mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Update env_var_to_ffi() to take an Option<EnvVar>
It wasn't possible to handle cases where vars.get() returned `None` then forward that to C++, but now we can.
This commit is contained in:
parent
32912b6525
commit
cce78eeb43
2 changed files with 7 additions and 3 deletions
8
fish-rust/src/env/environment.rs
vendored
8
fish-rust/src/env/environment.rs
vendored
|
@ -34,8 +34,12 @@ lazy_static! {
|
|||
static UVARS_LOCALLY_MODIFIED: RelaxedAtomicBool = RelaxedAtomicBool::new(false);
|
||||
|
||||
/// Convert an EnvVar to an FFI env_var_t.
|
||||
fn env_var_to_ffi(var: EnvVar) -> cxx::UniquePtr<ffi::env_var_t> {
|
||||
ffi::env_var_t::new_ffi(Box::into_raw(Box::from(var)).cast()).within_unique_ptr()
|
||||
pub fn env_var_to_ffi(var: Option<EnvVar>) -> cxx::UniquePtr<ffi::env_var_t> {
|
||||
if let Some(var) = var {
|
||||
ffi::env_var_t::new_ffi(Box::into_raw(Box::from(var)).cast()).within_unique_ptr()
|
||||
} else {
|
||||
cxx::UniquePtr::null()
|
||||
}
|
||||
}
|
||||
|
||||
/// An environment is read-only access to variable values.
|
||||
|
|
|
@ -150,7 +150,7 @@ pub trait FloggableDisplay {
|
|||
|
||||
impl<T: std::fmt::Display> FloggableDisplay for T {
|
||||
fn to_flog_str(&self) -> String {
|
||||
format!("{}", self)
|
||||
self.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue