rust-examples
Rust-examples is a repository to gather example codes from tutorial and other documentations of Rust into files, ready to compile.
Examples are tested with version 0.10-pre.
Files
- Homepage
what_it_looks_like.rs
- Tutorial
- 2.1 Compiling your first program:
tutorial-02_1-hello.rs
- 3 Syntax basics:
tutorial-03-syntax_basics.rs
- 4.2 Pattern matching:
tutorial-04_2-pattern-matching.rs
- 4.3 Loops (
for
,while
,loop
):tutorial-04_3-loops.rs
- 5.1 Structs:
tutorial-05_1-structs.rs
- 5.2 Enums:
tutorial-05_2-enum.rs
- 5.3 Tuples:
tutorial-05_3-tuples.rs
- 15 Closures:
tutorial-15-closure.rs
- 15.3 Do syntax:
tutorial-15_3-do.rs
- 16 Methods, with constructor:
tutorial-16-methods.rs
- 17 Generics:
tutorial-17-generics.rs
- 2.1 Compiling your first program:
- Rust Tasks and Communication
- 2 Basics:
tutorial-tasks-02-basics.rs
- 2.1 Communication:
tutorial-tasks-02_1-communication.rs
- 2.2 Backgrounding computations: Futures:
tutorial-tasks-02_2-backgrounding_computations.rs
- 2 Basics:
- Doc unit testing
- Unit testing in Rust:
unittests.rs
- Unit testing in Rust:
- API
- Program to an 'interface', not an 'implementation', by Josh Davis:
lang-interface.rs
- Lambda expressions:
lang-lambda.rs
- Pointer snippets from Dave Herman's talk:
lang-pointers.rs
- getopts:
api-getopts.rs
- std::from_str::FromStr:
api-std-from_str.rs
- std::hashmap::HashMap:
api-std-hashmap.rs
- std::io::File:
api-std-io-file.rs
- std::vec: OwnedVector, 2D-arrays, ...:
api-std-vec.rs
- Program to an 'interface', not an 'implementation', by Josh Davis:
- Some new files:
Makefile
to compile, run tests and run benchmarks.travis.yml
to add the repository to Travis CI and Rust CI- A library and its unit tests and benchmarks for 2 Fibonacci functions (a reccursive and a non reccursive):
fibonacci.rs
- A struct to manage dates:
date.rs
- A struct to manage INI files:
inifile.rs
- Design pattern Decorator:
design_pattern-decorator.rs
Compile and running it
You will need the version 0.10-pre of the rust compiler. If you encounter problems, make sure you have the right version before creating an issue.
The simplest way to build rust-examples is to do a clone and use make
to compile:
git clone https://github.com/eliovir/rust-examples
cd rust-examples
make
To run tests and benchmarks:
make tests
make bench
To get help on commands:
make help
Contributing
- Fork it (
git clone https://github.com/eliovir/rust-examples
) - Create your feature branch (
git checkout -b my-new-feature
) - Make your changes, and add tests for them
- Test your changes (
make test
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
License
Rust is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.
These codes are distributed under the MIT license.
See LICENSE for details.