You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use std::rc::Rc;use std::sync::Arc;structData{a:u64,b:u64,}fnadd_numbers(p:&Data) -> u64{
p.a + p.b}pubfnadd_two_numbers_arc(a:u64,b:u64) -> u64{let x = Arc::new(Data{ a, b });add_numbers(&x)}pubfnadd_two_numbers_rc(a:u64,b:u64) -> u64{let x = Rc::new(Data{ a, b });add_numbers(&x)}
I tried this code:
godbolt link
I expected to see this happen: The heap allocation of both the
Rc
and theArc
should be optimized out.Instead, this happened: Only
Rc
got the optimization.The text was updated successfully, but these errors were encountered: