OS in Rust
wc, is ready now.
I think failing my systems class was the best thing that happened to me.
This course demanded strong self-motivation… Thus, I didn’t learn as much as I might’ve if grading mattered more.
| Grade | Requirements |
|---|---|
| A | Final meets spec |
| A | 90% ave HW/Lab/Midterm, Final compiles |
| A- | 90% ave HW/Lab, Midterm/Final compile |
| A- | Midterm meets spec, Final compiles |
| Grade | Requirements |
|---|---|
| B+ | 90% ave HW/Lab, Midterm compiles |
| B | 80% ave HW/Lab, Midterm compiles |
| B- | 80% ave HW/Lab |
| Grade | Requirements |
|---|---|
| C | 80% ave Lab |
| D | 60% ave Lab |
| F | Anything else |
After ~10 years of systems research I’ve convinced myself only two things really matter:
Recursion isn’t too bad…
vimvim or another console-based editor as a component of your learning in this class.vim probably.
Union[None,x] \(\forall x\)?cargo rstdstdvec! from stdlambda keyword.fn add_one_v1 (x: u32) -> u32 { x + 1 }
let add_one_v2 = |x: u32| -> u32 { x + 1 };
let add_one_v3 = |x| { x + 1 };
let add_one_v4 = |x| x + 1 ;fn’s, not even people who actually know Rust!fn main() {
let s = "Hello, world";
match s.chars().nth(11) {
Some(c) => println!("The 11th character is {:?}", c),
None => println!("String `s` is fewer than 11 characters in length"),
}
}print!, println!, and format! are all nice ways to work with strings.format!("test"); // => "test"
format!("hello {}", "world!"); // => "hello world!"
format!("x = {}, y = {val}", 10, val = 30); // => "x = 10, y = 30"
let (x, y) = (1, 2);
format!("{x} + {y} = 3"); // => "1 + 2 = 3"u8 which was a fixed size.// String of length 0
let s = "";
// Complete text of Bhagavad Gita
let t = "Dhritarashtra said: O Sanjay, after gathering on the holy field of Kurukshetra, and desiring to fight, what did my sons and the sons of Pandu do? ...{ // s is not valid here, since it's not yet declared
let s = "hello"; // s is valid from this point forward
// do stuff with s
} // this scope is now over, and s is no longer valids exists at some time points, but not others.String is closer to data structure than a data type in some ways: let mut s = String::from("hello");
s.push_str(", world!"); // push_str() appends a literal to a String
println!("{s}"); // this will print `hello, world!`String is mutable, a literal is not.s passes “out of scope” once its value is assigned to t.s.String::from("6") isn’t a fixed width string of lenth 1 (to me at least).Whenever I use Rust, I just always
.cloneand when someone asks me about it, I say that’s a performance optimization for latter.
.clone on capital S String for e.g. Wordle, as needed..clone (you don’t need it)