diff --git a/fish-rust/src/redirection.rs b/fish-rust/src/redirection.rs index 4b2852dfd..bad68f3de 100644 --- a/fish-rust/src/redirection.rs +++ b/fish-rust/src/redirection.rs @@ -40,12 +40,12 @@ fn new_redirection_spec( target: wcharz_t, ) -> Box; - type RedirectionSpecList; - fn new_redirection_spec_list() -> Box; - fn size(self: &RedirectionSpecList) -> usize; - fn at(self: &RedirectionSpecList, offset: usize) -> *const RedirectionSpec; - fn push_back(self: &mut RedirectionSpecList, spec: Box); - fn clone(self: &RedirectionSpecList) -> Box; + type RedirectionSpecListFfi; + fn new_redirection_spec_list() -> Box; + fn size(self: &RedirectionSpecListFfi) -> usize; + fn at(self: &RedirectionSpecListFfi, offset: usize) -> *const RedirectionSpec; + fn push_back(self: &mut RedirectionSpecListFfi, spec: Box); + fn clone(self: &RedirectionSpecListFfi) -> Box; } /// A type that represents the action dup2(src, target). @@ -150,14 +150,15 @@ fn new_redirection_spec(fd: i32, mode: RedirectionMode, target: wcharz_t) -> Box }) } -/// TODO This should be type alias once we drop the FFI. -pub struct RedirectionSpecList(Vec); +pub type RedirectionSpecList = Vec; -fn new_redirection_spec_list() -> Box { - Box::new(RedirectionSpecList(Vec::new())) +struct RedirectionSpecListFfi(RedirectionSpecList); + +fn new_redirection_spec_list() -> Box { + Box::new(RedirectionSpecListFfi(Vec::new())) } -impl RedirectionSpecList { +impl RedirectionSpecListFfi { fn size(&self) -> usize { self.0.len() } @@ -165,11 +166,11 @@ fn at(&self, offset: usize) -> *const RedirectionSpec { &self.0[offset] } #[allow(clippy::boxed_local)] - fn push_back(self: &mut RedirectionSpecList, spec: Box) { + fn push_back(&mut self, spec: Box) { self.0.push(*spec) } - fn clone(self: &RedirectionSpecList) -> Box { - Box::new(RedirectionSpecList(self.0.clone())) + fn clone(&self) -> Box { + Box::new(RedirectionSpecListFfi(self.0.clone())) } } diff --git a/src/redirection.h b/src/redirection.h index 3e4c7d703..c0fabf7c2 100644 --- a/src/redirection.h +++ b/src/redirection.h @@ -19,13 +19,13 @@ enum class RedirectionMode { struct Dup2Action; class Dup2List; struct RedirectionSpec; -struct RedirectionSpecList; +struct RedirectionSpecListFfi; #endif using redirection_mode_t = RedirectionMode; using redirection_spec_t = RedirectionSpec; -using redirection_spec_list_t = RedirectionSpecList; +using redirection_spec_list_t = RedirectionSpecListFfi; using dup2_action_t = Dup2Action; using dup2_list_t = Dup2List;