Skip to content

Commit

Permalink
Merge pull request #874 from dtolnay/litspan
Browse files Browse the repository at this point in the history
Add Lit::span, Lit::set_span
  • Loading branch information
dtolnay authored Jul 27, 2020
2 parents 2fa9c25 + 5448714 commit 1b73cc2
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/lit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,32 @@ mod value {
Lit::Bool(_) | Lit::Verbatim(_) => "",
}
}

pub fn span(&self) -> Span {
match self {
Lit::Str(lit) => lit.span(),
Lit::ByteStr(lit) => lit.span(),
Lit::Byte(lit) => lit.span(),
Lit::Char(lit) => lit.span(),
Lit::Int(lit) => lit.span(),
Lit::Float(lit) => lit.span(),
Lit::Bool(lit) => lit.span,
Lit::Verbatim(lit) => lit.span(),
}
}

pub fn set_span(&mut self, span: Span) {
match self {
Lit::Str(lit) => lit.set_span(span),
Lit::ByteStr(lit) => lit.set_span(span),
Lit::Byte(lit) => lit.set_span(span),
Lit::Char(lit) => lit.set_span(span),
Lit::Int(lit) => lit.set_span(span),
Lit::Float(lit) => lit.set_span(span),
Lit::Bool(lit) => lit.span = span,
Lit::Verbatim(lit) => lit.set_span(span),
}
}
}

/// Get the byte at offset idx, or a default of `b'\0'` if we're looking
Expand Down

0 comments on commit 1b73cc2

Please sign in to comment.