2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-03 15:40:17 +00:00

rust/Types: Add reminder for different forms of 'self' parameter

This commit is contained in:
Luc Street 2018-08-19 22:03:16 -07:00
parent 25f882d1db
commit b8600d8082

View File

@ -43,7 +43,10 @@
// Methods //
impl<T> Foo<T> {
// Methods take an explicit `self` parameter
// Instance methods take an explicit `self` parameter.
// Using `self` on its own will consume the caller, while
// `&self` or `&mut self` will create immutable and mutable
// references, respectively.
fn get_bar(self) -> T {
self.bar
}