Skip to content
6 changes: 3 additions & 3 deletions mk/docs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
# translated.
######################################################################
DOCS := index tutorial guide-ffi guide-macros guide-lifetimes \
guide-tasks guide-container guide-pointers guide-testing \
guide-runtime complement-bugreport complement-cheatsheet \
complement-lang-faq complement-project-faq rust rustdoc
guide-tasks guide-container guide-pointers \
complement-cheatsheet guide-runtime \
rust rustdoc new-tutorial guide-syntax

PDF_DOCS := tutorial rust

Expand Down
64 changes: 64 additions & 0 deletions src/doc/guide-syntax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
% The Guide to Rust Syntax

A *very* brief guide to Rust syntax. It assumes you are already familar with programming concepts.

# Arguments

# Conditions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we consider using a different word here, given that the word "Conditions" had a prior meaning in the code base that I assume is very different than what is going to be presented in this section? (If you search for "conditions" in the github repository you will see what I mean.) I suppose my concern is if people come to the chat room asking about something they read in this section, and old-timer community members say "we don't have conditions anymore", yielding confusion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's a "condition" in this context?


# `enum`

# Expressions

# Functions

Functions in Rust are introduced with the `fn` keyword, optional arguments are specified within parenthesis as comma separated `name: type` pairs, and `->` indicates the return type. You can ommit the return type for functions that do not return a value. Functions return the top level expression (note the return expression is not terminated with a semi colon).

~~~~
fn increment(i:int) -> (int) {
i + 1
}

fn main() {
let i = 7;

let k = increment(i); // k=8
}
~~~~

# Loops

## `if`

## `loop`

## `while`

# Operators

# Patterns

# Return values

# Statements

# Structs and Tuples: `struct`

# Variables

There are two types of variable in Rust:

* `immutable` - the value cannot be changed. Introduced with `let mut`.
* `mutable` - the value of can be changed. Introduced with `let`.

~~~~
fn main() {

let i = 7; // i Cannot be changed

let mut j = i +1; // j = 8

j = 9; // j can be changed

}
~~~~
Loading