pub struct WithAttributes<Attr, Value> {
pub attr: Attr,
pub separator: &'static str,
pub value: Value,
}Expand description
Adds attributes to ANY item.
The first tuple value must be a sequence. The second must be a writable value. This struct is typically constructed via CanHaveAttributes::with_attributes.
Rust attributes can be put in many places, so this enables you to add attributes to any writable item. For example, adding attributes to function parameters can be done like so:
let function_param = FunctionParam(Str("conditional_param"), Str("Fd")).with_attributes(
SingularSeq(Cfg(Target::Os(Str("linux"))))
);
let string = InMemoryOutput::print_output(EmptyContext, &function_param);
assert_eq!("#[cfg(target_os = \"linux\")] conditional_param: Fd", string);Fields§
§attr: Attr§separator: &'static strThe separator. Usually a space or a new line, depending on what the target value is
value: ValueThe value
Trait Implementations§
Source§impl<Attr: Clone, Value: Clone> Clone for WithAttributes<Attr, Value>
impl<Attr: Clone, Value: Clone> Clone for WithAttributes<Attr, Value>
Source§fn clone(&self) -> WithAttributes<Attr, Value>
fn clone(&self) -> WithAttributes<Attr, Value>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<Attr, Value> Freeze for WithAttributes<Attr, Value>
impl<Attr, Value> RefUnwindSafe for WithAttributes<Attr, Value>where
Attr: RefUnwindSafe,
Value: RefUnwindSafe,
impl<Attr, Value> Send for WithAttributes<Attr, Value>
impl<Attr, Value> Sync for WithAttributes<Attr, Value>
impl<Attr, Value> Unpin for WithAttributes<Attr, Value>
impl<Attr, Value> UnwindSafe for WithAttributes<Attr, Value>where
Attr: UnwindSafe,
Value: UnwindSafe,
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