Boxes behave similar to references. Auto deference in many situations, but sometimes a * is required.

This commit is contained in:
Stephan Rehfeld 2026-05-27 17:58:08 +02:00
parent 58a9c36d0d
commit 8cd294c44a

View File

@ -1,14 +1,22 @@
use hello::geometry::Geometry; use hello::geometry::Geometry;
use hello::math::{Mat4x4, Point3}; use hello::math::{Mat4x4, Point3};
/*
enum SceneGraphNode { enum SceneGraphNode {
Geometry(Mat4x4, Geometry), Geometry(Mat4x4, Geometry),
SubNode(Mat4x4, SceneGraphNode), SubNode(Mat4x4, SceneGraphNode),
} }
*/
fn main() { fn main() {
let p1 = Point3::new(0.0, 0.0, 0.0); let v1 = 5;
let p2 = Point3::new(0.0, 0.0, 0.0); let v2 = &v1;
let v3 = Box::new(v1);
let v = p1 - p2; println!("v1: {}", v1);
println!("v2: {}", v2);
println!("v3: {}", v3);
assert_eq!(v1, *v2);
assert_eq!(v1, *v3);
} }