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

Add attributes to syntax #63

Merged
merged 1 commit into from
May 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
}