Flatten nested Rust projects into monorepo
This commit is contained in:
7
data_types/Cargo.lock
generated
Normal file
7
data_types/Cargo.lock
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "data_types"
|
||||
version = "0.1.0"
|
6
data_types/Cargo.toml
Normal file
6
data_types/Cargo.toml
Normal file
@@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "data_types"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
35
data_types/src/main.rs
Normal file
35
data_types/src/main.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
use std::io;
|
||||
|
||||
fn main() {
|
||||
let tup: (u32, f64, i8) = (500, 420.69, 1); // different types
|
||||
let fiveh = tup.0;
|
||||
let fourtw = tup.1;
|
||||
let one = tup.2;
|
||||
let (x, y, z) = tup;
|
||||
|
||||
let nums: [i32; 5] = [1, 2, 3, 4, 5]; // only one data type
|
||||
let a = [3; 5]; // same as
|
||||
// let a = [3, 3, 3, 3, 3];
|
||||
|
||||
let first = nums[0];
|
||||
let second = nums[1];
|
||||
|
||||
|
||||
let a = [1, 2, 3, 4, 5];
|
||||
|
||||
println!("Type an 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 wasn't a valid numver");
|
||||
|
||||
let element = a[index];
|
||||
|
||||
println!("The element for the index {index} is: {element}");
|
||||
}
|
Reference in New Issue
Block a user