Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
scotty79
54 days ago
|
parent
|
context
|
favorite
| on:
Flattening Rust’s learning curve
Nah. &str is const char* exactly. It's as primitive as types in rust get.
tuetuopay
54 days ago
[–]
Nope. `&str` includes the length of the slice, which `const char*` does not. `std::string_view` is the proper analogy.
umanwizard
54 days ago
|
parent
[–]
Another difference is that &str is guaranteed to be utf-8, whereas const char* can be any encoding (or no encoding).
pdpi
53 days ago
|
root
|
parent
[–]
Also, &str is closer to const uint8_t* than it is to const char*. Chars are signed by default and are
at least
8 bits, but can be wider.
Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: