Browse Source

Added LICENSE and README

master
Saura Sambit 1 year ago
parent
commit
2f84dc415f
2 changed files with 78 additions and 0 deletions
  1. +22
    -0
      LICENSE
  2. +56
    -0
      README.md

+ 22
- 0
LICENSE View File

@ -0,0 +1,22 @@
Copyright (c) 2019, Saura Sambit. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ 56
- 0
README.md View File

@ -0,0 +1,56 @@
#The Rust Programming Language
######Setting up a new project
```
cargo new project_name
cd project_name
```
######Compile and run the project
```
cargo run
```
######I/O Binary
```
use std::io;
```
######Program entry point
```
fn main() {}
```
######Println is a not a fn but a macro is RUST, so we use an `!`
```
println!();
```
######Variables are immutable by default, so we use `mut`
```
let mut var_name = String::new();
```
######Building without compiling
```
cargo build
```
######Comparing two values
```
use std::cmp::Ordering;
match var1.cmp(var2) {
Ordering::Less => println!("Too small!),
Ordering::Greater => println!("Too bog!"),
Ordering::Equal => println!("Equal!"),
}
```
######Converting String input to Integer
```
let num: u32 = num.trim().parse().expect("Please type a number!");
```
######Looping
```
loop {
//code to be repeated
}
```
######Handling invalid input
```
let var: u32 = match var.trim().parse() {
Ok(num) => num,
Err(_) => continue,
};
```

Loading…
Cancel
Save