5,321
edits
Line 10: | Line 10: | ||
==Syntax== | ==Syntax== | ||
=== | ===Basics=== | ||
<syntaxhighlight lang="rust"> | <syntaxhighlight lang="rust"> | ||
# Const variable, must have type annotation. | # Const variable, must have type annotation. | ||
Line 45: | Line 45: | ||
} | } | ||
} | } | ||
</syntaxhighlight> | |||
===Borrowing=== | |||
This is like references in C++ | |||
<syntaxhighlight lang="rust"> | |||
let x = 5; | |||
let mut y = 6; | |||
# C++: const int & | |||
fill_vec_borrow(&x) | |||
# C++: int& | |||
fill_vec_mut_borrow(&mut y) | |||
</syntaxhighlight> | </syntaxhighlight> | ||