pub struct Attributes { /* private fields */ }Expand description
A list of function attributes.
Attributes can be either named (e.g., @deprecated) or grouped
(e.g., @[attribute1, attribute2()]).
Implementations§
Source§impl Attributes
impl Attributes
Sourcepub fn with_attribute(self, attribute: impl Into<Attribute>) -> Self
pub fn with_attribute(self, attribute: impl Into<Attribute>) -> Self
Adds an attribute to this list of attributes.
Sourcepub fn append_attribute(&mut self, attribute: impl Into<Attribute>)
pub fn append_attribute(&mut self, attribute: impl Into<Attribute>)
Appends an attribute to this list of attributes.
Empty attribute groups are silently ignored.
Sourcepub fn iter_attributes(&self) -> impl Iterator<Item = &Attribute>
pub fn iter_attributes(&self) -> impl Iterator<Item = &Attribute>
Returns an iterator over the attributes in this list.
Sourcepub fn iter_mut_attributes(&mut self) -> impl Iterator<Item = &mut Attribute>
pub fn iter_mut_attributes(&mut self) -> impl Iterator<Item = &mut Attribute>
Returns a mutable iterator over the attributes in this list.
Sourcepub fn clear_attributes(&mut self)
pub fn clear_attributes(&mut self)
Clears all attributes.
Sourcepub fn has_attribute(&self, name: &str) -> bool
pub fn has_attribute(&self, name: &str) -> bool
Checks if an attribute with the given name exists in this list.
Sourcepub fn filter_attributes<F>(&mut self, predicate: F)
pub fn filter_attributes<F>(&mut self, predicate: F)
Filters attributes based on a predicate, keeping only those that return true. The predicate receives an immutable reference to each attribute.
Sourcepub fn filter_mut_attributes<F>(&mut self, predicate: F)
pub fn filter_mut_attributes<F>(&mut self, predicate: F)
Filters attributes based on a mutable predicate, keeping only those that return true. The predicate receives a mutable reference to each attribute, allowing modifications.
Sourcepub fn clear_comments(&mut self)
pub fn clear_comments(&mut self)
Clears all comments from the tokens in this node.
Sourcepub fn clear_whitespaces(&mut self)
pub fn clear_whitespaces(&mut self)
Clears all whitespaces information from the tokens in this node.
Trait Implementations§
Source§impl Clone for Attributes
impl Clone for Attributes
Source§fn clone(&self) -> Attributes
fn clone(&self) -> Attributes
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Attributes
impl Debug for Attributes
Source§impl Default for Attributes
impl Default for Attributes
Source§fn default() -> Attributes
fn default() -> Attributes
Source§impl PartialEq for Attributes
impl PartialEq for Attributes
impl Eq for Attributes
impl StructuralPartialEq for Attributes
Auto Trait Implementations§
impl Freeze for Attributes
impl RefUnwindSafe for Attributes
impl Send for Attributes
impl Sync for Attributes
impl Unpin for Attributes
impl UnsafeUnpin for Attributes
impl UnwindSafe for Attributes
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more