Skip to content

Commit 0507d49

Browse files
committed
Auto merge of #63808 - Rosto75:master, r=KodrAus
A bunch of minor documentation tweaks and fixes.
2 parents a71e32e + d9f3258 commit 0507d49

File tree

7 files changed

+54
-56
lines changed

7 files changed

+54
-56
lines changed

src/liballoc/collections/vec_deque.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1810,7 +1810,7 @@ impl<T> VecDeque<T> {
18101810
other
18111811
}
18121812

1813-
/// Moves all the elements of `other` into `Self`, leaving `other` empty.
1813+
/// Moves all the elements of `other` into `self`, leaving `other` empty.
18141814
///
18151815
/// # Panics
18161816
///
@@ -1847,7 +1847,7 @@ impl<T> VecDeque<T> {
18471847
///
18481848
/// let mut buf = VecDeque::new();
18491849
/// buf.extend(1..5);
1850-
/// buf.retain(|&x| x%2 == 0);
1850+
/// buf.retain(|&x| x % 2 == 0);
18511851
/// assert_eq!(buf, [2, 4]);
18521852
/// ```
18531853
///

src/libcore/num/f32.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ impl f32 {
315315
/// use std::f32;
316316
///
317317
/// let x = 2.0_f32;
318-
/// let abs_difference = (x.recip() - (1.0/x)).abs();
318+
/// let abs_difference = (x.recip() - (1.0 / x)).abs();
319319
///
320320
/// assert!(abs_difference <= f32::EPSILON);
321321
/// ```

src/libcore/num/f64.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ impl f64 {
327327
///
328328
/// ```
329329
/// let x = 2.0_f64;
330-
/// let abs_difference = (x.recip() - (1.0/x)).abs();
330+
/// let abs_difference = (x.recip() - (1.0 / x)).abs();
331331
///
332332
/// assert!(abs_difference < 1e-10);
333333
/// ```

src/libstd/f32.rs

+16-17
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ impl f32 {
236236
/// let b = 60.0_f32;
237237
///
238238
/// // 100.0
239-
/// let abs_difference = (m.mul_add(x, b) - (m*x + b)).abs();
239+
/// let abs_difference = (m.mul_add(x, b) - ((m * x) + b)).abs();
240240
///
241241
/// assert!(abs_difference <= f32::EPSILON);
242242
/// ```
@@ -318,7 +318,7 @@ impl f32 {
318318
/// use std::f32;
319319
///
320320
/// let x = 2.0_f32;
321-
/// let abs_difference = (x.powi(2) - x*x).abs();
321+
/// let abs_difference = (x.powi(2) - (x * x)).abs();
322322
///
323323
/// assert!(abs_difference <= f32::EPSILON);
324324
/// ```
@@ -336,7 +336,7 @@ impl f32 {
336336
/// use std::f32;
337337
///
338338
/// let x = 2.0_f32;
339-
/// let abs_difference = (x.powf(2.0) - x*x).abs();
339+
/// let abs_difference = (x.powf(2.0) - (x * x)).abs();
340340
///
341341
/// assert!(abs_difference <= f32::EPSILON);
342342
/// ```
@@ -600,7 +600,7 @@ impl f32 {
600600
/// ```
601601
/// use std::f32;
602602
///
603-
/// let x = f32::consts::PI/2.0;
603+
/// let x = f32::consts::FRAC_PI_2;
604604
///
605605
/// let abs_difference = (x.sin() - 1.0).abs();
606606
///
@@ -623,7 +623,7 @@ impl f32 {
623623
/// ```
624624
/// use std::f32;
625625
///
626-
/// let x = 2.0*f32::consts::PI;
626+
/// let x = 2.0 * f32::consts::PI;
627627
///
628628
/// let abs_difference = (x.cos() - 1.0).abs();
629629
///
@@ -646,7 +646,7 @@ impl f32 {
646646
/// ```
647647
/// use std::f32;
648648
///
649-
/// let x = f32::consts::PI / 4.0;
649+
/// let x = f32::consts::FRAC_PI_4;
650650
/// let abs_difference = (x.tan() - 1.0).abs();
651651
///
652652
/// assert!(abs_difference <= f32::EPSILON);
@@ -666,10 +666,10 @@ impl f32 {
666666
/// ```
667667
/// use std::f32;
668668
///
669-
/// let f = f32::consts::PI / 2.0;
669+
/// let f = f32::consts::FRAC_PI_2;
670670
///
671671
/// // asin(sin(pi/2))
672-
/// let abs_difference = (f.sin().asin() - f32::consts::PI / 2.0).abs();
672+
/// let abs_difference = (f.sin().asin() - f32::consts::FRAC_PI_2).abs();
673673
///
674674
/// assert!(abs_difference <= f32::EPSILON);
675675
/// ```
@@ -688,10 +688,10 @@ impl f32 {
688688
/// ```
689689
/// use std::f32;
690690
///
691-
/// let f = f32::consts::PI / 4.0;
691+
/// let f = f32::consts::FRAC_PI_4;
692692
///
693693
/// // acos(cos(pi/4))
694-
/// let abs_difference = (f.cos().acos() - f32::consts::PI / 4.0).abs();
694+
/// let abs_difference = (f.cos().acos() - f32::consts::FRAC_PI_4).abs();
695695
///
696696
/// assert!(abs_difference <= f32::EPSILON);
697697
/// ```
@@ -734,7 +734,6 @@ impl f32 {
734734
/// ```
735735
/// use std::f32;
736736
///
737-
/// let pi = f32::consts::PI;
738737
/// // Positive angles measured counter-clockwise
739738
/// // from positive x axis
740739
/// // -pi/4 radians (45 deg clockwise)
@@ -745,8 +744,8 @@ impl f32 {
745744
/// let x2 = -3.0f32;
746745
/// let y2 = 3.0f32;
747746
///
748-
/// let abs_difference_1 = (y1.atan2(x1) - (-pi/4.0)).abs();
749-
/// let abs_difference_2 = (y2.atan2(x2) - 3.0*pi/4.0).abs();
747+
/// let abs_difference_1 = (y1.atan2(x1) - (-f32::consts::FRAC_PI_4)).abs();
748+
/// let abs_difference_2 = (y2.atan2(x2) - (3.0 * f32::consts::FRAC_PI_4)).abs();
750749
///
751750
/// assert!(abs_difference_1 <= f32::EPSILON);
752751
/// assert!(abs_difference_2 <= f32::EPSILON);
@@ -765,7 +764,7 @@ impl f32 {
765764
/// ```
766765
/// use std::f32;
767766
///
768-
/// let x = f32::consts::PI/4.0;
767+
/// let x = f32::consts::FRAC_PI_4;
769768
/// let f = x.sin_cos();
770769
///
771770
/// let abs_difference_0 = (f.0 - x.sin()).abs();
@@ -834,7 +833,7 @@ impl f32 {
834833
///
835834
/// let f = x.sinh();
836835
/// // Solving sinh() at 1 gives `(e^2-1)/(2e)`
837-
/// let g = (e*e - 1.0)/(2.0*e);
836+
/// let g = ((e * e) - 1.0) / (2.0 * e);
838837
/// let abs_difference = (f - g).abs();
839838
///
840839
/// assert!(abs_difference <= f32::EPSILON);
@@ -856,7 +855,7 @@ impl f32 {
856855
/// let x = 1.0f32;
857856
/// let f = x.cosh();
858857
/// // Solving cosh() at 1 gives this result
859-
/// let g = (e*e + 1.0)/(2.0*e);
858+
/// let g = ((e * e) + 1.0) / (2.0 * e);
860859
/// let abs_difference = (f - g).abs();
861860
///
862861
/// // Same result
@@ -880,7 +879,7 @@ impl f32 {
880879
///
881880
/// let f = x.tanh();
882881
/// // Solving tanh() at 1 gives `(1 - e^(-2))/(1 + e^(-2))`
883-
/// let g = (1.0 - e.powi(-2))/(1.0 + e.powi(-2));
882+
/// let g = (1.0 - e.powi(-2)) / (1.0 + e.powi(-2));
884883
/// let abs_difference = (f - g).abs();
885884
///
886885
/// assert!(abs_difference <= f32::EPSILON);

src/libstd/f64.rs

+16-17
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ impl f64 {
212212
/// let b = 60.0_f64;
213213
///
214214
/// // 100.0
215-
/// let abs_difference = (m.mul_add(x, b) - (m*x + b)).abs();
215+
/// let abs_difference = (m.mul_add(x, b) - ((m * x) + b)).abs();
216216
///
217217
/// assert!(abs_difference < 1e-10);
218218
/// ```
@@ -291,7 +291,7 @@ impl f64 {
291291
///
292292
/// ```
293293
/// let x = 2.0_f64;
294-
/// let abs_difference = (x.powi(2) - x*x).abs();
294+
/// let abs_difference = (x.powi(2) - (x * x)).abs();
295295
///
296296
/// assert!(abs_difference < 1e-10);
297297
/// ```
@@ -307,7 +307,7 @@ impl f64 {
307307
///
308308
/// ```
309309
/// let x = 2.0_f64;
310-
/// let abs_difference = (x.powf(2.0) - x*x).abs();
310+
/// let abs_difference = (x.powf(2.0) - (x * x)).abs();
311311
///
312312
/// assert!(abs_difference < 1e-10);
313313
/// ```
@@ -537,7 +537,7 @@ impl f64 {
537537
/// ```
538538
/// use std::f64;
539539
///
540-
/// let x = f64::consts::PI/2.0;
540+
/// let x = f64::consts::FRAC_PI_2;
541541
///
542542
/// let abs_difference = (x.sin() - 1.0).abs();
543543
///
@@ -556,7 +556,7 @@ impl f64 {
556556
/// ```
557557
/// use std::f64;
558558
///
559-
/// let x = 2.0*f64::consts::PI;
559+
/// let x = 2.0 * f64::consts::PI;
560560
///
561561
/// let abs_difference = (x.cos() - 1.0).abs();
562562
///
@@ -575,7 +575,7 @@ impl f64 {
575575
/// ```
576576
/// use std::f64;
577577
///
578-
/// let x = f64::consts::PI/4.0;
578+
/// let x = f64::consts::FRAC_PI_4;
579579
/// let abs_difference = (x.tan() - 1.0).abs();
580580
///
581581
/// assert!(abs_difference < 1e-14);
@@ -595,10 +595,10 @@ impl f64 {
595595
/// ```
596596
/// use std::f64;
597597
///
598-
/// let f = f64::consts::PI / 2.0;
598+
/// let f = f64::consts::FRAC_PI_2;
599599
///
600600
/// // asin(sin(pi/2))
601-
/// let abs_difference = (f.sin().asin() - f64::consts::PI / 2.0).abs();
601+
/// let abs_difference = (f.sin().asin() - f64::consts::FRAC_PI_2).abs();
602602
///
603603
/// assert!(abs_difference < 1e-10);
604604
/// ```
@@ -617,10 +617,10 @@ impl f64 {
617617
/// ```
618618
/// use std::f64;
619619
///
620-
/// let f = f64::consts::PI / 4.0;
620+
/// let f = f64::consts::FRAC_PI_4;
621621
///
622622
/// // acos(cos(pi/4))
623-
/// let abs_difference = (f.cos().acos() - f64::consts::PI / 4.0).abs();
623+
/// let abs_difference = (f.cos().acos() - f64::consts::FRAC_PI_4).abs();
624624
///
625625
/// assert!(abs_difference < 1e-10);
626626
/// ```
@@ -661,7 +661,6 @@ impl f64 {
661661
/// ```
662662
/// use std::f64;
663663
///
664-
/// let pi = f64::consts::PI;
665664
/// // Positive angles measured counter-clockwise
666665
/// // from positive x axis
667666
/// // -pi/4 radians (45 deg clockwise)
@@ -672,8 +671,8 @@ impl f64 {
672671
/// let x2 = -3.0_f64;
673672
/// let y2 = 3.0_f64;
674673
///
675-
/// let abs_difference_1 = (y1.atan2(x1) - (-pi/4.0)).abs();
676-
/// let abs_difference_2 = (y2.atan2(x2) - 3.0*pi/4.0).abs();
674+
/// let abs_difference_1 = (y1.atan2(x1) - (-f64::consts::FRAC_PI_4)).abs();
675+
/// let abs_difference_2 = (y2.atan2(x2) - (3.0 * f64::consts::FRAC_PI_4)).abs();
677676
///
678677
/// assert!(abs_difference_1 < 1e-10);
679678
/// assert!(abs_difference_2 < 1e-10);
@@ -692,7 +691,7 @@ impl f64 {
692691
/// ```
693692
/// use std::f64;
694693
///
695-
/// let x = f64::consts::PI/4.0;
694+
/// let x = f64::consts::FRAC_PI_4;
696695
/// let f = x.sin_cos();
697696
///
698697
/// let abs_difference_0 = (f.0 - x.sin()).abs();
@@ -759,7 +758,7 @@ impl f64 {
759758
///
760759
/// let f = x.sinh();
761760
/// // Solving sinh() at 1 gives `(e^2-1)/(2e)`
762-
/// let g = (e*e - 1.0)/(2.0*e);
761+
/// let g = ((e * e) - 1.0) / (2.0 * e);
763762
/// let abs_difference = (f - g).abs();
764763
///
765764
/// assert!(abs_difference < 1e-10);
@@ -781,7 +780,7 @@ impl f64 {
781780
/// let x = 1.0_f64;
782781
/// let f = x.cosh();
783782
/// // Solving cosh() at 1 gives this result
784-
/// let g = (e*e + 1.0)/(2.0*e);
783+
/// let g = ((e * e) + 1.0) / (2.0 * e);
785784
/// let abs_difference = (f - g).abs();
786785
///
787786
/// // Same result
@@ -805,7 +804,7 @@ impl f64 {
805804
///
806805
/// let f = x.tanh();
807806
/// // Solving tanh() at 1 gives `(1 - e^(-2))/(1 + e^(-2))`
808-
/// let g = (1.0 - e.powi(-2))/(1.0 + e.powi(-2));
807+
/// let g = (1.0 - e.powi(-2)) / (1.0 + e.powi(-2));
809808
/// let abs_difference = (f - g).abs();
810809
///
811810
/// assert!(abs_difference < 1.0e-10);

src/libstd/ffi/c_str.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -572,8 +572,8 @@ impl CString {
572572
/// use std::ffi::{CString, CStr};
573573
///
574574
/// let c_string = CString::new(b"foo".to_vec()).expect("CString::new failed");
575-
/// let c_str = c_string.as_c_str();
576-
/// assert_eq!(c_str,
575+
/// let cstr = c_string.as_c_str();
576+
/// assert_eq!(cstr,
577577
/// CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed"));
578578
/// ```
579579
#[inline]
@@ -994,17 +994,17 @@ impl CStr {
994994
/// ```
995995
/// use std::ffi::CStr;
996996
///
997-
/// let c_str = CStr::from_bytes_with_nul(b"hello");
998-
/// assert!(c_str.is_err());
997+
/// let cstr = CStr::from_bytes_with_nul(b"hello");
998+
/// assert!(cstr.is_err());
999999
/// ```
10001000
///
10011001
/// Creating a `CStr` with an interior nul byte is an error:
10021002
///
10031003
/// ```
10041004
/// use std::ffi::CStr;
10051005
///
1006-
/// let c_str = CStr::from_bytes_with_nul(b"he\0llo\0");
1007-
/// assert!(c_str.is_err());
1006+
/// let cstr = CStr::from_bytes_with_nul(b"he\0llo\0");
1007+
/// assert!(cstr.is_err());
10081008
/// ```
10091009
#[stable(feature = "cstr_from_bytes", since = "1.10.0")]
10101010
pub fn from_bytes_with_nul(bytes: &[u8])
@@ -1111,8 +1111,8 @@ impl CStr {
11111111
/// ```
11121112
/// use std::ffi::CStr;
11131113
///
1114-
/// let c_str = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
1115-
/// assert_eq!(c_str.to_bytes(), b"foo");
1114+
/// let cstr = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
1115+
/// assert_eq!(cstr.to_bytes(), b"foo");
11161116
/// ```
11171117
#[inline]
11181118
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1137,8 +1137,8 @@ impl CStr {
11371137
/// ```
11381138
/// use std::ffi::CStr;
11391139
///
1140-
/// let c_str = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
1141-
/// assert_eq!(c_str.to_bytes_with_nul(), b"foo\0");
1140+
/// let cstr = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
1141+
/// assert_eq!(cstr.to_bytes_with_nul(), b"foo\0");
11421142
/// ```
11431143
#[inline]
11441144
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1164,8 +1164,8 @@ impl CStr {
11641164
/// ```
11651165
/// use std::ffi::CStr;
11661166
///
1167-
/// let c_str = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
1168-
/// assert_eq!(c_str.to_str(), Ok("foo"));
1167+
/// let cstr = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
1168+
/// assert_eq!(cstr.to_str(), Ok("foo"));
11691169
/// ```
11701170
#[stable(feature = "cstr_to_str", since = "1.4.0")]
11711171
pub fn to_str(&self) -> Result<&str, str::Utf8Error> {
@@ -1205,9 +1205,9 @@ impl CStr {
12051205
/// use std::borrow::Cow;
12061206
/// use std::ffi::CStr;
12071207
///
1208-
/// let c_str = CStr::from_bytes_with_nul(b"Hello World\0")
1208+
/// let cstr = CStr::from_bytes_with_nul(b"Hello World\0")
12091209
/// .expect("CStr::from_bytes_with_nul failed");
1210-
/// assert_eq!(c_str.to_string_lossy(), Cow::Borrowed("Hello World"));
1210+
/// assert_eq!(cstr.to_string_lossy(), Cow::Borrowed("Hello World"));
12111211
/// ```
12121212
///
12131213
/// Calling `to_string_lossy` on a `CStr` containing invalid UTF-8:
@@ -1216,10 +1216,10 @@ impl CStr {
12161216
/// use std::borrow::Cow;
12171217
/// use std::ffi::CStr;
12181218
///
1219-
/// let c_str = CStr::from_bytes_with_nul(b"Hello \xF0\x90\x80World\0")
1219+
/// let cstr = CStr::from_bytes_with_nul(b"Hello \xF0\x90\x80World\0")
12201220
/// .expect("CStr::from_bytes_with_nul failed");
12211221
/// assert_eq!(
1222-
/// c_str.to_string_lossy(),
1222+
/// cstr.to_string_lossy(),
12231223
/// Cow::Owned(String::from("Hello �World")) as Cow<'_, str>
12241224
/// );
12251225
/// ```

0 commit comments

Comments
 (0)