mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 20:15:07 +08:00
feat: Add From<&str> implementation for Token
This commit is contained in:
parent
d3731dda48
commit
1b5b5778c1
@ -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)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum FilterCondition<'a> {
|
pub enum FilterCondition<'a> {
|
||||||
Not(Box<Self>),
|
Not(Box<Self>),
|
||||||
@ -664,6 +671,13 @@ pub mod tests {
|
|||||||
assert!(filter.token_at_depth(2).is_some());
|
assert!(filter.token_at_depth(2).is_some());
|
||||||
assert!(filter.token_at_depth(3).is_none());
|
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> {
|
impl<'a> std::fmt::Display for FilterCondition<'a> {
|
||||||
|
Loading…
Reference in New Issue
Block a user