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§
Sourcefn try_split_attr_mut<F, R>(&mut self, f: F) -> Result<R>
fn try_split_attr_mut<F, R>(&mut self, f: F) -> Result<R>
Takes a closure and calls it with separated attrs and item, as both mutable references.
- Try to get attrs; Otherwise
Err - Split
attrsfromselfwith std::mem::replace - Call the closure
f - Merge
attrsintoself
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.