WithAttributes

Struct WithAttributes 

Source
pub struct WithAttributes<Attr, Value>(pub Attr, pub Value);
Expand description

Adds attributes to ANY item.

The first tuple value must be a sequence. The second must be a writable value.

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 = WithAttributes(
  SingularSeq(Cfg(Target::Os("linux"))),
  FunctionParam(Str("conditional_param"), Str("Fd"))
);

Will render as:

#[cfg(target_os = "linux")] conditional_param: Fd

Tuple Fields§

§0: Attr§1: Value

Trait Implementations§

Source§

impl<O, Attr, Value> Writable<O> for WithAttributes<Attr, Value>
where O: Output, Attr: WritableSeq<O>, Value: Writable<O>,

Source§

async fn write_to(&self, output: &mut O) -> Result<(), O::Error>

Writes to the output. Returns the output’s error upon failure. Read more

Auto Trait Implementations§

§

impl<Attr, Value> Freeze for WithAttributes<Attr, Value>
where Attr: Freeze, Value: Freeze,

§

impl<Attr, Value> RefUnwindSafe for WithAttributes<Attr, Value>
where Attr: RefUnwindSafe, Value: RefUnwindSafe,

§

impl<Attr, Value> Send for WithAttributes<Attr, Value>
where Attr: Send, Value: Send,

§

impl<Attr, Value> Sync for WithAttributes<Attr, Value>
where Attr: Sync, Value: Sync,

§

impl<Attr, Value> Unpin for WithAttributes<Attr, Value>
where Attr: Unpin, Value: Unpin,

§

impl<Attr, Value> UnwindSafe for WithAttributes<Attr, Value>
where Attr: UnwindSafe, Value: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.