Skip to content

A bunch of minor documentation tweaks and fixes. #63808

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 8 commits into from
Aug 23, 2019
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/liballoc/collections/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1810,7 +1810,7 @@ impl<T> VecDeque<T> {
other
}

/// Moves all the elements of `other` into `Self`, leaving `other` empty.
/// Moves all the elements of `other` into `self`, leaving `other` empty.
///
/// # Panics
///
Expand Down Expand Up @@ -1847,7 +1847,7 @@ impl<T> VecDeque<T> {
///
/// let mut buf = VecDeque::new();
/// buf.extend(1..5);
/// buf.retain(|&x| x%2 == 0);
/// buf.retain(|&x| x % 2 == 0);
/// assert_eq!(buf, [2, 4]);
/// ```
///
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ impl f32 {
/// use std::f32;
///
/// let x = 2.0_f32;
/// let abs_difference = (x.recip() - (1.0/x)).abs();
/// let abs_difference = (x.recip() - (1.0 / x)).abs();
///
/// assert!(abs_difference <= f32::EPSILON);
/// ```
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ impl f64 {
///
/// ```
/// let x = 2.0_f64;
/// let abs_difference = (x.recip() - (1.0/x)).abs();
/// let abs_difference = (x.recip() - (1.0 / x)).abs();
///
/// assert!(abs_difference < 1e-10);
/// ```
Expand Down
33 changes: 16 additions & 17 deletions src/libstd/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl f32 {
/// let b = 60.0_f32;
///
/// // 100.0
/// let abs_difference = (m.mul_add(x, b) - (m*x + b)).abs();
/// let abs_difference = (m.mul_add(x, b) - ((m * x) + b)).abs();
///
/// assert!(abs_difference <= f32::EPSILON);
/// ```
Expand Down Expand Up @@ -318,7 +318,7 @@ impl f32 {
/// use std::f32;
///
/// let x = 2.0_f32;
/// let abs_difference = (x.powi(2) - x*x).abs();
/// let abs_difference = (x.powi(2) - (x * x)).abs();
///
/// assert!(abs_difference <= f32::EPSILON);
/// ```
Expand All @@ -336,7 +336,7 @@ impl f32 {
/// use std::f32;
///
/// let x = 2.0_f32;
/// let abs_difference = (x.powf(2.0) - x*x).abs();
/// let abs_difference = (x.powf(2.0) - (x * x)).abs();
///
/// assert!(abs_difference <= f32::EPSILON);
/// ```
Expand Down Expand Up @@ -600,7 +600,7 @@ impl f32 {
/// ```
/// use std::f32;
///
/// let x = f32::consts::PI/2.0;
/// let x = f32::consts::FRAC_PI_2;
///
/// let abs_difference = (x.sin() - 1.0).abs();
///
Expand All @@ -623,7 +623,7 @@ impl f32 {
/// ```
/// use std::f32;
///
/// let x = 2.0*f32::consts::PI;
/// let x = 2.0 * f32::consts::PI;
///
/// let abs_difference = (x.cos() - 1.0).abs();
///
Expand All @@ -646,7 +646,7 @@ impl f32 {
/// ```
/// use std::f32;
///
/// let x = f32::consts::PI / 4.0;
/// let x = f32::consts::FRAC_PI_4;
/// let abs_difference = (x.tan() - 1.0).abs();
///
/// assert!(abs_difference <= f32::EPSILON);
Expand All @@ -666,10 +666,10 @@ impl f32 {
/// ```
/// use std::f32;
///
/// let f = f32::consts::PI / 2.0;
/// let f = f32::consts::FRAC_PI_2;
///
/// // asin(sin(pi/2))
/// let abs_difference = (f.sin().asin() - f32::consts::PI / 2.0).abs();
/// let abs_difference = (f.sin().asin() - f32::consts::FRAC_PI_2).abs();
///
/// assert!(abs_difference <= f32::EPSILON);
/// ```
Expand All @@ -688,10 +688,10 @@ impl f32 {
/// ```
/// use std::f32;
///
/// let f = f32::consts::PI / 4.0;
/// let f = f32::consts::FRAC_PI_4;
///
/// // acos(cos(pi/4))
/// let abs_difference = (f.cos().acos() - f32::consts::PI / 4.0).abs();
/// let abs_difference = (f.cos().acos() - f32::consts::FRAC_PI_4).abs();
///
/// assert!(abs_difference <= f32::EPSILON);
/// ```
Expand Down Expand Up @@ -734,7 +734,6 @@ impl f32 {
/// ```
/// use std::f32;
///
/// let pi = f32::consts::PI;
/// // Positive angles measured counter-clockwise
/// // from positive x axis
/// // -pi/4 radians (45 deg clockwise)
Expand All @@ -745,8 +744,8 @@ impl f32 {
/// let x2 = -3.0f32;
/// let y2 = 3.0f32;
///
/// let abs_difference_1 = (y1.atan2(x1) - (-pi/4.0)).abs();
/// let abs_difference_2 = (y2.atan2(x2) - 3.0*pi/4.0).abs();
/// let abs_difference_1 = (y1.atan2(x1) - (-f32::consts::FRAC_PI_4)).abs();
/// let abs_difference_2 = (y2.atan2(x2) - (3.0 * f32::consts::FRAC_PI_4)).abs();
///
/// assert!(abs_difference_1 <= f32::EPSILON);
/// assert!(abs_difference_2 <= f32::EPSILON);
Expand All @@ -765,7 +764,7 @@ impl f32 {
/// ```
/// use std::f32;
///
/// let x = f32::consts::PI/4.0;
/// let x = f32::consts::FRAC_PI_4;
/// let f = x.sin_cos();
///
/// let abs_difference_0 = (f.0 - x.sin()).abs();
Expand Down Expand Up @@ -834,7 +833,7 @@ impl f32 {
///
/// let f = x.sinh();
/// // Solving sinh() at 1 gives `(e^2-1)/(2e)`
/// let g = (e*e - 1.0)/(2.0*e);
/// let g = ((e * e) - 1.0) / (2.0 * e);
/// let abs_difference = (f - g).abs();
///
/// assert!(abs_difference <= f32::EPSILON);
Expand All @@ -856,7 +855,7 @@ impl f32 {
/// let x = 1.0f32;
/// let f = x.cosh();
/// // Solving cosh() at 1 gives this result
/// let g = (e*e + 1.0)/(2.0*e);
/// let g = ((e * e) + 1.0) / (2.0 * e);
/// let abs_difference = (f - g).abs();
///
/// // Same result
Expand All @@ -880,7 +879,7 @@ impl f32 {
///
/// let f = x.tanh();
/// // Solving tanh() at 1 gives `(1 - e^(-2))/(1 + e^(-2))`
/// let g = (1.0 - e.powi(-2))/(1.0 + e.powi(-2));
/// let g = (1.0 - e.powi(-2)) / (1.0 + e.powi(-2));
/// let abs_difference = (f - g).abs();
///
/// assert!(abs_difference <= f32::EPSILON);
Expand Down
33 changes: 16 additions & 17 deletions src/libstd/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ impl f64 {
/// let b = 60.0_f64;
///
/// // 100.0
/// let abs_difference = (m.mul_add(x, b) - (m*x + b)).abs();
/// let abs_difference = (m.mul_add(x, b) - ((m * x) + b)).abs();
///
/// assert!(abs_difference < 1e-10);
/// ```
Expand Down Expand Up @@ -291,7 +291,7 @@ impl f64 {
///
/// ```
/// let x = 2.0_f64;
/// let abs_difference = (x.powi(2) - x*x).abs();
/// let abs_difference = (x.powi(2) - (x * x)).abs();
///
/// assert!(abs_difference < 1e-10);
/// ```
Expand All @@ -307,7 +307,7 @@ impl f64 {
///
/// ```
/// let x = 2.0_f64;
/// let abs_difference = (x.powf(2.0) - x*x).abs();
/// let abs_difference = (x.powf(2.0) - (x * x)).abs();
///
/// assert!(abs_difference < 1e-10);
/// ```
Expand Down Expand Up @@ -537,7 +537,7 @@ impl f64 {
/// ```
/// use std::f64;
///
/// let x = f64::consts::PI/2.0;
/// let x = f64::consts::FRAC_PI_2;
///
/// let abs_difference = (x.sin() - 1.0).abs();
///
Expand All @@ -556,7 +556,7 @@ impl f64 {
/// ```
/// use std::f64;
///
/// let x = 2.0*f64::consts::PI;
/// let x = 2.0 * f64::consts::PI;
///
/// let abs_difference = (x.cos() - 1.0).abs();
///
Expand All @@ -575,7 +575,7 @@ impl f64 {
/// ```
/// use std::f64;
///
/// let x = f64::consts::PI/4.0;
/// let x = f64::consts::FRAC_PI_4;
/// let abs_difference = (x.tan() - 1.0).abs();
///
/// assert!(abs_difference < 1e-14);
Expand All @@ -595,10 +595,10 @@ impl f64 {
/// ```
/// use std::f64;
///
/// let f = f64::consts::PI / 2.0;
/// let f = f64::consts::FRAC_PI_2;
///
/// // asin(sin(pi/2))
/// let abs_difference = (f.sin().asin() - f64::consts::PI / 2.0).abs();
/// let abs_difference = (f.sin().asin() - f64::consts::FRAC_PI_2).abs();
///
/// assert!(abs_difference < 1e-10);
/// ```
Expand All @@ -617,10 +617,10 @@ impl f64 {
/// ```
/// use std::f64;
///
/// let f = f64::consts::PI / 4.0;
/// let f = f64::consts::FRAC_PI_4;
///
/// // acos(cos(pi/4))
/// let abs_difference = (f.cos().acos() - f64::consts::PI / 4.0).abs();
/// let abs_difference = (f.cos().acos() - f64::consts::FRAC_PI_4).abs();
///
/// assert!(abs_difference < 1e-10);
/// ```
Expand Down Expand Up @@ -661,7 +661,6 @@ impl f64 {
/// ```
/// use std::f64;
///
/// let pi = f64::consts::PI;
/// // Positive angles measured counter-clockwise
/// // from positive x axis
/// // -pi/4 radians (45 deg clockwise)
Expand All @@ -672,8 +671,8 @@ impl f64 {
/// let x2 = -3.0_f64;
/// let y2 = 3.0_f64;
///
/// let abs_difference_1 = (y1.atan2(x1) - (-pi/4.0)).abs();
/// let abs_difference_2 = (y2.atan2(x2) - 3.0*pi/4.0).abs();
/// let abs_difference_1 = (y1.atan2(x1) - (-f64::consts::FRAC_PI_4)).abs();
/// let abs_difference_2 = (y2.atan2(x2) - (3.0 * f64::consts::FRAC_PI_4)).abs();
///
/// assert!(abs_difference_1 < 1e-10);
/// assert!(abs_difference_2 < 1e-10);
Expand All @@ -692,7 +691,7 @@ impl f64 {
/// ```
/// use std::f64;
///
/// let x = f64::consts::PI/4.0;
/// let x = f64::consts::FRAC_PI_4;
/// let f = x.sin_cos();
///
/// let abs_difference_0 = (f.0 - x.sin()).abs();
Expand Down Expand Up @@ -759,7 +758,7 @@ impl f64 {
///
/// let f = x.sinh();
/// // Solving sinh() at 1 gives `(e^2-1)/(2e)`
/// let g = (e*e - 1.0)/(2.0*e);
/// let g = ((e * e) - 1.0) / (2.0 * e);
/// let abs_difference = (f - g).abs();
///
/// assert!(abs_difference < 1e-10);
Expand All @@ -781,7 +780,7 @@ impl f64 {
/// let x = 1.0_f64;
/// let f = x.cosh();
/// // Solving cosh() at 1 gives this result
/// let g = (e*e + 1.0)/(2.0*e);
/// let g = ((e * e) + 1.0) / (2.0 * e);
/// let abs_difference = (f - g).abs();
///
/// // Same result
Expand All @@ -805,7 +804,7 @@ impl f64 {
///
/// let f = x.tanh();
/// // Solving tanh() at 1 gives `(1 - e^(-2))/(1 + e^(-2))`
/// let g = (1.0 - e.powi(-2))/(1.0 + e.powi(-2));
/// let g = (1.0 - e.powi(-2)) / (1.0 + e.powi(-2));
/// let abs_difference = (f - g).abs();
///
/// assert!(abs_difference < 1.0e-10);
Expand Down
32 changes: 16 additions & 16 deletions src/libstd/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,8 @@ impl CString {
/// use std::ffi::{CString, CStr};
///
/// let c_string = CString::new(b"foo".to_vec()).expect("CString::new failed");
/// let c_str = c_string.as_c_str();
/// assert_eq!(c_str,
/// let cstr = c_string.as_c_str();
/// assert_eq!(cstr,
/// CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed"));
/// ```
#[inline]
Expand Down Expand Up @@ -994,17 +994,17 @@ impl CStr {
/// ```
/// use std::ffi::CStr;
///
/// let c_str = CStr::from_bytes_with_nul(b"hello");
/// assert!(c_str.is_err());
/// let cstr = CStr::from_bytes_with_nul(b"hello");
/// assert!(cstr.is_err());
/// ```
///
/// Creating a `CStr` with an interior nul byte is an error:
///
/// ```
/// use std::ffi::CStr;
///
/// let c_str = CStr::from_bytes_with_nul(b"he\0llo\0");
/// assert!(c_str.is_err());
/// let cstr = CStr::from_bytes_with_nul(b"he\0llo\0");
/// assert!(cstr.is_err());
/// ```
#[stable(feature = "cstr_from_bytes", since = "1.10.0")]
pub fn from_bytes_with_nul(bytes: &[u8])
Expand Down Expand Up @@ -1111,8 +1111,8 @@ impl CStr {
/// ```
/// use std::ffi::CStr;
///
/// let c_str = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
/// assert_eq!(c_str.to_bytes(), b"foo");
/// let cstr = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
/// assert_eq!(cstr.to_bytes(), b"foo");
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
Expand All @@ -1137,8 +1137,8 @@ impl CStr {
/// ```
/// use std::ffi::CStr;
///
/// let c_str = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
/// assert_eq!(c_str.to_bytes_with_nul(), b"foo\0");
/// let cstr = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
/// assert_eq!(cstr.to_bytes_with_nul(), b"foo\0");
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
Expand All @@ -1164,8 +1164,8 @@ impl CStr {
/// ```
/// use std::ffi::CStr;
///
/// let c_str = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
/// assert_eq!(c_str.to_str(), Ok("foo"));
/// let cstr = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
/// assert_eq!(cstr.to_str(), Ok("foo"));
/// ```
#[stable(feature = "cstr_to_str", since = "1.4.0")]
pub fn to_str(&self) -> Result<&str, str::Utf8Error> {
Expand Down Expand Up @@ -1205,9 +1205,9 @@ impl CStr {
/// use std::borrow::Cow;
/// use std::ffi::CStr;
///
/// let c_str = CStr::from_bytes_with_nul(b"Hello World\0")
/// let cstr = CStr::from_bytes_with_nul(b"Hello World\0")
/// .expect("CStr::from_bytes_with_nul failed");
/// assert_eq!(c_str.to_string_lossy(), Cow::Borrowed("Hello World"));
/// assert_eq!(cstr.to_string_lossy(), Cow::Borrowed("Hello World"));
/// ```
///
/// Calling `to_string_lossy` on a `CStr` containing invalid UTF-8:
Expand All @@ -1216,10 +1216,10 @@ impl CStr {
/// use std::borrow::Cow;
/// use std::ffi::CStr;
///
/// let c_str = CStr::from_bytes_with_nul(b"Hello \xF0\x90\x80World\0")
/// let cstr = CStr::from_bytes_with_nul(b"Hello \xF0\x90\x80World\0")
/// .expect("CStr::from_bytes_with_nul failed");
/// assert_eq!(
/// c_str.to_string_lossy(),
/// cstr.to_string_lossy(),
/// Cow::Owned(String::from("Hello �World")) as Cow<'_, str>
/// );
/// ```
Expand Down
Loading