this post was submitted on 16 Oct 2024
58 points (96.8% liked)
Rust
5876 readers
125 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
The general theme of your comment is good, but the example is...
strcmp()
docs:So basically, if C had higher level constructs, it would be identical to Rust here.
Rust has
impl Add<&str> for String
andimpl AddAssign<&str> for String
. Both append as expected.But maybe you meant numeric addition specifically.
In that case, yes, Rust doesn't have that, although it's an
impl<'a> Step for &'a str
away from having something similar (it would be("AAAAA"..).next()
).impl Step for char
already exists of course, but shouldn't if we take your argument to its logical conclusion.Oh, and C would most definitely have this feature if it could. Numerical manipulation of
char
s is commonplace there.