diff --git a/milli/src/documents/builder.rs b/milli/src/documents/builder.rs index 2be7c1dd8..391175f31 100644 --- a/milli/src/documents/builder.rs +++ b/milli/src/documents/builder.rs @@ -108,7 +108,7 @@ impl DocumentBatchBuilder { .headers()? .into_iter() .map(parse_csv_header) - .map(|(k, t)| (this.index.insert(&k), t)) + .map(|(k, t)| (this.index.insert(k), t)) .collect::>(); for (i, record) in records.into_records().enumerate() { @@ -161,16 +161,16 @@ enum AllowedType { Number, } -fn parse_csv_header(header: &str) -> (String, AllowedType) { +fn parse_csv_header(header: &str) -> (&str, AllowedType) { // if there are several separators we only split on the last one. match header.rsplit_once(':') { Some((field_name, field_type)) => match field_type { - "string" => (field_name.to_string(), AllowedType::String), - "number" => (field_name.to_string(), AllowedType::Number), + "string" => (field_name, AllowedType::String), + "number" => (field_name, AllowedType::Number), // if the pattern isn't reconized, we keep the whole field. - _otherwise => (header.to_string(), AllowedType::String), + _otherwise => (header, AllowedType::String), }, - None => (header.to_string(), AllowedType::String), + None => (header, AllowedType::String), } }