Skip to content

FAQ refers to apparently non-existent .char_at() method #46942

@mark-summerfield

Description

@mark-summerfield

In this file: https://www.rust-lang.org/en-US/faq.html#strings it refers to a .char_at() method. I've tried this on String and &str but according the the playpen neither has this method:

fn main() {
    let s = "Hello, world!";
    let t = s.to_string();
    println!("{}", s.char_at(5));
    println!("{}", t.char_at(5));
}
   Compiling playground v0.0.1 (file:///playground)
error[E0599]: no method named `char_at` found for type `&str` in the current scope
 --> src/main.rs:4:22
  |
4 |     println!("{}", s.char_at(5));
  |                      ^^^^^^^

error[E0599]: no method named `char_at` found for type `std::string::String` in the current scope
 --> src/main.rs:5:22
  |
5 |     println!("{}", t.char_at(5));
  |                      ^^^^^^^

error: aborting due to 2 previous errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions