-
Notifications
You must be signed in to change notification settings - Fork 13.8k
'New Philosophical Tutorial' #14017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
'New Philosophical Tutorial' #14017
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
f8eb62f
Initial mess.
plaindocs 849dc68
Merge remote-tracking branch 'upstream/master'
plaindocs d81a403
Add new-tutorial.md and guide-syntax.md, some intial content.
brson 6c2215a
Examples now pass code tests.
plaindocs 232eb39
Some more text.
plaindocs a7c478a
WIP
plaindocs e02bb45
WIP
plaindocs 662915c
Iterating...
plaindocs 6528add
Iterating
plaindocs e88d274
Philosophy rewrite.
plaindocs 22a3b0e
Typo fixes
plaindocs b5e88a1
Where we're headed
plaindocs 4fcb05d
Editing
plaindocs 05af410
Edits
plaindocs cf72c64
Minor fixes for issues raised in https://github.com/mozilla/rust/pull…
plaindocs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
# `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 | ||
|
||
} | ||
~~~~ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?