initial commit
This commit is contained in:
commit
3814503bde
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
8
.idea/.gitignore
vendored
Normal file
8
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/variable_stuff.iml" filepath="$PROJECT_DIR$/.idea/variable_stuff.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
11
.idea/variable_stuff.iml
Normal file
11
.idea/variable_stuff.iml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="CPP_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "variable_stuff"
|
||||
version = "0.1.0"
|
8
Cargo.toml
Normal file
8
Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "variable_stuff"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
90
src/main.rs
Normal file
90
src/main.rs
Normal file
@ -0,0 +1,90 @@
|
||||
use std::io;
|
||||
|
||||
const THREE_HOURS_IN_SECONDS: u32 = 60 * 60 * 3;
|
||||
|
||||
fn main() {
|
||||
let mut x = 5;
|
||||
println!("The value of x is: {x}");
|
||||
x = 6;
|
||||
println!("The value of x is: {x}");
|
||||
|
||||
println!("{THREE_HOURS_IN_SECONDS}");
|
||||
|
||||
let z = 5;
|
||||
|
||||
let z = z + 1;
|
||||
|
||||
{
|
||||
let z = z * 2;
|
||||
println!("The value of z in the inner scope is: {z}");
|
||||
}
|
||||
|
||||
println!("The value of z is: {z}");
|
||||
|
||||
let spaces = " ";
|
||||
let spaces = spaces.len();
|
||||
println!("{spaces}");
|
||||
|
||||
let glert: u32 = "42".parse().expect("Not a number!");
|
||||
println!("{glert}");
|
||||
|
||||
let q = 2.76; // f64
|
||||
let r: f32 = 3.11; // f32
|
||||
let s = 4.0;
|
||||
println!("{q}");
|
||||
println!("{r}");
|
||||
println!("{s}"); // why is this printing as if it were an integer?
|
||||
|
||||
// addition
|
||||
let sum = 5 + 10;
|
||||
println!("SUM: {sum}");
|
||||
|
||||
// subtraction
|
||||
let difference = 95.5 - 4.3;
|
||||
println!("DIFF: {difference}");
|
||||
|
||||
// multiplication
|
||||
let product = 4 * 30;
|
||||
println!("PROD: {product}");
|
||||
|
||||
// division
|
||||
let quotient = 56.7 / 32.2;
|
||||
let floored = 2 / 3; // Results in 0
|
||||
println!("QUOT: {quotient}");
|
||||
println!("FLOOR: {floored}");
|
||||
|
||||
// remainder
|
||||
let remainder = 43 % 5;
|
||||
println!("MOD: {remainder}");
|
||||
|
||||
let tup = (500, 6.4, "cowherd");
|
||||
let (m, n, o) = tup;
|
||||
println!("The value of M is: {m}");
|
||||
println!("The value of N is: {n}");
|
||||
println!("The value of O is: {o}");
|
||||
|
||||
let months = ["January", "February", "March", "April", "May", "June", "July",
|
||||
"August", "September", "October", "November", "December"];
|
||||
for mn in months {
|
||||
println!("{mn}");
|
||||
}
|
||||
|
||||
let j = [1, 2, 3, 4, 5];
|
||||
|
||||
println!("Please enter an array index.");
|
||||
|
||||
let mut index = String::new();
|
||||
|
||||
io::stdin()
|
||||
.read_line(&mut index)
|
||||
.expect("Failed to read line");
|
||||
|
||||
let index: usize = index
|
||||
.trim()
|
||||
.parse()
|
||||
.expect("Index entered was not a number");
|
||||
|
||||
let element = j[index];
|
||||
|
||||
println!("The value of the element at index {index} is: {element}");
|
||||
}
|
Loading…
Reference in New Issue
Block a user