#[test]
fn test_destructor() {
- let x: Rc<Box<_>> = Rc::new(box 5);
+ let x: Rc<Box<_>> = Rc::new(Box::new(5));
assert_eq!(**x, 5);
}
#[test]
fn into_from_raw() {
- let x = Rc::new(box "hello");
+ let x = Rc::new(Box::new("hello"));
let y = x.clone();
let x_ptr = Rc::into_raw(x);
#[test]
fn into_from_weak_raw() {
- let x = Rc::new(box "hello");
+ let x = Rc::new(Box::new("hello"));
let y = Rc::downgrade(&x);
let y_ptr = Weak::into_raw(y);
#[test]
fn test_from_box() {
- let b: Box<u32> = box 123;
+ let b: Box<u32> = Box::new(123);
let r: Rc<u32> = Rc::from(b);
assert_eq!(*r, 123);
use std::fmt::Display;
use std::string::ToString;
- let b: Box<dyn Display> = box 123;
+ let b: Box<dyn Display> = Box::new(123);
let r: Rc<dyn Display> = Rc::from(b);
assert_eq!(r.to_string(), "123");
fn test_from_box_trait_zero_sized() {
use std::fmt::Debug;
- let b: Box<dyn Debug> = box ();
+ let b: Box<dyn Debug> = Box::new(());
let r: Rc<dyn Debug> = Rc::from(b);
assert_eq!(format!("{r:?}"), "()");