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§
Trait Implementations§
source§impl Clone for SpanDisplay
impl Clone for SpanDisplay
source§fn clone(&self) -> SpanDisplay
fn clone(&self) -> SpanDisplay
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for SpanDisplay
impl Debug for SpanDisplay
source§impl Display for SpanDisplay
impl Display for SpanDisplay
source§impl From<Span> for SpanDisplay
impl From<Span> for SpanDisplay
impl Copy for SpanDisplay
Auto Trait Implementations§
impl Freeze for SpanDisplay
impl RefUnwindSafe for SpanDisplay
impl !Send for SpanDisplay
impl !Sync for SpanDisplay
impl Unpin for SpanDisplay
impl UnwindSafe for SpanDisplay
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
Mutably borrows from an owned value. Read more