[go: up one dir, main page]

Struct cargo_config2::Flags

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

A representation of rustflags and 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 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 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_BUILD_RUSTDOCFLAGS

And the following configs:

  • target.<triple>.rustflags
  • target.<cfg>.rustflags
  • build.rustflags
  • build.rustdocflags

See also encode_space_separated.

source

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

Concatenates this rustflags 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 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 with space (’ ’).

This is a valid format for the following environment variables:

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

And the following configs:

  • target.<triple>.rustflags
  • target.<cfg>.rustflags
  • build.rustflags
  • 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.

Trait Implementations§

source§

impl Clone for Flags

source§

fn clone(&self) -> Flags

Returns a copy 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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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 StructuralEq for Flags

source§

impl StructuralPartialEq for Flags

Auto Trait Implementations§

§

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.