Skip to content

Commit

Permalink
Ownership, Reference and Memory allocation with Dangling Problem.
Browse files Browse the repository at this point in the history
  • Loading branch information
faheemuzzaman committed Oct 13, 2019
1 parent 2a08034 commit 7a9cbe0
Show file tree
Hide file tree
Showing 25 changed files with 74 additions and 0 deletions.
6 changes: 6 additions & 0 deletions class04/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions class04/Cargo.toml
@@ -0,0 +1,9 @@
[package]
name = "class04"
version = "0.1.0"
authors = ["Admin <faheemuzzaman@hotmail.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
42 changes: 42 additions & 0 deletions class04/src/main.rs
@@ -0,0 +1,42 @@
// fn main() {
// let x = 10;
// let y = x;
// println!("{} ,{}",x,y);

// let s1 = String::from("Hello");
// let s2 = s1.clone();
// let s3 = &s1;

// let s4 = &s1;
// println!("{}, {}, {}, {}", s1, s2, s3, s4);
// // }
// fn main() {
// let s = String::from("hello");
// takes_ownership(s.clone());
// println!("{}",s);
// let x = 5;
// makes_copy(x);
// }
// fn takes_ownership(some_string: String) {
// println!("{}", some_string);
// }
// fn makes_copy(some_integer: i32) {
// println!("{}", some_integer);
// }

fn main() {
let s1 = gives_ownership();
let s2 = String::from("hello");
let s3 = takes_and_gives_back(s2);
println!("{}",s1);
println!("{}",s3);


}
fn gives_ownership() -> String {
let some_string = String::from("hello");
some_string
}
fn takes_and_gives_back(a_string: String) -> String {
a_string
}
1 change: 1 addition & 0 deletions class04/target/.rustc_info.json
@@ -0,0 +1 @@
{"rustc_fingerprint":9484594007537757877,"outputs":{"4476964694761187371":["___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\Admin\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\ndebug_assertions\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"pc\"\nwindows\n",""],"1164083562126845933":["rustc 1.37.0 (eae3437df 2019-08-13)\nbinary: rustc\ncommit-hash: eae3437dfe991621e8afdc82734f4a172d7ddf9b\ncommit-date: 2019-08-13\nhost: x86_64-pc-windows-msvc\nrelease: 1.37.0\nLLVM version: 8.0\n",""],"9311443727202421799":["___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\Admin\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\ndebug_assertions\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"pc\"\nwindows\n",""]},"successes":{}}
Empty file.
Binary file not shown.
@@ -0,0 +1 @@
This file has an mtime of when this was started.
@@ -0,0 +1 @@
d24ad2a210b2794b
@@ -0,0 +1 @@
{"rustc":16761476351873615079,"features":"[]","target":457681104562150112,"profile":1647870076477133176,"path":1036222786711178230,"deps":[],"local":[{"CheckDepInfo":{"dep_info":".fingerprint\\class04-288ce7719697c293\\dep-test-bin-class04-288ce7719697c293"}}],"rustflags":[],"metadata":11626969923688510520}
@@ -0,0 +1 @@
42d6f14e3daced75
@@ -0,0 +1 @@
{"rustc":16761476351873615079,"features":"[]","target":457681104562150112,"profile":14891217944882224483,"path":1036222786711178230,"deps":[],"local":[{"CheckDepInfo":{"dep_info":".fingerprint\\class04-e6cf225208f9f5ca\\dep-bin-class04-e6cf225208f9f5ca"}}],"rustflags":[],"metadata":11626969923688510520}
Binary file not shown.
@@ -0,0 +1 @@
This file has an mtime of when this was started.
5 changes: 5 additions & 0 deletions class04/target/debug/deps/class04-288ce7719697c293.d
@@ -0,0 +1,5 @@
c:\Users\Admin\Desktop\Rust\class04\target\debug\deps\class04-288ce7719697c293.rmeta: src\main.rs

c:\Users\Admin\Desktop\Rust\class04\target\debug\deps\class04-288ce7719697c293.d: src\main.rs

src\main.rs:
5 changes: 5 additions & 0 deletions class04/target/debug/deps/class04-e6cf225208f9f5ca.d
@@ -0,0 +1,5 @@
c:\Users\Admin\Desktop\Rust\class04\target\debug\deps\class04-e6cf225208f9f5ca.rmeta: src\main.rs

c:\Users\Admin\Desktop\Rust\class04\target\debug\deps\class04-e6cf225208f9f5ca.d: src\main.rs

src\main.rs:
Empty file.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.

0 comments on commit 7a9cbe0

Please sign in to comment.