Boxes behave similar to references. Auto deference in many situations, but sometimes a * is required.
This commit is contained in:
parent
58a9c36d0d
commit
8cd294c44a
14
src/main.rs
14
src/main.rs
@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user