diff options
| author | Jakub Bukaj <jakub@jakub.cc> | 2014-11-16 10:19:22 +0100 |
|---|---|---|
| committer | Jakub Bukaj <jakub@jakub.cc> | 2014-11-16 10:19:22 +0100 |
| commit | ecf765d97b2a519baaffa6c1dbeb7efc9ed34ec9 (patch) | |
| tree | 9e0492982fa8d9963e335d65568786aa9e02ebd8 /src/doc | |
| parent | cb51567e1911452f3da4b924a91e5360f5efe67c (diff) | |
| parent | 769d49a8b7d00c2e3b85a139206516764ce23a84 (diff) | |
| download | rust-ecf765d97b2a519baaffa6c1dbeb7efc9ed34ec9.tar.gz rust-ecf765d97b2a519baaffa6c1dbeb7efc9ed34ec9.zip | |
rollup merge of #18933: IanConnolly/doc-fake-rust
Diffstat (limited to 'src/doc')
| -rw-r--r-- | src/doc/guide-pointers.md | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/doc/guide-pointers.md b/src/doc/guide-pointers.md index 87eb91d3ec7..2c6388a6180 100644 --- a/src/doc/guide-pointers.md +++ b/src/doc/guide-pointers.md @@ -133,11 +133,11 @@ pass-by-reference. Basically, languages can make two choices (this is made up syntax, it's not Rust): ```{notrust,ignore} -fn foo(x) { +func foo(x) { x = 5 } -fn main() { +func main() { i = 1 foo(i) // what is the value of i here? @@ -153,11 +153,11 @@ So what do pointers have to do with this? Well, since pointers point to a location in memory... ```{notrust,ignore} -fn foo(&int x) { +func foo(&int x) { *x = 5 } -fn main() { +func main() { i = 1 foo(&i) // what is the value of i here? @@ -192,13 +192,13 @@ When you combine pointers and functions, it's easy to accidentally invalidate the memory the pointer is pointing to. For example: ```{notrust,ignore} -fn make_pointer(): &int { +func make_pointer(): &int { x = 5; return &x; } -fn main() { +func main() { &int i = make_pointer(); *i = 5; // uh oh! } @@ -214,11 +214,11 @@ issue. Two pointers are said to alias when they point at the same location in memory. Like this: ```{notrust,ignore} -fn mutate(&int i, int j) { +func mutate(&int i, int j) { *i = j; } -fn main() { +func main() { x = 5; y = &x; z = &x; //y and z are aliased |
