mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 12:27:13 +02:00
Add Token::original_span rather than making Token::span pub
This commit is contained in:
parent
d80ce00623
commit
ae8660e585
2 changed files with 10 additions and 5 deletions
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue