@@ -241,24 +241,35 @@ impl<'a> CharIndices<'a> {
241241 /// Returns the byte position of the next character, or the length
242242 /// of the underlying string if there are no more characters.
243243 ///
244+ /// This means that, when the iterator has not been fully consumed,
245+ /// the returned value will match the index that will be returned
246+ /// by the next call to [`next()`](Self::next).
247+ ///
244248 /// # Examples
245249 ///
246250 /// ```
247- /// #![feature(char_indices_offset)]
248251 /// let mut chars = "a楽".char_indices();
249252 ///
253+ /// // `next()` has not been called yet, so `offset()` returns the byte
254+ /// // index of the first character of the string, which is always 0.
250255 /// assert_eq!(chars.offset(), 0);
256+ /// // As expected, the first call to `next()` also returns 0 as index.
251257 /// assert_eq!(chars.next(), Some((0, 'a')));
252258 ///
259+ /// // `next()` has been called once, so `offset()` returns the byte index
260+ /// // of the second character ...
253261 /// assert_eq!(chars.offset(), 1);
262+ /// // ... which matches the index returned by the next call to `next()`.
254263 /// assert_eq!(chars.next(), Some((1, '楽')));
255264 ///
265+ /// // Once the iterator has been consumed, `offset()` returns the length
266+ /// // in bytes of the string.
256267 /// assert_eq!(chars.offset(), 4);
257268 /// assert_eq!(chars.next(), None);
258269 /// ```
259270 #[ inline]
260271 #[ must_use]
261- #[ unstable ( feature = "char_indices_offset" , issue = "83871 " ) ]
272+ #[ stable ( feature = "char_indices_offset" , since = "CURRENT_RUSTC_VERSION " ) ]
262273 pub fn offset ( & self ) -> usize {
263274 self . front_offset
264275 }
0 commit comments