From 3f09f772ecf80ebd3b4fd44317fe61a980c09a6b Mon Sep 17 00:00:00 2001 From: Andrew Hobden Date: Thu, 11 May 2017 16:24:22 +0200 Subject: [PATCH] Add attributes --- chapters/en-US/syntax.chapter | 10 +++++++++- chapters/shared/code/syntax/15.rs | 13 ++++++------- chapters/shared/code/syntax/16.rs | 8 ++++++++ 3 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 chapters/shared/code/syntax/16.rs diff --git a/chapters/en-US/syntax.chapter b/chapters/en-US/syntax.chapter index 27652f7..fa80777 100644 --- a/chapters/en-US/syntax.chapter +++ b/chapters/en-US/syntax.chapter @@ -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). + +
+ +--- + ## On Semicolons A line without a semi-colon implictly returns. Don't worry, the compiler will tell you if you forget it. -
\ No newline at end of file +
\ No newline at end of file diff --git a/chapters/shared/code/syntax/15.rs b/chapters/shared/code/syntax/15.rs index 2970148..beb275a 100644 --- a/chapters/shared/code/syntax/15.rs +++ b/chapters/shared/code/syntax/15.rs @@ -1,8 +1,7 @@ -fn do_thing() -> bool { - "Forgotten semicolon" - true -} +#[#[derive(Clone, Copy)]] +struct Foo; -fn main() { - do_thing() -} \ No newline at end of file +#[inline(always)] +fn bar() {} + +fn main() {} \ No newline at end of file diff --git a/chapters/shared/code/syntax/16.rs b/chapters/shared/code/syntax/16.rs new file mode 100644 index 0000000..2970148 --- /dev/null +++ b/chapters/shared/code/syntax/16.rs @@ -0,0 +1,8 @@ +fn do_thing() -> bool { + "Forgotten semicolon" + true +} + +fn main() { + do_thing() +} \ No newline at end of file