pub struct RustFlags { /* private fields */ }Available on crate feature
os_cmd only.Expand description
Represents various flags used for configuring Rust compilation.
-
crt_staticSome(true)=>["-C", "target-feature=+crt-static"]Some(false)=>["-C", "target-feature=-crt-static"]None=>[]
-
prefer_dynamic
Some(true)=>["-C", "prefer-dynamic=true"]Some(false)=>["-C", "prefer-dynamic=false"]None=>[]
-
linker: The linker to be used.- “” =>
[] - lld =>
["-C", "linker=lld"]
- “” =>
-
relocation_model: static, pic, pie, etc. -
code_model: “tiny”, “small”, “kernel”, “medium”, “large” -
codegen_units:- Some(u) =>
["-C", "codegen-units={u}"] - None =>
[]
- Some(u) =>
-
native_target_cpu:- Some(true) =>
["-C", "target-cpu=native"] - Some(false) =>
["-C", "target-cpu=generic"] - None =>
[]
- Some(true) =>
-
other_flags: Additional flags for the Rust compiler.
See also: The rustc book
Implementations§
Source§impl RustFlags
impl RustFlags
pub fn with_crt_static(self, val: Option<bool>) -> Self
pub fn with_prefer_dynamic(self, val: Option<bool>) -> Self
pub fn with_linker(self, val: MiniStr) -> Self
pub fn with_linker_flavor(self, val: LinkerFlavor) -> Self
pub fn with_link_self_contained(self, val: Option<bool>) -> Self
pub fn with_relocation_model(self, val: RelocationModel) -> Self
pub fn with_code_model(self, val: CodeModel) -> Self
pub fn with_codegen_units(self, val: Option<usize>) -> Self
pub fn with_native_target_cpu(self, val: Option<bool>) -> Self
pub fn with_other_flags(self, val: Box<[MiniStr]>) -> Self
Source§impl RustFlags
impl RustFlags
pub fn get_crt_static(&self) -> &Option<bool>
pub fn get_prefer_dynamic(&self) -> &Option<bool>
pub fn get_linker(&self) -> &MiniStr
pub fn get_linker_flavor(&self) -> &LinkerFlavor
pub fn get_link_self_contained(&self) -> &Option<bool>
pub fn get_relocation_model(&self) -> &RelocationModel
pub fn get_code_model(&self) -> &CodeModel
pub fn get_codegen_units(&self) -> &Option<usize>
pub fn get_native_target_cpu(&self) -> &Option<bool>
pub fn get_other_flags(&self) -> &Box<[MiniStr]>
Source§impl RustFlags
impl RustFlags
Sourcepub fn into_vec(self) -> Vec<MiniStr>
pub fn into_vec(self) -> Vec<MiniStr>
Collects flags into a Vec
§Example
use tap::Pipe;
use testutils::os_cmd::{
collect_boxed_ministr_slice,
presets::cargo_build::flags::{LinkerFlavor, RustFlags},
};
let flags = RustFlags::default()
.with_crt_static(false.into())
.with_prefer_dynamic(true.into())
.with_linker_flavor(LinkerFlavor::GNUbinutilsLLVMLLD)
.with_other_flags(
[
"-C",
"link-arg=-ffunction-sections",
"-C",
"link-arg=-fdata-sections",
]
.pipe(collect_boxed_ministr_slice),
)
.into_vec();
assert_eq!(
flags,
[
"-C",
"target-feature=-crt-static",
"-C",
"prefer-dynamic=true",
"-C",
"linker-flavor=ld.lld",
"-C",
"link-arg=-ffunction-sections",
"-C",
"link-arg=-fdata-sections",
]
);Trait Implementations§
Auto Trait Implementations§
impl Freeze for RustFlags
impl RefUnwindSafe for RustFlags
impl Send for RustFlags
impl Sync for RustFlags
impl Unpin for RustFlags
impl UnsafeUnpin for RustFlags
impl UnwindSafe for RustFlags
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref() only in debug builds, and is erased in release
builds.