3 ms·
If OP is here, then in this listing: let boxed_str: Box<str> = "hello".into(); println!("size of boxed_str on stack: {}", std::mem::size_of_val(&boxed_
by OJFord 4y ago
If OP is here, then in this listing:
let boxed_str: Box<str> = "hello".into();
println!("size of boxed_str on stack: {}", std::mem::size_of_val(&boxed_str));
let s = String::from("hello!");
println!("size of string on stack: {}", std::mem::size_of_val(&s));
I know it's not the point and doesn't make a difference, but you might want to make the two 'strings' the same (not with & without '!'), just to be clearer.