Ben Chuanlong Du's Blog

It is never too late to learn.

Tuple in Rust

In [ ]:
:timing
:sccache 1

Tips

  1. A Tuple in Rust can have up to 12 elements.

Tips and Traps

  1. Module std::collections has a good summary on when to each which collection in Rust.

Unpacking Variables (Multiple Assignments)

You can do multiple assignments simialarly as what you can do in Python.

In [2]:
let t = ("how", 1);
In [3]:
t.0
Out[3]:
"how"
In [4]:
t.1
Out[4]:
1
In [2]:
let(v1, v2) = ("how", 1)
In [3]:
v1
Out[3]:
"how"
In [4]:
v2
Out[4]:
1
In [ ]:

Comments