mirror of
				https://github.com/meilisearch/meilisearch.git
				synced 2025-10-31 07:56:28 +00:00 
			
		
		
		
	feat: Add From<&str> implementation for Token
This commit is contained in:
		| @@ -115,6 +115,13 @@ impl<'a> From<Span<'a>> for Token<'a> { | ||||
|     } | ||||
| } | ||||
|  | ||||
| /// Allow [Token] to be constructed from &[str] | ||||
| impl<'a> From<&'a str> for Token<'a> { | ||||
|     fn from(s: &'a str) -> Self { | ||||
|         Token::from(Span::new_extra(s, s)) | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[derive(Debug, Clone, PartialEq, Eq)] | ||||
| pub enum FilterCondition<'a> { | ||||
|     Not(Box<Self>), | ||||
| @@ -664,6 +671,13 @@ pub mod tests { | ||||
|         assert!(filter.token_at_depth(2).is_some()); | ||||
|         assert!(filter.token_at_depth(3).is_none()); | ||||
|     } | ||||
|  | ||||
|     #[test] | ||||
|     fn token_from_str() { | ||||
|         let s = "test string that should not be parsed"; | ||||
|         let token: Token = s.into(); | ||||
|         assert_eq!(token.value(), s); | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> std::fmt::Display for FilterCondition<'a> { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user