28. Raw string
Curious to know how you can add a double quote in raw strings?
No escape sequences are recognized in raw strings, so adding a backslash does not work.
Use ### to mark the start and the end of a raw string.
| |
Curious to know how you can add a double quote in raw strings?
No escape sequences are recognized in raw strings, so adding a backslash does not work.
Use ### to mark the start and the end of a raw string.
| |
Rust’s option implements Sum and Product traits too!
Use it when you want to get None if there is a None element and sum of values otherwise.
| |
or sum of the values …
| |
And product.
| |
Rust’s option implements FromIterator too!
Use it when you want to get None if there is a None element and values otherwise.
| |
or values …
| |
Rust’s option implements an iterator!
| |
Why is this useful? see example.
| |
As of 1.66, it is possible to use ..=X in patterns
| |
Instead of manually implementing Default trait for an enum, you can derive it and explicitly tell which variant should be the default one.
| |
Use Debug trait to print enum values if needed.
| |
Sometimes there is a need to zip two iterables of various lengths.
If it is known which one is longer, then use the following approach:
First one must be longer.
| |
As of 1.65, it is possible to use let statement with a refutable pattern.
| |
As of 1.65, it is possible to label plain block expression and terminate that block early.
| |