@@ -319,6 +319,13 @@ pub(super) trait SplitIter: DoubleEndedIterator {
319319///
320320/// This struct is created by the [`split`] method on [slices].
321321///
322+ /// # Example
323+ ///
324+ /// ```
325+ /// let slice = [10, 40, 33, 20];
326+ /// let mut iter = slice.split(|num| num % 3 == 0);
327+ /// ```
328+ ///
322329/// [`split`]: ../../std/primitive.slice.html#method.split
323330/// [slices]: ../../std/primitive.slice.html
324331#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -434,6 +441,15 @@ impl<T, P> FusedIterator for Split<'_, T, P> where P: FnMut(&T) -> bool {}
434441///
435442/// This struct is created by the [`split_inclusive`] method on [slices].
436443///
444+ /// # Example
445+ ///
446+ /// ```
447+ /// #![feature(split_inclusive)]
448+ ///
449+ /// let slice = [10, 40, 33, 20];
450+ /// let mut iter = slice.split_inclusive(|num| num % 3 == 0);
451+ /// ```
452+ ///
437453/// [`split_inclusive`]: ../../std/primitive.slice.html#method.split_inclusive
438454/// [slices]: ../../std/primitive.slice.html
439455#[ unstable( feature = "split_inclusive" , issue = "72360" ) ]
@@ -539,6 +555,13 @@ impl<T, P> FusedIterator for SplitInclusive<'_, T, P> where P: FnMut(&T) -> bool
539555///
540556/// This struct is created by the [`split_mut`] method on [slices].
541557///
558+ /// # Example
559+ ///
560+ /// ```
561+ /// let mut v = [10, 40, 30, 20, 60, 50];
562+ /// let iter = v.split_mut(|num| *num % 3 == 0);
563+ /// ```
564+ ///
542565/// [`split_mut`]: ../../std/primitive.slice.html#method.split_mut
543566/// [slices]: ../../std/primitive.slice.html
544567#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -661,6 +684,15 @@ impl<T, P> FusedIterator for SplitMut<'_, T, P> where P: FnMut(&T) -> bool {}
661684///
662685/// This struct is created by the [`split_inclusive_mut`] method on [slices].
663686///
687+ /// # Example
688+ ///
689+ /// ```
690+ /// #![feature(split_inclusive)]
691+ ///
692+ /// let mut v = [10, 40, 30, 20, 60, 50];
693+ /// let iter = v.split_inclusive_mut(|num| *num % 3 == 0);
694+ /// ```
695+ ///
664696/// [`split_inclusive_mut`]: ../../std/primitive.slice.html#method.split_inclusive_mut
665697/// [slices]: ../../std/primitive.slice.html
666698#[ unstable( feature = "split_inclusive" , issue = "72360" ) ]
@@ -775,6 +807,13 @@ impl<T, P> FusedIterator for SplitInclusiveMut<'_, T, P> where P: FnMut(&T) -> b
775807///
776808/// This struct is created by the [`rsplit`] method on [slices].
777809///
810+ /// # Example
811+ ///
812+ /// ```
813+ /// let slice = [11, 22, 33, 0, 44, 55];
814+ /// let iter = slice.rsplit(|num| *num == 0);
815+ /// ```
816+ ///
778817/// [`rsplit`]: ../../std/primitive.slice.html#method.rsplit
779818/// [slices]: ../../std/primitive.slice.html
780819#[ stable( feature = "slice_rsplit" , since = "1.27.0" ) ]
@@ -854,6 +893,13 @@ impl<T, P> FusedIterator for RSplit<'_, T, P> where P: FnMut(&T) -> bool {}
854893///
855894/// This struct is created by the [`rsplit_mut`] method on [slices].
856895///
896+ /// # Example
897+ ///
898+ /// ```
899+ /// let mut slice = [11, 22, 33, 0, 44, 55];
900+ /// let iter = slice.rsplit_mut(|num| *num == 0);
901+ /// ```
902+ ///
857903/// [`rsplit_mut`]: ../../std/primitive.slice.html#method.rsplit_mut
858904/// [slices]: ../../std/primitive.slice.html
859905#[ stable( feature = "slice_rsplit" , since = "1.27.0" ) ]
@@ -966,6 +1012,13 @@ impl<T, I: SplitIter<Item = T>> Iterator for GenericSplitN<I> {
9661012///
9671013/// This struct is created by the [`splitn`] method on [slices].
9681014///
1015+ /// # Example
1016+ ///
1017+ /// ```
1018+ /// let slice = [10, 40, 30, 20, 60, 50];
1019+ /// let iter = slice.splitn(2, |num| *num % 3 == 0);
1020+ /// ```
1021+ ///
9691022/// [`splitn`]: ../../std/primitive.slice.html#method.splitn
9701023/// [slices]: ../../std/primitive.slice.html
9711024#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -999,6 +1052,13 @@ where
9991052///
10001053/// This struct is created by the [`rsplitn`] method on [slices].
10011054///
1055+ /// # Example
1056+ ///
1057+ /// ```
1058+ /// let slice = [10, 40, 30, 20, 60, 50];
1059+ /// let iter = slice.rsplitn(2, |num| *num % 3 == 0);
1060+ /// ```
1061+ ///
10021062/// [`rsplitn`]: ../../std/primitive.slice.html#method.rsplitn
10031063/// [slices]: ../../std/primitive.slice.html
10041064#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -1031,6 +1091,13 @@ where
10311091///
10321092/// This struct is created by the [`splitn_mut`] method on [slices].
10331093///
1094+ /// # Example
1095+ ///
1096+ /// ```
1097+ /// let mut slice = [10, 40, 30, 20, 60, 50];
1098+ /// let iter = slice.splitn_mut(2, |num| *num % 3 == 0);
1099+ /// ```
1100+ ///
10341101/// [`splitn_mut`]: ../../std/primitive.slice.html#method.splitn_mut
10351102/// [slices]: ../../std/primitive.slice.html
10361103#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -1064,6 +1131,13 @@ where
10641131///
10651132/// This struct is created by the [`rsplitn_mut`] method on [slices].
10661133///
1134+ /// # Example
1135+ ///
1136+ /// ```
1137+ /// let mut slice = [10, 40, 30, 20, 60, 50];
1138+ /// let iter = slice.rsplitn_mut(2, |num| *num % 3 == 0);
1139+ /// ```
1140+ ///
10671141/// [`rsplitn_mut`]: ../../std/primitive.slice.html#method.rsplitn_mut
10681142/// [slices]: ../../std/primitive.slice.html
10691143#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -1100,6 +1174,13 @@ forward_iterator! { RSplitNMut: T, &'a mut [T] }
11001174///
11011175/// This struct is created by the [`windows`] method on [slices].
11021176///
1177+ /// # Example
1178+ ///
1179+ /// ```
1180+ /// let slice = ['r', 'u', 's', 't'];
1181+ /// let iter = slice.windows(2);
1182+ /// ```
1183+ ///
11031184/// [`windows`]: ../../std/primitive.slice.html#method.windows
11041185/// [slices]: ../../std/primitive.slice.html
11051186#[ derive( Debug ) ]
@@ -1239,6 +1320,13 @@ unsafe impl<'a, T> TrustedRandomAccess for Windows<'a, T> {
12391320///
12401321/// This struct is created by the [`chunks`] method on [slices].
12411322///
1323+ /// # Example
1324+ ///
1325+ /// ```
1326+ /// let slice = ['l', 'o', 'r', 'e', 'm'];
1327+ /// let iter = slice.chunks(2);
1328+ /// ```
1329+ ///
12421330/// [`chunks`]: ../../std/primitive.slice.html#method.chunks
12431331/// [slices]: ../../std/primitive.slice.html
12441332#[ derive( Debug ) ]
@@ -1400,6 +1488,13 @@ unsafe impl<'a, T> TrustedRandomAccess for Chunks<'a, T> {
14001488///
14011489/// This struct is created by the [`chunks_mut`] method on [slices].
14021490///
1491+ /// # Example
1492+ ///
1493+ /// ```
1494+ /// let mut slice = ['l', 'o', 'r', 'e', 'm'];
1495+ /// let iter = slice.chunks_mut(2);
1496+ /// ```
1497+ ///
14031498/// [`chunks_mut`]: ../../std/primitive.slice.html#method.chunks_mut
14041499/// [slices]: ../../std/primitive.slice.html
14051500#[ derive( Debug ) ]
@@ -1559,6 +1654,13 @@ unsafe impl<'a, T> TrustedRandomAccess for ChunksMut<'a, T> {
15591654///
15601655/// This struct is created by the [`chunks_exact`] method on [slices].
15611656///
1657+ /// # Example
1658+ ///
1659+ /// ```
1660+ /// let slice = ['l', 'o', 'r', 'e', 'm'];
1661+ /// let iter = slice.chunks_exact(2);
1662+ /// ```
1663+ ///
15621664/// [`chunks_exact`]: ../../std/primitive.slice.html#method.chunks_exact
15631665/// [`remainder`]: ChunksExact::remainder
15641666/// [slices]: ../../std/primitive.slice.html
@@ -1708,6 +1810,13 @@ unsafe impl<'a, T> TrustedRandomAccess for ChunksExact<'a, T> {
17081810///
17091811/// This struct is created by the [`chunks_exact_mut`] method on [slices].
17101812///
1813+ /// # Example
1814+ ///
1815+ /// ```
1816+ /// let mut slice = ['l', 'o', 'r', 'e', 'm'];
1817+ /// let iter = slice.chunks_exact_mut(2);
1818+ /// ```
1819+ ///
17111820/// [`chunks_exact_mut`]: ../../std/primitive.slice.html#method.chunks_exact_mut
17121821/// [`into_remainder`]: ChunksExactMut::into_remainder
17131822/// [slices]: ../../std/primitive.slice.html
@@ -1850,6 +1959,15 @@ unsafe impl<'a, T> TrustedRandomAccess for ChunksExactMut<'a, T> {
18501959///
18511960/// This struct is created by the [`array_windows`] method on [slices].
18521961///
1962+ /// # Example
1963+ ///
1964+ /// ```
1965+ /// #![feature(array_windows)]
1966+ ///
1967+ /// let slice = [0, 1, 2, 3];
1968+ /// let iter = slice.array_windows::<2>();
1969+ /// ```
1970+ ///
18531971/// [`array_windows`]: ../../std/primitive.slice.html#method.array_windows
18541972/// [slices]: ../../std/primitive.slice.html
18551973#[ derive( Debug , Clone , Copy ) ]
@@ -1962,6 +2080,15 @@ impl<T, const N: usize> ExactSizeIterator for ArrayWindows<'_, T, N> {
19622080///
19632081/// This struct is created by the [`array_chunks`] method on [slices].
19642082///
2083+ /// # Example
2084+ ///
2085+ /// ```
2086+ /// #![feature(array_chunks)]
2087+ ///
2088+ /// let slice = ['l', 'o', 'r', 'e', 'm'];
2089+ /// let iter = slice.array_chunks::<2>();
2090+ /// ```
2091+ ///
19652092/// [`array_chunks`]: ../../std/primitive.slice.html#method.array_chunks
19662093/// [`remainder`]: ArrayChunks::remainder
19672094/// [slices]: ../../std/primitive.slice.html
@@ -2080,6 +2207,15 @@ unsafe impl<'a, T, const N: usize> TrustedRandomAccess for ArrayChunks<'a, T, N>
20802207///
20812208/// This struct is created by the [`array_chunks_mut`] method on [slices].
20822209///
2210+ /// # Example
2211+ ///
2212+ /// ```
2213+ /// #![feature(array_chunks)]
2214+ ///
2215+ /// let mut slice = ['l', 'o', 'r', 'e', 'm'];
2216+ /// let iter = slice.array_chunks_mut::<2>();
2217+ /// ```
2218+ ///
20832219/// [`array_chunks_mut`]: ../../std/primitive.slice.html#method.array_chunks_mut
20842220/// [`into_remainder`]: ../../std/slice/struct.ArrayChunksMut.html#method.into_remainder
20852221/// [slices]: ../../std/primitive.slice.html
@@ -2190,6 +2326,13 @@ unsafe impl<'a, T, const N: usize> TrustedRandomAccess for ArrayChunksMut<'a, T,
21902326///
21912327/// This struct is created by the [`rchunks`] method on [slices].
21922328///
2329+ /// # Example
2330+ ///
2331+ /// ```
2332+ /// let slice = ['l', 'o', 'r', 'e', 'm'];
2333+ /// let iter = slice.rchunks(2);
2334+ /// ```
2335+ ///
21932336/// [`rchunks`]: ../../std/primitive.slice.html#method.rchunks
21942337/// [slices]: ../../std/primitive.slice.html
21952338#[ derive( Debug ) ]
@@ -2347,6 +2490,13 @@ unsafe impl<'a, T> TrustedRandomAccess for RChunks<'a, T> {
23472490///
23482491/// This struct is created by the [`rchunks_mut`] method on [slices].
23492492///
2493+ /// # Example
2494+ ///
2495+ /// ```
2496+ /// let mut slice = ['l', 'o', 'r', 'e', 'm'];
2497+ /// let iter = slice.rchunks_mut(2);
2498+ /// ```
2499+ ///
23502500/// [`rchunks_mut`]: ../../std/primitive.slice.html#method.rchunks_mut
23512501/// [slices]: ../../std/primitive.slice.html
23522502#[ derive( Debug ) ]
@@ -2504,6 +2654,13 @@ unsafe impl<'a, T> TrustedRandomAccess for RChunksMut<'a, T> {
25042654///
25052655/// This struct is created by the [`rchunks_exact`] method on [slices].
25062656///
2657+ /// # Example
2658+ ///
2659+ /// ```
2660+ /// let slice = ['l', 'o', 'r', 'e', 'm'];
2661+ /// let iter = slice.rchunks_exact(2);
2662+ /// ```
2663+ ///
25072664/// [`rchunks_exact`]: ../../std/primitive.slice.html#method.rchunks_exact
25082665/// [`remainder`]: ChunksExact::remainder
25092666/// [slices]: ../../std/primitive.slice.html
@@ -2657,6 +2814,13 @@ unsafe impl<'a, T> TrustedRandomAccess for RChunksExact<'a, T> {
26572814///
26582815/// This struct is created by the [`rchunks_exact_mut`] method on [slices].
26592816///
2817+ /// # Example
2818+ ///
2819+ /// ```
2820+ /// let mut slice = ['l', 'o', 'r', 'e', 'm'];
2821+ /// let iter = slice.rchunks_exact_mut(2);
2822+ /// ```
2823+ ///
26602824/// [`rchunks_exact_mut`]: ../../std/primitive.slice.html#method.rchunks_exact_mut
26612825/// [`into_remainder`]: ChunksExactMut::into_remainder
26622826/// [slices]: ../../std/primitive.slice.html
0 commit comments