ItemAttrExt

Trait ItemAttrExt 

Source
pub trait ItemAttrExt: ItemLike {
    // Provided method
    fn try_split_attr_mut<F, R>(&mut self, f: F) -> Result<R>
       where F: FnOnce(&mut Vec<Attribute>, &mut Self) -> Result<R> { ... }
}
Expand description

Extension for syn::*Item::attrs using crate::ext::ItemLike

Provided Methods§

Source

fn try_split_attr_mut<F, R>(&mut self, f: F) -> Result<R>
where F: FnOnce(&mut Vec<Attribute>, &mut Self) -> Result<R>,

Takes a closure and calls it with separated attrs and item, as both mutable references.

  1. Try to get attrs; Otherwise Err
  2. Split attrs from self with std::mem::replace
  3. Call the closure f
  4. Merge attrs into self

Note: During the closure call, attrs in self is always an empty. Always access attrs with given closure parameter.

§Panics

Panics if replaced attrs in self is not empty at merge step.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ItemAttrExt for ImplItem

Source§

impl ItemAttrExt for Item

Source§

impl ItemAttrExt for TraitItem

Implementors§