diff options
Diffstat (limited to 'rust.html.markdown')
-rw-r--r-- | rust.html.markdown | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/rust.html.markdown b/rust.html.markdown index 413939bf..83682c01 100644 --- a/rust.html.markdown +++ b/rust.html.markdown @@ -176,7 +176,13 @@ fn main() { impl<T> Foo<T> { // Methods take an explicit `self` parameter - fn get_bar(self) -> T { + fn bar(&self) -> &T { // self is borrowed + &self.bar + } + fn bar_mut(&mut self) -> &mut T { // self is mutably borrowed + &mut self.bar + } + fn into_bar(self) -> T { // here self is consumed self.bar } } |