type
Post
status
Published
date
Sep 28, 2024
slug
summary
Range
tags
Rust
category
Tech notes
icon
password

Range

Rather than using C style loop, in Rust, we use ..= to indicate a range:
Output:
Sequences are only allowed for numeric or character types because they can be consecutive.
 

Char

 
Use '' . "" is for the string
Accept Unicode, occupy 4 bytes.
 

Bool

 
Only 1 byte.
 

Unit type

 
Literally, it is ().
Yes, the unit type is (), and the value of this type is also, and only ().
It's similar to void in other languages.
Sometimes, you may come across code like Result<(), String>. This is an example of generic types in Rust. If you're familiar with C++ generic types, you can figure out that we pass 2 types into the Result, regardless of what the Result actually is.
Two Ways to Reverse a Singly Linked ListLagrange Interpolation Method
Loading...