Hi all, I’m very new to Rust, so I’ll not be disappointed if someone will explain me that this idea is a nonsense.
When I see this code:
use std::rc::Rc;
use std::sync::Arc;
fn main() {
let a: Box<i32> = box 1;
let b: Rc<i32> = Rc::new(2);
let c: Arc<i32> = Arc::new(3);
println!("a = {}, b = {}, c = {}", *a, *b, *c);
}
I think: if box
is something like a syntactic sugar for something like Box::new
, why not generalize the boxing concept to other pointers too? Something similar to the *
operator in the opposite sense.
That could be valuable for example to switch between Rc
and Arc
without involving macros.