pub struct Spanned {
pub span: Span,
pub form: SpannedForm,
}Expand description
An S-expression node with source position.
Fields§
§span: Span§form: SpannedFormImplementations§
Source§impl Spanned
impl Spanned
pub fn new(span: Span, form: SpannedForm) -> Spanned
Sourcepub fn synthetic_nil() -> Spanned
pub fn synthetic_nil() -> Spanned
Synthetic nil — useful as a placeholder in macro expansion when no real span is available.
Sourcepub fn from_sexp_synthetic(s: &Sexp) -> Spanned
pub fn from_sexp_synthetic(s: &Sexp) -> Spanned
Lift a plain Sexp to a Spanned with every node marked synthetic.
Useful when a macro template generates literal structure that has no
user-source origin.
Sourcepub fn from_sexp_at(s: &Sexp, span: Span) -> Spanned
pub fn from_sexp_at(s: &Sexp, span: Span) -> Spanned
Lift a plain Sexp to a Spanned with every node assigned the given
span. Used by the expander to stamp macro-generated subtrees with
the call-site span so errors point somewhere useful.
pub fn is_list(&self) -> bool
pub fn as_list(&self) -> Option<&[Spanned]>
pub fn as_symbol(&self) -> Option<&str>
pub fn as_keyword(&self) -> Option<&str>
pub fn as_string(&self) -> Option<&str>
pub fn as_int(&self) -> Option<i64>
Trait Implementations§
impl StructuralPartialEq for Spanned
Auto Trait Implementations§
impl Freeze for Spanned
impl RefUnwindSafe for Spanned
impl Send for Spanned
impl Sync for Spanned
impl Unpin for Spanned
impl UnsafeUnpin for Spanned
impl UnwindSafe for Spanned
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