Skip to content

Add missing urls for OsStr and OsString #39224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 22, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions src/libstd/ffi/os_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,20 @@ use sys_common::{AsInner, IntoInner, FromInner};
///
/// * In Rust, strings are always valid UTF-8, but may contain zeros.
///
/// `OsString` and `OsStr` bridge this gap by simultaneously representing Rust
/// `OsString` and [`OsStr`] bridge this gap by simultaneously representing Rust
/// and platform-native string values, and in particular allowing a Rust string
/// to be converted into an "OS" string with no cost.
///
/// [`OsStr`]: struct.OsStr.html
#[derive(Clone)]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct OsString {
inner: Buf
}

/// Slices into OS strings (see `OsString`).
/// Slices into OS strings (see [`OsString`]).
///
/// [`OsString`]: struct.OsString.html
#[stable(feature = "rust1", since = "1.0.0")]
pub struct OsStr {
inner: Slice
Expand All @@ -61,7 +65,9 @@ impl OsString {
OsString { inner: Buf::from_string(String::new()) }
}

/// Converts to an `OsStr` slice.
/// Converts to an [`OsStr`] slice.
///
/// [`OsStr`]: struct.OsStr.html
///
/// # Examples
///
Expand All @@ -77,10 +83,12 @@ impl OsString {
self
}

/// Converts the `OsString` into a `String` if it contains valid Unicode data.
/// Converts the `OsString` into a [`String`] if it contains valid Unicode data.
///
/// On failure, ownership of the original `OsString` is returned.
///
/// [`String`]: ../../std/string/struct.String.html
///
/// # Examples
///
/// ```
Expand All @@ -95,7 +103,9 @@ impl OsString {
self.inner.into_string().map_err(|buf| OsString { inner: buf} )
}

/// Extends the string with the given `&OsStr` slice.
/// Extends the string with the given [`&OsStr`] slice.
///
/// [`&OsStr`]: struct.OsStr.html
///
/// # Examples
///
Expand Down Expand Up @@ -329,10 +339,12 @@ impl OsStr {
unsafe { mem::transmute(inner) }
}

/// Yields a `&str` slice if the `OsStr` is valid Unicode.
/// Yields a [`&str`] slice if the `OsStr` is valid Unicode.
///
/// This conversion may entail doing a check for UTF-8 validity.
///
/// [`&str`]: ../../std/primitive.str.html
///
/// # Examples
///
/// ```
Expand All @@ -346,10 +358,13 @@ impl OsStr {
self.inner.to_str()
}

/// Converts an `OsStr` to a `Cow<str>`.
/// Converts an `OsStr` to a [`Cow`]`<`[`str`]`>`.
///
/// Any non-Unicode sequences are replaced with U+FFFD REPLACEMENT CHARACTER.
///
/// [`Cow`]: ../../std/borrow/enum.Cow.html
/// [`str`]: ../../std/primitive.str.html
///
/// # Examples
///
/// Calling `to_string_lossy` on an `OsStr` with valid unicode:
Expand All @@ -368,7 +383,9 @@ impl OsStr {
self.inner.to_string_lossy()
}

/// Copies the slice into an owned `OsString`.
/// Copies the slice into an owned [`OsString`].
///
/// [`OsString`]: struct.OsString.html
#[stable(feature = "rust1", since = "1.0.0")]
pub fn to_os_string(&self) -> OsString {
OsString { inner: self.inner.to_owned() }
Expand Down Expand Up @@ -397,10 +414,12 @@ impl OsStr {
/// Note that this does **not** return the number of bytes in this string
/// as, for example, OS strings on Windows are encoded as a list of `u16`
/// rather than a list of bytes. This number is simply useful for passing to
/// other methods like `OsString::with_capacity` to avoid reallocations.
/// other methods like [`OsString::with_capacity`] to avoid reallocations.
///
/// See `OsStr` introduction for more information about encoding.
///
/// [`OsString::with_capacity`]: struct.OsString.html#method.with_capacity
///
/// # Examples
///
/// ```
Expand Down