@@ -384,6 +384,9 @@ pub trait Iterator {
384
384
///
385
385
/// In other words, it links two iterators together, in a chain. 🔗
386
386
///
387
+ /// [`once`] is commonly used to adapt a single value into a chain of
388
+ /// other kinds of iteration.
389
+ ///
387
390
/// # Examples
388
391
///
389
392
/// Basic usage:
@@ -408,9 +411,6 @@ pub trait Iterator {
408
411
/// [`Iterator`] itself. For example, slices (`&[T]`) implement
409
412
/// [`IntoIterator`], and so can be passed to `chain()` directly:
410
413
///
411
- /// [`IntoIterator`]: trait.IntoIterator.html
412
- /// [`Iterator`]: trait.Iterator.html
413
- ///
414
414
/// ```
415
415
/// let s1 = &[1, 2, 3];
416
416
/// let s2 = &[4, 5, 6];
@@ -425,6 +425,21 @@ pub trait Iterator {
425
425
/// assert_eq!(iter.next(), Some(&6));
426
426
/// assert_eq!(iter.next(), None);
427
427
/// ```
428
+ ///
429
+ /// If you work with Windows API, you may wish to convert [`OsStr`] to `Vec<u16>`:
430
+ ///
431
+ /// ```
432
+ /// #[cfg(windows)]
433
+ /// fn os_str_to_utf16(s: &std::ffi::OsStr) -> Vec<u16> {
434
+ /// use std::os::windows::ffi::OsStrExt;
435
+ /// s.encode_wide().chain(std::iter::once(0)).collect()
436
+ /// }
437
+ /// ```
438
+ ///
439
+ /// [`once`]: fn.once.html
440
+ /// [`Iterator`]: trait.Iterator.html
441
+ /// [`IntoIterator`]: trait.IntoIterator.html
442
+ /// [`OsStr`]: ../../std/ffi/struct.OsStr.html
428
443
#[ inline]
429
444
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
430
445
fn chain < U > ( self , other : U ) -> Chain < Self , U :: IntoIter > where
0 commit comments