From ca1617d3cd51427a59346ed777b734bd4d69dd4e Mon Sep 17 00:00:00 2001 From: Paul Masurel Date: Sat, 25 Feb 2017 20:32:26 +0900 Subject: [PATCH] Fixes #91 --- src/schema/schema.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/schema/schema.rs b/src/schema/schema.rs index 8b35aff01..287ad40a0 100644 --- a/src/schema/schema.rs +++ b/src/schema/schema.rs @@ -12,7 +12,7 @@ use std::sync::Arc; use super::*; use std::fmt; - +const MAX_NUM_FIELDS: usize = 255; /// Tantivy has a very strict schema. /// You need to specify in advance whether a field is indexed or not, @@ -94,10 +94,13 @@ impl SchemaBuilder { /// Finalize the creation of a `Schema` /// This will consume your `SchemaBuilder` pub fn build(self,) -> Schema { + if self.fields.len() > MAX_NUM_FIELDS { + panic!("There may be at most 255 fields."); + } Schema(Arc::new(InnerSchema { fields: self.fields, fields_map: self.fields_map, - })) + })) } }