1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2024-12-15 06:20:32 +02:00

Use std::string_view (not just const char*) as an analogy of &str. (#1518)

This commit is contained in:
Lukasz Anforowicz 2023-12-01 15:17:27 +00:00 committed by GitHub
parent f837afa034
commit 9d21d5648d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,7 +48,7 @@ Rust terminology:
boundaries, the expression will panic. The `chars` iterator iterates over
characters and is preferred over trying to get character boundaries right.
* For C++ programmers: think of `&str` as `const char*` from C++, but the one that always points
* For C++ programmers: think of `&str` as `std::string_view` from C++, but the one that always points
to a valid string in memory. Rust `String` is a rough equivalent of `std::string` from C++
(main difference: it can only contain UTF-8 encoded bytes and will never use a small-string optimization).