Document From conversions for OsString and OsStr
This commit is contained in:
parent
50702b2838
commit
acdafa0fb1
1 changed files with 21 additions and 0 deletions
|
@ -348,6 +348,11 @@ impl OsString {
|
|||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl From<String> for OsString {
|
||||
/// Converts a [`String`] into a [`OsString`].
|
||||
/// The conversion copies the data, and includes an allocation on the heap.
|
||||
///
|
||||
/// [`String`]: ../string/struct.String.html
|
||||
/// [`OsString`]: struct.OsString.html
|
||||
fn from(s: String) -> OsString {
|
||||
OsString { inner: Buf::from_string(s) }
|
||||
}
|
||||
|
@ -630,6 +635,10 @@ impl<'a> From<&'a OsStr> for Box<OsStr> {
|
|||
|
||||
#[stable(feature = "os_string_from_box", since = "1.18.0")]
|
||||
impl From<Box<OsStr>> for OsString {
|
||||
/// Converts a `Box<OsStr>` into a `OsString` without copying or allocating.
|
||||
///
|
||||
/// [`Box`]: ../boxed/struct.Box.html
|
||||
/// [`OsString`]: ../ffi/struct.OsString.html
|
||||
fn from(boxed: Box<OsStr>) -> OsString {
|
||||
boxed.into_os_string()
|
||||
}
|
||||
|
@ -637,6 +646,10 @@ impl From<Box<OsStr>> for OsString {
|
|||
|
||||
#[stable(feature = "box_from_os_string", since = "1.20.0")]
|
||||
impl From<OsString> for Box<OsStr> {
|
||||
/// Converts a [`OsString`] into a [`Box`]`<OsStr>` without copying or allocating.
|
||||
///
|
||||
/// [`Box`]: ../boxed/struct.Box.html
|
||||
/// [`OsString`]: ../ffi/struct.OsString.html
|
||||
fn from(s: OsString) -> Box<OsStr> {
|
||||
s.into_boxed_os_str()
|
||||
}
|
||||
|
@ -652,6 +665,10 @@ impl Clone for Box<OsStr> {
|
|||
|
||||
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
|
||||
impl From<OsString> for Arc<OsStr> {
|
||||
/// Converts a [`OsString`] into a [`Arc`]`<OsStr>` without copying or allocating.
|
||||
///
|
||||
/// [`Arc`]: ../sync/struct.Arc.html
|
||||
/// [`OsString`]: ../ffi/struct.OsString.html
|
||||
#[inline]
|
||||
fn from(s: OsString) -> Arc<OsStr> {
|
||||
let arc = s.inner.into_arc();
|
||||
|
@ -670,6 +687,10 @@ impl<'a> From<&'a OsStr> for Arc<OsStr> {
|
|||
|
||||
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
|
||||
impl From<OsString> for Rc<OsStr> {
|
||||
/// Converts a [`OsString`] into a [`Rc`]`<OsStr>` without copying or allocating.
|
||||
///
|
||||
/// [`Rc`]: ../rc/struct.Rc.html
|
||||
/// [`OsString`]: ../ffi/struct.OsString.html
|
||||
#[inline]
|
||||
fn from(s: OsString) -> Rc<OsStr> {
|
||||
let rc = s.inner.into_rc();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue