Skip to content

Commit

Permalink
Merge pull request ferrous-systems#63 from skade/feature/syntax
Browse files Browse the repository at this point in the history
Add attributes to syntax
  • Loading branch information
Andrew Hobden authored May 11, 2017
2 parents 58163e9 + 3f09f77 commit 421fae5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
10 changes: 9 additions & 1 deletion chapters/en-US/syntax.chapter
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,16 @@ Generally the `where` syntax is preferred.

---

## Attributes

Rust attributes are used for a number of different things. There is a full list of attributes in the [reference](https://doc.rust-lang.org/reference/attributes.html).

<pre><code data-source="chapters/shared/code/syntax/15.rs" data-trim="hljs rust" class="lang-rust"></code></pre>

---

## On Semicolons

A line without a semi-colon implictly returns. Don't worry, the compiler will tell you if you forget it.

<pre><code data-source="chapters/shared/code/syntax/15.rs" data-trim="hljs rust" class="lang-rust"></code></pre>
<pre><code data-source="chapters/shared/code/syntax/16.rs" data-trim="hljs rust" class="lang-rust"></code></pre>
13 changes: 6 additions & 7 deletions chapters/shared/code/syntax/15.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
fn do_thing() -> bool {
"Forgotten semicolon"
true
}
#[#[derive(Clone, Copy)]]
struct Foo;

fn main() {
do_thing()
}
#[inline(always)]
fn bar() {}

fn main() {}
8 changes: 8 additions & 0 deletions chapters/shared/code/syntax/16.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fn do_thing() -> bool {
"Forgotten semicolon"
true
}

fn main() {
do_thing()
}

0 comments on commit 421fae5

Please sign in to comment.