Struct parsel::util::SpanDisplay
source · [−]pub struct SpanDisplay { /* private fields */ }
Expand description
Helper type that formats a Span
in a human-readable way.
#[derive(Clone, Debug, Parse)]
struct HttpHeader {
key: Separated<Word, Token![-]>,
colon: Token![:],
value: TokenStream,
}
let header: HttpHeader = parsel::parse_str(r#"
// this comment exists only so that there is a line before the actual tokens
Content-Type: application/json
/* another comment, just to confuse the lexer */
"#)?;
let key_span = header.key.format_span().to_string();
assert_eq!(key_span, "3:5..3:16");
let colon_span = header.colon.format_span().to_string();
assert_eq!(colon_span, "3:17..3:17");
let value_span = header.value.format_span().to_string();
assert_eq!(value_span, "3:19..3:34");
Implementations
sourceimpl SpanDisplay
impl SpanDisplay
Trait Implementations
sourceimpl Clone for SpanDisplay
impl Clone for SpanDisplay
sourcefn clone(&self) -> SpanDisplay
fn clone(&self) -> SpanDisplay
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Debug for SpanDisplay
impl Debug for SpanDisplay
sourceimpl Display for SpanDisplay
impl Display for SpanDisplay
sourceimpl From<Span> for SpanDisplay
impl From<Span> for SpanDisplay
impl Copy for SpanDisplay
Auto Trait Implementations
impl RefUnwindSafe for SpanDisplay
impl !Send for SpanDisplay
impl !Sync for SpanDisplay
impl Unpin for SpanDisplay
impl UnwindSafe for SpanDisplay
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more