MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / option_into_with_c_str

Function option_into_with_c_str

src/path/arg.rs:96–106  ·  view source on GitHub ↗

Runs a closure on `arg` where `A` is mapped to a `&CStr`

(arg: Option<A>, f: F)

Source from the content-addressed store, hash-verified

94
95/// Runs a closure on `arg` where `A` is mapped to a `&CStr`
96pub fn option_into_with_c_str<T, F, A>(arg: Option<A>, f: F) -> io::Result<T>
97where
98 A: Arg + Sized,
99 F: FnOnce(Option<&CStr>) -> io::Result<T>,
100{
101 if let Some(arg) = arg {
102 arg.into_with_c_str(|p| f(Some(p)))
103 } else {
104 f(None)
105 }
106}
107
108impl Arg for &str {
109 #[inline]

Callers 1

mountFunction · 0.85

Calls 2

fFunction · 0.85
into_with_c_strMethod · 0.80

Tested by

no test coverage detected