OS in Rust
wc ongoing.THE KNOWLEDGE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF UNLEASHING INDESCRIBABLE HORRORS THAT SHATTER YOUR PSYCHE AND SET YOUR MIND ADRIFT IN THE UNKNOWABLY INFINITE COSMOS.
When implementation details start to matter in a safe programming language, programmers usually have three options:
Unfortunately, C is incredibly unsafe to use (sometimes for good reason), and this unsafety is magnified when trying to interoperate with another language. Care must be taken to ensure C and the other language agree on what’s happening, and that they don’t step on each other’s toes.
Rust can be thought of as a combination of two programming languages: Safe Rust and Unsafe Rust.
Rust’s memory safety guarantees enforced at compile time
rustc isn’t a theorem prover…Unsafe Rust is, well, not (safe). In fact, Unsafe Rust lets us do some really unsafe things. Things the Rust authors will implore you not to do, but we’ll do anyway.
stdstd is already implemented.std.* operator on) dangling or unaligned pointers (see below)& (borrow) and mut0 or 1 for a boolean.unions.unsafe block.Breaking the pointer aliasing rules. The exact aliasing rules are not determined yet, but here is an outline of the general principles:
Violating assumptions of the Rust runtime. Most assumptions of the Rust runtime are currently not explicitly documented.
&*const T or mutable *mut T.as keyword.
* operator. let mut num = 5;
let r1 = &raw const num;
let r2 = &raw mut num;
unsafe {
println!("r1 is: {}", *r1);
println!("r2 is: {}", *r2);
}src/main.rs
unsafe block.wc ongoing.