summaryrefslogtreecommitdiff
path: root/advanced/unsafe-rust
diff options
context:
space:
mode:
authorAdam Carpenter <53hornet@gmail.com>2019-03-27 15:32:37 -0400
committerAdam Carpenter <53hornet@gmail.com>2019-03-27 15:32:37 -0400
commit67cdcc2e12118becb823e20a40cc2687f2b8425a (patch)
treeed92c3234b89079e6d4cf36f5e80c5ffa79def48 /advanced/unsafe-rust
parente25482fca375d318a39c3b54db396b0db6e0b263 (diff)
downloadlearning-rust-67cdcc2e12118becb823e20a40cc2687f2b8425a.tar.xz
learning-rust-67cdcc2e12118becb823e20a40cc2687f2b8425a.zip
Started Rust in Action MEAP.
Diffstat (limited to 'advanced/unsafe-rust')
-rw-r--r--advanced/unsafe-rust/Cargo.lock4
-rw-r--r--advanced/unsafe-rust/Cargo.toml7
-rw-r--r--advanced/unsafe-rust/src/main.rs62
3 files changed, 0 insertions, 73 deletions
diff --git a/advanced/unsafe-rust/Cargo.lock b/advanced/unsafe-rust/Cargo.lock
deleted file mode 100644
index fbd902c..0000000
--- a/advanced/unsafe-rust/Cargo.lock
+++ /dev/null
@@ -1,4 +0,0 @@
-[[package]]
-name = "unsafe-rust"
-version = "0.1.0"
-
diff --git a/advanced/unsafe-rust/Cargo.toml b/advanced/unsafe-rust/Cargo.toml
deleted file mode 100644
index b37474a..0000000
--- a/advanced/unsafe-rust/Cargo.toml
+++ /dev/null
@@ -1,7 +0,0 @@
-[package]
-name = "unsafe-rust"
-version = "0.1.0"
-authors = ["Adam Carpenter <53hornet@gmail.com>"]
-edition = "2018"
-
-[dependencies]
diff --git a/advanced/unsafe-rust/src/main.rs b/advanced/unsafe-rust/src/main.rs
deleted file mode 100644
index c9967a8..0000000
--- a/advanced/unsafe-rust/src/main.rs
+++ /dev/null
@@ -1,62 +0,0 @@
-fn main() {
- let mut num = 5;
-
- let r1 = &num as *const i32;
- let r2 = &mut num as *mut i32;
-
- let address = 0x012345usize;
- let r = address as *const i32;
-
- unsafe {
- println!("{}", *r1);
- println!("{}", *r2);
- }
-
- unsafe {
- dangerous();
- }
-
-
- unsafe {
- println!("c call: {}", abs(-3));
- }
-
-
- unsafe {
- HELLO_WORLD = "test";
- println!("{}", HELLO_WORLD);
- }
- println!("{}", HI_THERE);
-
- add_to_count(3);
-
- unsafe {
- println!("counter: {}", COUNTER);
- }
-}
-
-unsafe fn dangerous() {}
-
-extern "C" {
- fn abs(input: i32) -> i32;
-}
-
-static mut HELLO_WORLD: &str = "hello world";
-static mut COUNTER: u32 = 0;
-
-fn add_to_count(inc: u32) {
- unsafe {
- COUNTER += inc;
- }
-}
-
-const HI_THERE: &str = "hi there";
-
-unsafe trait Foo {
- // methods
-}
-
-unsafe impl Foo for i32 {
- // implementations
-}
-