Where did str.graphemes() go?


#1

Trying to use the .graphemes() iterator, I get this:

error: no method named `graphemes` found for type `&str` in the current scope
  --> src/main.rs:84:24
     |
     |         for gr in line.graphemes() {                // for all graphemes
     |                        ^^^^^^^^^

Is .graphemes() a standard method of &str? I thought it became one last year. But I’ve also seen discussions of it being moved to some external crate. There’s a version in https://unicode-rs.github.io/unicode-segmentation/unicode_segmentation/index.html but I thought that had been superseded. There’s https://doc.rust-lang.org/1.3.0/std/str/struct.Graphemes.html but I have “use std::str” and that’s not bringing it in.

(Latest Rust stable, downloaded a few minutes ago.)


#2

It had been deprecated and moved to the crate you mentioned as of 1.3.0:

Deprecated since 1.0.0: use the crates.io unicode-segmentation library instead

https://doc.rust-lang.org/1.3.0/std/primitive.str.html#method.graphemes

and it was removed soon after 1.3.0 was released: http://github.com/rust-lang/rust/commit/8d90d3f36871a00023cc1f313f91e351c287ca15


#3

Note that it was never a stable API in libstd.