We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
So, imagine having a len! macro. Literally just that.
len!
Well, there aren't a lot of reasons... Use-case #1:
let world = "World"; let helloworld = String::with_capacity(len!("Hello "), world.len()); println!("{}", helloworld);
Use-case #2:
let string = "prefix!!yay"; if string.starts_with("prefix!!") { let string = &string[len!("prefix!!")..]; assert_eq!(string, "yay"); }
The text was updated successfully, but these errors were encountered:
Both of those examples could use .len().
.len()
Sorry, something went wrong.
Except "prefix!!".len() isn't retrieved at compile time.
"prefix!!".len()
@legolord208 What difference does it make? It still optimizes to a constant, always.
Oh 🤔.... Ooops, didn't realize
No branches or pull requests
So, imagine having a
len!
macro. Literally just that.Why is this useful?
Well, there aren't a lot of reasons...
Use-case #1:
Use-case #2:
The text was updated successfully, but these errors were encountered: