A beginner's rust-lang exploration :)
$ cargo add ferris-says
$ cargo build
$ cargo run
$ cargo fmt
$ cargo fix
-
No need to write parentheses in
if
for
control flow statement -
Can still use
return something;
if we want -
Seems that there's no builtin random generator, had to use crate
rand
to do that(ref) -
Seems that is is very hard to create a recursive closure?(ref)
-
The naming conver of a
.rs
file in rust project is unclear,kebab-case
orsnake_case
?(ref) -
Need to declare a module first before using, maybe something like
#ifndef & #define
in c++(ref1, ref2, ref3):/// define a module in some file, this in fact do the `copy file content into it` stuff work mod utils; /// use it in some other file use utils; use crate::utils; // from 'project root directory' to find the module use super::utils; // from 'parent directory' to find the module
-
When I want to use a un-exported or indirect type from a dependency, for example, a return type from a
new
, it is painful. There's no such thing like typescriptReturnType<fn>
, had to find where the exact typings are from, andcargo add
that exact version of dep(ref1, ref2).