Skip to content
This repository has been archived by the owner on Mar 23, 2020. It is now read-only.

Commit

Permalink
Merge pull request #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 committed May 11, 2017
2 parents 50fedd4 + 629ebab commit dcb2fd6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
10 changes: 9 additions & 1 deletion presentation/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 presentation/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 presentation/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 dcb2fd6

Please sign in to comment.