Change crop_length type from Option(usize) to usize

This commit is contained in:
Clémentine Urquizar 2021-06-13 12:37:38 +02:00
parent 638009fb2b
commit 65130d9ee7
No known key found for this signature in database
GPG Key ID: D8E7CC7422E77E1A
2 changed files with 5 additions and 5 deletions

View File

@ -22,8 +22,8 @@ const fn default_search_limit() -> usize {
}
pub const DEFAULT_CROP_LENGTH: usize = 200;
const fn default_crop_length() -> Option<usize> {
Some(DEFAULT_CROP_LENGTH)
const fn default_crop_length() -> usize {
DEFAULT_CROP_LENGTH
}
#[derive(Deserialize)]
@ -36,7 +36,7 @@ pub struct SearchQuery {
pub attributes_to_retrieve: Option<HashSet<String>>,
pub attributes_to_crop: Option<Vec<String>>,
#[serde(default = "default_crop_length")]
pub crop_length: Option<usize>,
pub crop_length: usize,
pub attributes_to_highlight: Option<HashSet<String>>,
pub matches: Option<bool>,
pub filter: Option<Value>,
@ -133,7 +133,7 @@ impl Index {
let mut ids_length_crop = HashMap::new();
for attribute in attributes {
let mut attr_name = attribute.clone();
let mut attr_len = query.crop_length;
let mut attr_len = Some(query.crop_length);
if attr_name.contains(':') {
let mut split = attr_name.rsplit(':');

View File

@ -23,7 +23,7 @@ pub struct SearchQueryGet {
limit: Option<usize>,
attributes_to_retrieve: Option<String>,
attributes_to_crop: Option<String>,
crop_length: Option<usize>,
crop_length: usize,
attributes_to_highlight: Option<String>,
filter: Option<String>,
matches: Option<bool>,