[go: up one dir, main page]

Flags

Struct Flags 

Source
#[non_exhaustive]
pub struct Flags { pub flags: Vec<String>, }
Expand description

A representation of rustflags or rustdocflags.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§flags: Vec<String>

Implementations§

Source§

impl Flags

Source

pub fn from_encoded(s: &str) -> Self

Creates a rustflags or rustdocflags from a string separated with ASCII unit separator (‘\x1f’).

This is a valid format for the following environment variables:

  • CARGO_ENCODED_RUSTFLAGS (Cargo 1.55+)
  • CARGO_ENCODED_RUSTDOCFLAGS (Cargo 1.55+)

See also encode.

Source

pub fn from_space_separated(s: &str) -> Self

Creates a rustflags or rustdocflags from a string separated with space (’ ’).

This is a valid format for the following environment variables:

  • RUSTFLAGS
  • CARGO_TARGET_<triple>_RUSTFLAGS
  • CARGO_BUILD_RUSTFLAGS
  • RUSTDOCFLAGS
  • CARGO_TARGET_<triple>_RUSTDOCFLAGS
  • CARGO_BUILD_RUSTDOCFLAGS

And the following configs:

  • target.<triple>.rustflags
  • target.<cfg>.rustflags
  • build.rustflags
  • target.<triple>.rustdocflags (Cargo 1.78+)
  • build.rustdocflags

See also encode_space_separated.

Source

pub fn encode(&self) -> Result<String, Error>

Concatenates this rustflags or rustdocflags with ASCII unit separator (‘\x1f’).

This is a valid format for the following environment variables:

  • CARGO_ENCODED_RUSTFLAGS (Cargo 1.55+)
  • CARGO_ENCODED_RUSTDOCFLAGS (Cargo 1.55+)
§Errors

This returns an error if any of flag contains ASCII unit separator (‘\x1f’).

This is because even if you do not intend it to be interpreted as a separator, Cargo will interpret it as a separator.

Since it is not easy to insert an ASCII unit separator in a toml file or Shell environment variable, this usually occurs when this rustflags or rustdocflags is created in the wrong way (from_encoded vs from_space_separated) or when a flag containing a separator is written in the rust code (push, into, from, etc.).

Source

pub fn encode_space_separated(&self) -> Result<String, Error>

Concatenates this rustflags or rustdocflags with space (’ ’).

This is a valid format for the following environment variables:

  • RUSTFLAGS
  • CARGO_TARGET_<triple>_RUSTFLAGS
  • CARGO_BUILD_RUSTFLAGS
  • RUSTDOCFLAGS
  • CARGO_TARGET_<triple>_RUSTDOCFLAGS
  • CARGO_BUILD_RUSTDOCFLAGS

And the following configs:

  • target.<triple>.rustflags
  • target.<cfg>.rustflags
  • build.rustflags
  • target.<triple>.rustdocflags (Cargo 1.78+)
  • build.rustdocflags
§Errors

This returns an error if any of flag contains space (’ ’).

This is because even if you do not intend it to be interpreted as a separator, Cargo will interpret it as a separator.

If you run into this error, consider using a more robust CARGO_ENCODED_* flags.

Source

pub fn push<S: Into<String>>(&mut self, flag: S)

Appends a flag to the back of this rustflags or rustdocflags.

Trait Implementations§

Source§

impl Clone for Flags

Source§

fn clone(&self) -> Flags

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Flags

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Flags

Source§

fn default() -> Flags

Returns the “default value” for a type. Read more
Source§

impl From<&[&str]> for Flags

Source§

fn from(value: &[&str]) -> Self

Converts to this type from the input type.
Source§

impl From<&[String]> for Flags

Source§

fn from(value: &[String]) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<[&str; N]> for Flags

Source§

fn from(value: [&str; N]) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<[String; N]> for Flags

Source§

fn from(value: [String; N]) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<String>> for Flags

Source§

fn from(value: Vec<String>) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Flags

Source§

fn eq(&self, other: &Flags) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Flags

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Flags

Source§

impl StructuralPartialEq for Flags

Auto Trait Implementations§

§

impl Freeze for Flags

§

impl RefUnwindSafe for Flags

§

impl Send for Flags

§

impl Sync for Flags

§

impl Unpin for Flags

§

impl UnwindSafe for Flags

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.