pub struct Located<D, Sp = SimpleSpan, Sl = ()> { /* private fields */ }Expand description
A value with complete location information: both which source and where in that source.
Located<D, Sp, Sl> combines a value of type D with:
- A slice identifier
Slindicating which source the data came from - A span
Spindicating where within that source the data is located
This provides the most complete location tracking possible, combining the benefits
of both Sliced (source tracking) and Spanned (position tracking).
§Design
Located uses public fields for direct access, but also provides accessor methods
for consistency. It implements Deref and DerefMut to allow transparent access
to the inner data while keeping full location information available when needed.
§Common Patterns
§Transparent Access via Deref
Thanks to Deref, you can call methods on the wrapped value directly:
use tokit::utils::{Located, Span};
let located = Located::new("main.rs", Span::new(10, 15), "hello");
// Can call str methods directly
assert_eq!(located.len(), 5);
assert_eq!(located.to_uppercase(), "HELLO");
// But can still access location info
assert_eq!(located.slice(), "main.rs");
assert_eq!(located.span().start(), 10);§Multi-File Error Reporting
use tokit::utils::{Located, Span};
use std::path::PathBuf;
fn report_error<T>(loc: &Located<T, Span, PathBuf>, message: &str)
where
T: core::fmt::Debug
{
eprintln!(
"Error in {}:{}:{}: {}\n {:?}",
loc.slice().display(),
get_line_number(loc.span().start()),
get_column_number(loc.span().start()),
message,
loc.data()
);
}§Building Complete AST Nodes
use tokit::utils::{Located, Span};
use std::path::PathBuf;
type Loc<T> = Located<T, Span, PathBuf>;
enum Expr {
Number(i64),
BinOp {
op: String,
left: Box<Loc<Expr>>,
right: Box<Loc<Expr>>,
},
}
// Each expression knows exactly where it came from
let expr = Loc::new(
PathBuf::from("src/calc.rs"),
Span::new(45, 52),
Expr::Number(42)
);
// Can report: "Error in src/calc.rs:3:12-19"§Cross-File Reference Checking
use tokit::utils::{Located, Span};
fn check_reference(
reference: &Located<String, Span, String>,
definition: &Located<String, Span, String>
) -> Result<(), String> {
if reference.slice() != definition.slice() {
Err(format!(
"Cross-file reference: {} (in {}) references {} (in {})",
reference.data(),
reference.slice(),
definition.data(),
definition.slice()
))
} else {
Ok(())
}
}§Mapping Values While Preserving Full Location
use tokit::utils::{Located, Span};
let located_str = Located::new("input.txt", Span::new(5, 7), "42");
// Parse the string, keeping both source and position
let parsed: Located<i32, Span, &str> = located_str.map_data(|s| s.parse().unwrap());
assert_eq!(*parsed, 42);
assert_eq!(parsed.slice(), "input.txt");
assert_eq!(parsed.span().start(), 5);§IDE Integration
use tokit::utils::{Located, Span};
use std::path::PathBuf;
struct Diagnostic {
severity: Severity,
message: String,
location: Located<(), Span, PathBuf>,
}
// Generate diagnostics with complete location info
fn undefined_variable(name: &Located<String, Span, PathBuf>) -> Diagnostic {
Diagnostic {
severity: Severity::Error,
message: format!("Undefined variable '{}'", name.data()),
location: name.as_ref().map_data(|_| ()),
}
}
// IDE can jump to exact location:
// - Open file: diagnostic.location.slice()
// - Navigate to: diagnostic.location.span()§Incremental Compilation with Position Tracking
use tokit::utils::{Located, Span};
use std::collections::HashMap;
struct Definition {
name: String,
location: Located<(), Span, String>,
}
// Track where each definition is located
let mut definitions: HashMap<String, Definition> = HashMap::new();
// When a file changes, only recheck definitions in that file
fn recheck_file(file: &str, definitions: &mut HashMap<String, Definition>) {
definitions.retain(|_, def| def.location.slice() != file);
// Re-parse and add new definitions from the changed file
}§Trait Implementations
Deref/DerefMut: Access the inner data transparentlyDisplay: Delegates to the inner data’sDisplayimplementationIntoComponents: Destructure into(Sl, Sp, D)tuple
§Examples
§Basic Usage
use tokit::utils::{Located, Span};
let located = Located::new("file.rs", Span::new(0, 5), "hello");
assert_eq!(located.slice(), "file.rs");
assert_eq!(located.span(), Span::new(0, 5));
assert_eq!(located.data(), &"hello");
assert_eq!(*located, "hello"); // Via Deref§Destructuring
use tokit::utils::{Located, Span};
let located = Located::new("main.rs", Span::new(10, 20), 42);
let (slice, span, value) = located.into_components();
assert_eq!(slice, "main.rs");
assert_eq!(span, Span::new(10, 20));
assert_eq!(value, 42);§Mutable Access
use tokit::utils::{Located, Span};
let mut located = Located::new("input", Span::new(0, 2), 10);
// Modify the data
*located += 5;
assert_eq!(*located, 15);
// Modify the slice
*located.slice_mut() = "output";
assert_eq!(located.slice(), "output");
// Modify the span
located.span_mut().set_end(5);
assert_eq!(located.span().end(), 5);§Conversion from Spanned or Sliced
use tokit::utils::{Located, Span, Spanned, Sliced};
// From Spanned by adding slice info
let spanned = Spanned::new(Span::new(5, 10), "data");
let located = Located::new("file.rs", spanned.span(), spanned.into_data());
// From Sliced by adding span info
let sliced = Sliced::new("config.toml", "value");
let located = Located::new(sliced.into_slice(), Span::new(0, 5), "value");Implementations§
Source§impl<D, Sp, Sl> Located<D, Sp, Sl>
impl<D, Sp, Sl> Located<D, Sp, Sl>
Sourcepub const fn new(slice: Sl, span: Sp, data: D) -> Self
pub const fn new(slice: Sl, span: Sp, data: D) -> Self
Create a new located value.
§Example
use tokit::utils::{Located, Span};
let located = Located::new("file.rs", Span::new(10, 15), "hello");
assert_eq!(located.slice(), "file.rs");
assert_eq!(located.span(), Span::new(10, 15));
assert_eq!(located.data(), &"hello");Sourcepub const fn slice(&self) -> Slwhere
Sl: Copy,
pub const fn slice(&self) -> Slwhere
Sl: Copy,
Get a copy of the slice.
§Example
use tokit::utils::{Located, Span};
let located = Located::new("main.rs", Span::new(0, 5), "data");
assert_eq!(located.slice(), "main.rs");Sourcepub const fn slice_ref(&self) -> &Sl
pub const fn slice_ref(&self) -> &Sl
Get a reference to the slice.
§Example
use tokit::utils::{Located, Span};
let located = Located::new("config.toml", Span::new(5, 10), "data");
assert_eq!(located.slice_ref(), &"config.toml");Sourcepub const fn slice_mut(&mut self) -> &mut Sl
pub const fn slice_mut(&mut self) -> &mut Sl
Get a mutable reference to the slice.
§Example
use tokit::utils::{Located, Span};
let mut located = Located::new("old.txt", Span::new(0, 3), "data");
*located.slice_mut() = "new.txt";
assert_eq!(located.slice(), "new.txt");Sourcepub const fn span(&self) -> Spwhere
Sp: Copy,
pub const fn span(&self) -> Spwhere
Sp: Copy,
Get a copy of the span.
§Example
use tokit::utils::{Located, Span};
let located = Located::new("file.rs", Span::new(5, 10), "data");
assert_eq!(located.span(), Span::new(5, 10));Sourcepub const fn span_ref(&self) -> &Sp
pub const fn span_ref(&self) -> &Sp
Get a reference to the span.
§Example
use tokit::utils::{Located, Span};
let located = Located::new("file.rs", Span::new(5, 10), "data");
assert_eq!(located.span_ref(), &Span::new(5, 10));Sourcepub const fn span_mut(&mut self) -> &mut Sp
pub const fn span_mut(&mut self) -> &mut Sp
Get a mutable reference to the span.
§Example
use tokit::utils::{Located, Span};
let mut located = Located::new("file.rs", Span::new(0, 5), "data");
located.span_mut().set_end(10);
assert_eq!(located.span().end(), 10);Sourcepub const fn data(&self) -> &D
pub const fn data(&self) -> &D
Get a reference to the data.
§Example
use tokit::utils::{Located, Span};
let located = Located::new("file.txt", Span::new(0, 2), 42);
assert_eq!(*located.data(), 42);Sourcepub const fn data_mut(&mut self) -> &mut D
pub const fn data_mut(&mut self) -> &mut D
Get a mutable reference to the data.
§Example
use tokit::utils::{Located, Span};
let mut located = Located::new("file.txt", Span::new(0, 2), 42);
*located.data_mut() = 100;
assert_eq!(*located.data(), 100);Sourcepub const fn as_ref(&self) -> Located<&D, &Sp, &Sl>
pub const fn as_ref(&self) -> Located<&D, &Sp, &Sl>
Returns a reference to the slice, span, and data.
§Example
use tokit::utils::{Located, Span};
let located = Located::new(
String::from("file.txt"),
Span::new(0, 5),
String::from("hello")
);
let borrowed: Located<&String, &Span, &String> = located.as_ref();
assert_eq!(borrowed.data(), &"hello");Sourcepub const fn as_mut(&mut self) -> Located<&mut D, &mut Sp, &mut Sl>
pub const fn as_mut(&mut self) -> Located<&mut D, &mut Sp, &mut Sl>
Returns a mutable reference to the slice, span, and data.
§Example
use tokit::utils::{Located, Span};
let mut located = Located::new(
String::from("file.txt"),
Span::new(0, 5),
String::from("hello")
);
let mut borrowed: Located<&mut String, &mut Span, &mut String> = located.as_mut();
borrowed.data_mut().push_str(" world");
assert_eq!(located.data(), &"hello world");Sourcepub fn into_slice(self) -> Sl
pub fn into_slice(self) -> Sl
Consume the located value and return the slice.
Sourcepub fn into_components(self) -> (Sl, Sp, D)
pub fn into_components(self) -> (Sl, Sp, D)
Decompose the located value into its slice, span, and data.
Sourcepub fn into_spanned(self) -> Spanned<D, Sp>
pub fn into_spanned(self) -> Spanned<D, Sp>
Convert into a Spanned value, discarding the slice information.
Sourcepub fn into_sliced(self) -> Sliced<D, Sl>
pub fn into_sliced(self) -> Sliced<D, Sl>
Convert into a Sliced value, discarding the span information.
Trait Implementations§
Source§impl<D, Sp, Sl> Error for Located<D, Sp, Sl>
impl<D, Sp, Sl> Error for Located<D, Sp, Sl>
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl<D, Sp, Sl> IntoComponents for Located<D, Sp, Sl>
impl<D, Sp, Sl> IntoComponents for Located<D, Sp, Sl>
Source§type Components = (Sl, Sp, D)
type Components = (Sl, Sp, D)
Source§fn into_components(self) -> Self::Components
fn into_components(self) -> Self::Components
Source§impl<D: Ord, Sp: Ord, Sl: Ord> Ord for Located<D, Sp, Sl>
impl<D: Ord, Sp: Ord, Sl: Ord> Ord for Located<D, Sp, Sl>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<'inp, L, Ctx, Lang: ?Sized> ParseInput<'inp, L, Located<<L as Lexer<'inp>>::Token, <L as Lexer<'inp>>::Span, <<L as Lexer<'inp>>::Source as Source<<L as Lexer<'inp>>::Offset>>::Slice<'inp>>, Ctx, Lang> for With<Any<L, Ctx, Lang>, PhantomLocated>
impl<'inp, L, Ctx, Lang: ?Sized> ParseInput<'inp, L, Located<<L as Lexer<'inp>>::Token, <L as Lexer<'inp>>::Span, <<L as Lexer<'inp>>::Source as Source<<L as Lexer<'inp>>::Offset>>::Slice<'inp>>, Ctx, Lang> for With<Any<L, Ctx, Lang>, PhantomLocated>
Source§fn parse_input(
&mut self,
inp: &mut InputRef<'inp, '_, L, Ctx, Lang>,
) -> Result<Located<L::Token, L::Span, <L::Source as Source<L::Offset>>::Slice<'inp>>, <Ctx::Emitter as Emitter<'inp, L, Lang>>::Error>where
Ctx: ParseContext<'inp, L, Lang>,
fn parse_input(
&mut self,
inp: &mut InputRef<'inp, '_, L, Ctx, Lang>,
) -> Result<Located<L::Token, L::Span, <L::Source as Source<L::Offset>>::Slice<'inp>>, <Ctx::Emitter as Emitter<'inp, L, Lang>>::Error>where
Ctx: ParseContext<'inp, L, Lang>,
Source§fn spanned(self) -> With<PhantomSpan, Self>where
Self: Sized,
fn spanned(self) -> With<PhantomSpan, Self>where
Self: Sized,
Spanned with the span of the parsed input.Source§fn sourced(self) -> With<PhantomSliced, Self>where
Self: Sized,
fn sourced(self) -> With<PhantomSliced, Self>where
Self: Sized,
Sliced with the source slice of the parsed input.Source§fn located(self) -> With<PhantomLocated, Self>where
Self: Sized,
fn located(self) -> With<PhantomLocated, Self>where
Self: Sized,
Located with the span and source slice of the parsed input.Source§fn repeated<Condition, W>(
self,
condition: Condition,
) -> Repeated<Self, Condition, O, W>
fn repeated<Condition, W>( self, condition: Condition, ) -> Repeated<Self, Condition, O, W>
Repeated combinator that applies this parser repeatedly
until the condition handler Condition returns [RepeatedAction::End] or an fatal error.Source§fn separated_by<SepClassifier, Condition, W>(
self,
sep_classifier: SepClassifier,
condition: Condition,
) -> SeparatedBy<Self, SepClassifier, Condition, O, W, L, Ctx>
fn separated_by<SepClassifier, Condition, W>( self, sep_classifier: SepClassifier, condition: Condition, ) -> SeparatedBy<Self, SepClassifier, Condition, O, W, L, Ctx>
SeparatedBy combinator that applies this parser repeatedly,Source§fn separated_by_comma<Condition, W>(
self,
condition: Condition,
) -> SeparatedBy<Self, Comma, Condition, O, W, L, Ctx>where
Self: Sized,
L: Lexer<'inp>,
L::Token: PunctuatorToken<'inp>,
Ctx: ParseContext<'inp, L, Lang>,
Condition: Decision<'inp, L, Ctx::Emitter, W, Lang>,
W: Window,
fn separated_by_comma<Condition, W>(
self,
condition: Condition,
) -> SeparatedBy<Self, Comma, Condition, O, W, L, Ctx>where
Self: Sized,
L: Lexer<'inp>,
L::Token: PunctuatorToken<'inp>,
Ctx: ParseContext<'inp, L, Lang>,
Condition: Decision<'inp, L, Ctx::Emitter, W, Lang>,
W: Window,
SeparatedBy combinator that applies this parser repeatedly,Source§fn peek_then<C, W>(self, condition: C) -> PeekThen<Self, C, L::Token, W>
fn peek_then<C, W>(self, condition: C) -> PeekThen<Self, C, L::Token, W>
PeekThen combinator that peeks at most N tokens first from the input before parsing. Read moreSource§fn peek_then_or_not<C, W>(
self,
condition: C,
) -> OrNot<PeekThen<Self, C, L::Token, W>>
fn peek_then_or_not<C, W>( self, condition: C, ) -> OrNot<PeekThen<Self, C, L::Token, W>>
PeekThen combinator that peeks at most N tokens first from the input before parsing. Read moreSource§fn map<U, F>(self, f: F) -> Map<Self, F, L, Ctx, O, U, Lang>
fn map<U, F>(self, f: F) -> Map<Self, F, L, Ctx, O, U, Lang>
Source§fn filter<F>(self, validator: F) -> Filter<Self, F>
fn filter<F>(self, validator: F) -> Filter<Self, F>
Source§fn filter_map<U, F>(self, mapper: F) -> FilterMap<Self, F, O>
fn filter_map<U, F>(self, mapper: F) -> FilterMap<Self, F, O>
Source§fn validate<F>(self, validator: F) -> Validate<Self, F>
fn validate<F>(self, validator: F) -> Validate<Self, F>
Source§fn then_ignore<G, U>(self, second: G) -> ThenIgnore<Self, G, U>
fn then_ignore<G, U>(self, second: G) -> ThenIgnore<Self, G, U>
Source§fn then<T, U>(self, then: T) -> Then<Self, T>
fn then<T, U>(self, then: T) -> Then<Self, T>
Source§fn ignore_then<G, U>(self, second: G) -> IgnoreThen<Self, G, O>where
Self: Sized,
G: ParseInput<'inp, L, U, Ctx, Lang>,
fn ignore_then<G, U>(self, second: G) -> IgnoreThen<Self, G, O>where
Self: Sized,
G: ParseInput<'inp, L, U, Ctx, Lang>,
Source§fn recover<R>(self, recovery: R) -> Recover<Self, R>
fn recover<R>(self, recovery: R) -> Recover<Self, R>
Source§fn inplace_recover<R>(self, recovery: R) -> InplaceRecover<Self, R>
fn inplace_recover<R>(self, recovery: R) -> InplaceRecover<Self, R>
Source§impl<'inp, L, Ctx, Lang, Classifier> ParseInput<'inp, L, Located<<L as Lexer<'inp>>::Token, <L as Lexer<'inp>>::Span, <<L as Lexer<'inp>>::Source as Source<<L as Lexer<'inp>>::Offset>>::Slice<'inp>>, Ctx, Lang> for With<Expect<Classifier, Ctx, Lang>, PhantomLocated>where
L: Lexer<'inp>,
Ctx: ParseContext<'inp, L, Lang>,
<Ctx::Emitter as Emitter<'inp, L, Lang>>::Error: From<UnexpectedToken<'inp, L::Token, <L::Token as Token<'inp>>::Kind, L::Span, Lang>> + From<<L::Token as Token<'inp>>::Error> + From<UnexpectedEot<L::Offset, Lang>>,
Classifier: Check<L::Token, Result<(), Expected<'inp, <L::Token as Token<'inp>>::Kind>>>,
impl<'inp, L, Ctx, Lang, Classifier> ParseInput<'inp, L, Located<<L as Lexer<'inp>>::Token, <L as Lexer<'inp>>::Span, <<L as Lexer<'inp>>::Source as Source<<L as Lexer<'inp>>::Offset>>::Slice<'inp>>, Ctx, Lang> for With<Expect<Classifier, Ctx, Lang>, PhantomLocated>where
L: Lexer<'inp>,
Ctx: ParseContext<'inp, L, Lang>,
<Ctx::Emitter as Emitter<'inp, L, Lang>>::Error: From<UnexpectedToken<'inp, L::Token, <L::Token as Token<'inp>>::Kind, L::Span, Lang>> + From<<L::Token as Token<'inp>>::Error> + From<UnexpectedEot<L::Offset, Lang>>,
Classifier: Check<L::Token, Result<(), Expected<'inp, <L::Token as Token<'inp>>::Kind>>>,
Source§fn parse_input(
&mut self,
inp: &mut InputRef<'inp, '_, L, Ctx, Lang>,
) -> Result<Located<L::Token, L::Span, <L::Source as Source<L::Offset>>::Slice<'inp>>, <Ctx::Emitter as Emitter<'inp, L, Lang>>::Error>
fn parse_input( &mut self, inp: &mut InputRef<'inp, '_, L, Ctx, Lang>, ) -> Result<Located<L::Token, L::Span, <L::Source as Source<L::Offset>>::Slice<'inp>>, <Ctx::Emitter as Emitter<'inp, L, Lang>>::Error>
Source§fn spanned(self) -> With<PhantomSpan, Self>where
Self: Sized,
fn spanned(self) -> With<PhantomSpan, Self>where
Self: Sized,
Spanned with the span of the parsed input.Source§fn sourced(self) -> With<PhantomSliced, Self>where
Self: Sized,
fn sourced(self) -> With<PhantomSliced, Self>where
Self: Sized,
Sliced with the source slice of the parsed input.Source§fn located(self) -> With<PhantomLocated, Self>where
Self: Sized,
fn located(self) -> With<PhantomLocated, Self>where
Self: Sized,
Located with the span and source slice of the parsed input.Source§fn repeated<Condition, W>(
self,
condition: Condition,
) -> Repeated<Self, Condition, O, W>
fn repeated<Condition, W>( self, condition: Condition, ) -> Repeated<Self, Condition, O, W>
Repeated combinator that applies this parser repeatedly
until the condition handler Condition returns [RepeatedAction::End] or an fatal error.Source§fn separated_by<SepClassifier, Condition, W>(
self,
sep_classifier: SepClassifier,
condition: Condition,
) -> SeparatedBy<Self, SepClassifier, Condition, O, W, L, Ctx>
fn separated_by<SepClassifier, Condition, W>( self, sep_classifier: SepClassifier, condition: Condition, ) -> SeparatedBy<Self, SepClassifier, Condition, O, W, L, Ctx>
SeparatedBy combinator that applies this parser repeatedly,Source§fn separated_by_comma<Condition, W>(
self,
condition: Condition,
) -> SeparatedBy<Self, Comma, Condition, O, W, L, Ctx>where
Self: Sized,
L: Lexer<'inp>,
L::Token: PunctuatorToken<'inp>,
Ctx: ParseContext<'inp, L, Lang>,
Condition: Decision<'inp, L, Ctx::Emitter, W, Lang>,
W: Window,
fn separated_by_comma<Condition, W>(
self,
condition: Condition,
) -> SeparatedBy<Self, Comma, Condition, O, W, L, Ctx>where
Self: Sized,
L: Lexer<'inp>,
L::Token: PunctuatorToken<'inp>,
Ctx: ParseContext<'inp, L, Lang>,
Condition: Decision<'inp, L, Ctx::Emitter, W, Lang>,
W: Window,
SeparatedBy combinator that applies this parser repeatedly,Source§fn peek_then<C, W>(self, condition: C) -> PeekThen<Self, C, L::Token, W>
fn peek_then<C, W>(self, condition: C) -> PeekThen<Self, C, L::Token, W>
PeekThen combinator that peeks at most N tokens first from the input before parsing. Read moreSource§fn peek_then_or_not<C, W>(
self,
condition: C,
) -> OrNot<PeekThen<Self, C, L::Token, W>>
fn peek_then_or_not<C, W>( self, condition: C, ) -> OrNot<PeekThen<Self, C, L::Token, W>>
PeekThen combinator that peeks at most N tokens first from the input before parsing. Read moreSource§fn map<U, F>(self, f: F) -> Map<Self, F, L, Ctx, O, U, Lang>
fn map<U, F>(self, f: F) -> Map<Self, F, L, Ctx, O, U, Lang>
Source§fn filter<F>(self, validator: F) -> Filter<Self, F>
fn filter<F>(self, validator: F) -> Filter<Self, F>
Source§fn filter_map<U, F>(self, mapper: F) -> FilterMap<Self, F, O>
fn filter_map<U, F>(self, mapper: F) -> FilterMap<Self, F, O>
Source§fn validate<F>(self, validator: F) -> Validate<Self, F>
fn validate<F>(self, validator: F) -> Validate<Self, F>
Source§fn then_ignore<G, U>(self, second: G) -> ThenIgnore<Self, G, U>
fn then_ignore<G, U>(self, second: G) -> ThenIgnore<Self, G, U>
Source§fn then<T, U>(self, then: T) -> Then<Self, T>
fn then<T, U>(self, then: T) -> Then<Self, T>
Source§fn ignore_then<G, U>(self, second: G) -> IgnoreThen<Self, G, O>where
Self: Sized,
G: ParseInput<'inp, L, U, Ctx, Lang>,
fn ignore_then<G, U>(self, second: G) -> IgnoreThen<Self, G, O>where
Self: Sized,
G: ParseInput<'inp, L, U, Ctx, Lang>,
Source§fn recover<R>(self, recovery: R) -> Recover<Self, R>
fn recover<R>(self, recovery: R) -> Recover<Self, R>
Source§fn inplace_recover<R>(self, recovery: R) -> InplaceRecover<Self, R>
fn inplace_recover<R>(self, recovery: R) -> InplaceRecover<Self, R>
Source§impl<'inp, L, O, Ctx, P, Lang: ?Sized> ParseInput<'inp, L, Located<O, <L as Lexer<'inp>>::Span, <<L as Lexer<'inp>>::Source as Source<<L as Lexer<'inp>>::Offset>>::Slice<'inp>>, Ctx, Lang> for With<PhantomLocated, P>
impl<'inp, L, O, Ctx, P, Lang: ?Sized> ParseInput<'inp, L, Located<O, <L as Lexer<'inp>>::Span, <<L as Lexer<'inp>>::Source as Source<<L as Lexer<'inp>>::Offset>>::Slice<'inp>>, Ctx, Lang> for With<PhantomLocated, P>
Source§fn parse_input(
&mut self,
inp: &mut InputRef<'inp, '_, L, Ctx, Lang>,
) -> Result<Located<O, L::Span, <L::Source as Source<L::Offset>>::Slice<'inp>>, <Ctx::Emitter as Emitter<'inp, L, Lang>>::Error>
fn parse_input( &mut self, inp: &mut InputRef<'inp, '_, L, Ctx, Lang>, ) -> Result<Located<O, L::Span, <L::Source as Source<L::Offset>>::Slice<'inp>>, <Ctx::Emitter as Emitter<'inp, L, Lang>>::Error>
Source§fn spanned(self) -> With<PhantomSpan, Self>where
Self: Sized,
fn spanned(self) -> With<PhantomSpan, Self>where
Self: Sized,
Spanned with the span of the parsed input.Source§fn sourced(self) -> With<PhantomSliced, Self>where
Self: Sized,
fn sourced(self) -> With<PhantomSliced, Self>where
Self: Sized,
Sliced with the source slice of the parsed input.Source§fn located(self) -> With<PhantomLocated, Self>where
Self: Sized,
fn located(self) -> With<PhantomLocated, Self>where
Self: Sized,
Located with the span and source slice of the parsed input.Source§fn repeated<Condition, W>(
self,
condition: Condition,
) -> Repeated<Self, Condition, O, W>
fn repeated<Condition, W>( self, condition: Condition, ) -> Repeated<Self, Condition, O, W>
Repeated combinator that applies this parser repeatedly
until the condition handler Condition returns [RepeatedAction::End] or an fatal error.Source§fn separated_by<SepClassifier, Condition, W>(
self,
sep_classifier: SepClassifier,
condition: Condition,
) -> SeparatedBy<Self, SepClassifier, Condition, O, W, L, Ctx>
fn separated_by<SepClassifier, Condition, W>( self, sep_classifier: SepClassifier, condition: Condition, ) -> SeparatedBy<Self, SepClassifier, Condition, O, W, L, Ctx>
SeparatedBy combinator that applies this parser repeatedly,Source§fn separated_by_comma<Condition, W>(
self,
condition: Condition,
) -> SeparatedBy<Self, Comma, Condition, O, W, L, Ctx>where
Self: Sized,
L: Lexer<'inp>,
L::Token: PunctuatorToken<'inp>,
Ctx: ParseContext<'inp, L, Lang>,
Condition: Decision<'inp, L, Ctx::Emitter, W, Lang>,
W: Window,
fn separated_by_comma<Condition, W>(
self,
condition: Condition,
) -> SeparatedBy<Self, Comma, Condition, O, W, L, Ctx>where
Self: Sized,
L: Lexer<'inp>,
L::Token: PunctuatorToken<'inp>,
Ctx: ParseContext<'inp, L, Lang>,
Condition: Decision<'inp, L, Ctx::Emitter, W, Lang>,
W: Window,
SeparatedBy combinator that applies this parser repeatedly,Source§fn peek_then<C, W>(self, condition: C) -> PeekThen<Self, C, L::Token, W>
fn peek_then<C, W>(self, condition: C) -> PeekThen<Self, C, L::Token, W>
PeekThen combinator that peeks at most N tokens first from the input before parsing. Read moreSource§fn peek_then_or_not<C, W>(
self,
condition: C,
) -> OrNot<PeekThen<Self, C, L::Token, W>>
fn peek_then_or_not<C, W>( self, condition: C, ) -> OrNot<PeekThen<Self, C, L::Token, W>>
PeekThen combinator that peeks at most N tokens first from the input before parsing. Read moreSource§fn map<U, F>(self, f: F) -> Map<Self, F, L, Ctx, O, U, Lang>
fn map<U, F>(self, f: F) -> Map<Self, F, L, Ctx, O, U, Lang>
Source§fn filter<F>(self, validator: F) -> Filter<Self, F>
fn filter<F>(self, validator: F) -> Filter<Self, F>
Source§fn filter_map<U, F>(self, mapper: F) -> FilterMap<Self, F, O>
fn filter_map<U, F>(self, mapper: F) -> FilterMap<Self, F, O>
Source§fn validate<F>(self, validator: F) -> Validate<Self, F>
fn validate<F>(self, validator: F) -> Validate<Self, F>
Source§fn then_ignore<G, U>(self, second: G) -> ThenIgnore<Self, G, U>
fn then_ignore<G, U>(self, second: G) -> ThenIgnore<Self, G, U>
Source§fn then<T, U>(self, then: T) -> Then<Self, T>
fn then<T, U>(self, then: T) -> Then<Self, T>
Source§fn ignore_then<G, U>(self, second: G) -> IgnoreThen<Self, G, O>where
Self: Sized,
G: ParseInput<'inp, L, U, Ctx, Lang>,
fn ignore_then<G, U>(self, second: G) -> IgnoreThen<Self, G, O>where
Self: Sized,
G: ParseInput<'inp, L, U, Ctx, Lang>,
Source§fn recover<R>(self, recovery: R) -> Recover<Self, R>
fn recover<R>(self, recovery: R) -> Recover<Self, R>
Source§fn inplace_recover<R>(self, recovery: R) -> InplaceRecover<Self, R>
fn inplace_recover<R>(self, recovery: R) -> InplaceRecover<Self, R>
Source§impl<D: PartialOrd, Sp: PartialOrd, Sl: PartialOrd> PartialOrd for Located<D, Sp, Sl>
impl<D: PartialOrd, Sp: PartialOrd, Sl: PartialOrd> PartialOrd for Located<D, Sp, Sl>
impl<D: Copy, Sp: Copy, Sl: Copy> Copy for Located<D, Sp, Sl>
impl<D: Eq, Sp: Eq, Sl: Eq> Eq for Located<D, Sp, Sl>
impl<D, Sp, Sl> StructuralPartialEq for Located<D, Sp, Sl>
Auto Trait Implementations§
impl<D, Sp, Sl> Freeze for Located<D, Sp, Sl>
impl<D, Sp, Sl> RefUnwindSafe for Located<D, Sp, Sl>
impl<D, Sp, Sl> Send for Located<D, Sp, Sl>
impl<D, Sp, Sl> Sync for Located<D, Sp, Sl>
impl<D, Sp, Sl> Unpin for Located<D, Sp, Sl>
impl<D, Sp, Sl> UnwindSafe for Located<D, Sp, Sl>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Source for T
impl<T> Source for T
Source§type Slice<'a> = <<T as Deref>::Target as Source>::Slice<'a>
where
T: 'a
type Slice<'a> = <<T as Deref>::Target as Source>::Slice<'a> where T: 'a
Source can be sliced into.Source§fn read<'a, Chunk>(&'a self, offset: usize) -> Option<Chunk>where
Chunk: Chunk<'a>,
fn read<'a, Chunk>(&'a self, offset: usize) -> Option<Chunk>where
Chunk: Chunk<'a>,
None when reading
out of bounds would occur. Read moreSource§unsafe fn read_byte_unchecked(&self, offset: usize) -> u8
unsafe fn read_byte_unchecked(&self, offset: usize) -> u8
forbid_unsafe only.Source§fn slice(&self, range: Range<usize>) -> Option<<T as Source>::Slice<'_>>
fn slice(&self, range: Range<usize>) -> Option<<T as Source>::Slice<'_>>
slice::get(range). Read moreSource§unsafe fn slice_unchecked(
&self,
range: Range<usize>,
) -> <T as Source>::Slice<'_>
unsafe fn slice_unchecked( &self, range: Range<usize>, ) -> <T as Source>::Slice<'_>
forbid_unsafe only.slice::get_unchecked(range). Read more