remove exclamation mark from string-program

This commit is contained in:
Mahdi Dibaiee 2022-06-28 15:45:26 +01:00
parent da24cc1f50
commit 0facc24fa7
7 changed files with 40 additions and 2 deletions

8
Cargo.lock generated
View File

@ -204,6 +204,10 @@ dependencies = [
"bitflags",
]
[[package]]
name = "refcell-program"
version = "0.1.0"
[[package]]
name = "rustc-demangle"
version = "0.1.21"
@ -273,6 +277,10 @@ version = "0.1.0"
name = "stack-program"
version = "0.1.0"
[[package]]
name = "str-program"
version = "0.1.0"
[[package]]
name = "string-dhat"
version = "0.1.0"

View File

@ -1,2 +1,2 @@
[workspace]
members = ["stack-program", "stack-and-heap-program", "string-program", "box-str-program", "string-dhat", "box-str-dhat"]
members = ["stack-program", "stack-and-heap-program", "string-program", "box-str-program", "string-dhat", "box-str-dhat", "refcell-program", "str-program"]

View File

@ -0,0 +1,4 @@
[package]
name = "refcell-program"
version = "0.1.0"
edition = "2021"

View File

@ -0,0 +1,9 @@
use std::cell::RefCell;
fn main() {
let refcell_str: RefCell<&str> = RefCell::new("hello");
println!("refcell_str");
let second = refcell_str.clone();
println!("refcell_str second:");
}

4
str-program/Cargo.toml Normal file
View File

@ -0,0 +1,4 @@
[package]
name = "str-program"
version = "0.1.0"
edition = "2021"

13
str-program/src/main.rs Normal file
View File

@ -0,0 +1,13 @@
const NAME: &str = "asqar";
fn hello() -> u8 {
let hello = NAME;
println!("hello {}", hello);
0
}
fn main() {
for _ in 1..5 {
let v = hello();
}
}

View File

@ -1,5 +1,5 @@
fn main() {
let s = String::from("hello!");
let s = String::from("hello");
println!("{}", s);
println!("size of string on stack: {}", std::mem::size_of_val(&s));
}