mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-25 07:41:00 +00:00
Add Token::original_span rather than making Token::span pub
This commit is contained in:
@ -71,7 +71,7 @@ const MAX_FILTER_DEPTH: usize = 200;
|
||||
#[derive(Debug, Clone, Eq)]
|
||||
pub struct Token<'a> {
|
||||
/// The token in the original input, it should be used when possible.
|
||||
pub span: Span<'a>,
|
||||
span: Span<'a>,
|
||||
/// If you need to modify the original input you can use the `value` field
|
||||
/// to store your modified input.
|
||||
value: Option<String>,
|
||||
@ -100,6 +100,11 @@ impl<'a> Token<'a> {
|
||||
Error::new_from_external(self.span, error)
|
||||
}
|
||||
|
||||
/// Returns a copy of the span this token was created with.
|
||||
pub fn original_span(&self) -> Span<'a> {
|
||||
self.span
|
||||
}
|
||||
|
||||
pub fn parse_finite_float(&self) -> Result<f64, Error> {
|
||||
let value: f64 = self.value().parse().map_err(|e| self.as_external_error(e))?;
|
||||
if value.is_finite() {
|
||||
|
Reference in New Issue
Block a user