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
This commit is contained in:
Tobin C. Harding 2025-01-04 15:39:50 +11:00
parent b7fdb359e7
commit 88dfd4e8f2
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 10 additions and 0 deletions

View File

@ -33,10 +33,20 @@ impl<T> FromStd<T> {
/// 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 }
}