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 stringAccept
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.- Author:Parker Chen
- URL:www.parkerchenca.com/article/10ff0ccf-d7f8-8094-9866-c972b5fdcf48
- Copyright:All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!

