Tracking Issue for CharIndices::offset function (original) (raw)

Feature gate: #![feature(char_indices_offset)]

This is a tracking issue for the function CharIndices::offset. It returns the byte position of the next character, or the length of the underlying string if there are no more characters. This is useful for getting ranges over strings you're iterating over.

Public API

let mut chars = "a楽".char_indices();

assert_eq!(chars.offset(), 0); assert_eq!(chars.next(), Some((0, 'a')));

assert_eq!(chars.offset(), 1); assert_eq!(chars.next(), Some((1, '楽')));

assert_eq!(chars.offset(), 4); assert_eq!(chars.next(), None);

Steps / History

Unresolved Questions