From 88dfd4e8f2b12f5e50caab16481c4e0a8935c9f7 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Sat, 4 Jan 2025 15:39:50 +1100 Subject: [PATCH] io: Use get_ref / get_mut API Currently in the `bridge` module to get a reference and mutable reference we provide the `as_inner` and `inner_mut` functions. These names are not in line with the `std::io` module which favours `get_ref` and `get_mut`. Add inherent functions `get_ref` and `get_mut` for accessing the wrapped value in `bridge::ToStd` and deprecate `as_inner` and `inner_mut`. To convince yourself this API is correct grep the stdlib `io` module for `fn get_ref` as opposed to `fn as_ref`. Close: #3832 --- io/src/bridge.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/io/src/bridge.rs b/io/src/bridge.rs index 182f770c9..a979f7387 100644 --- a/io/src/bridge.rs +++ b/io/src/bridge.rs @@ -33,10 +33,20 @@ impl FromStd { /// Returns a reference to the wrapped value. #[inline] + pub fn get_ref(&self) -> &T { &self.0 } + + /// Returns a mutable reference to the wrapped value. + #[inline] + pub fn get_mut(&mut self) -> &mut T { &mut self.0 } + + /// Returns a reference to the wrapped value. + #[inline] + #[deprecated(since = "TBD", note = "use `get_ref()` instead")] pub fn inner(&self) -> &T { &self.0 } /// Returns a mutable reference to the wrapped value. #[inline] + #[deprecated(since = "TBD", note = "use `get_ref()` instead")] pub fn inner_mut(&mut self) -> &mut T { &mut self.0 } }