Scene

Struct Scene 

Source
pub struct Scene {
    pub objects: Vec<Box<dyn Object>>,
    pub lights: Vec<Box<dyn Sampleable>>,
    pub medium: Option<Medium>,
}
Expand description

Defines a scene in 3D space

Fields§

§objects: Vec<Box<dyn Object>>

All of the objects in the scene.

§lights: Vec<Box<dyn Sampleable>>

Contains all lights in the scene.

§medium: Option<Medium>

Medium that the scene is filled with

Implementations§

Source§

impl Scene

Source

pub fn empty_box( def_color: Color, mat_left: Material, mat_right: Material, ) -> Self

Constructs an empty “Cornell box”. Middle of the box is at (0.0, 0.0, -1.0) and it has dimensions 2x2x2. Perfect for the default camera.

§Arguments
  • def_color - Color of the roof, and the front wall
  • mat_left - Material of the left wall
  • mat_right - Material of the right wall
Examples found in repository?
examples/bunny.rs (lines 9-13)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7    let camera = Camera::default(1024, 768);
8    let def_color = Color::new(242, 242, 242);
9    let mut scene = Scene::empty_box(
10        def_color,
11        Material::diffuse(Texture::Solid(Color::new(255, 0, 0))),
12        Material::diffuse(Texture::Solid(Color::new(0, 255, 0))),
13    );
14
15    scene.add(
16        parser::mesh_from_url(
17            BUNNY_URL,
18            Material::transparent(
19                Texture::Solid(Color::new(0, 255, 0)),
20                0.1,
21                1.5,
22            ),
23        )?
24        .scale(0.3, 0.3, 0.3)
25        .translate(0.0, -0.65, -1.5),
26    );
27
28    let renderer = Renderer::new(scene, camera);
29    renderer.render().save("bunny.png")?;
30    Ok(())
31}
More examples
Hide additional examples
examples/dragon.rs (lines 9-13)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7    let camera = Camera::default(1024, 768);
8    let def_color = Color::new(242, 242, 242);
9    let mut scene = Scene::empty_box(
10        def_color,
11        Material::diffuse(Texture::Solid(Color::new(255, 0, 0))),
12        Material::diffuse(Texture::Solid(Color::new(0, 255, 0))),
13    );
14
15    scene.add(
16        parser::mesh_from_url(
17            DRAGON_URL,
18            Material::transparent(
19                Texture::Solid(Color::new(255, 0, 255)),
20                0.03,
21                1.5,
22            ),
23        )?
24        .to_unit_size()
25        .to_origin()
26        .rotate_y(5.0 * PI / 8.0)
27        .scale(1.3, 1.3, 1.3)
28        .translate(0.0, -0.35, -1.4)
29    );
30
31    let renderer = Renderer::new(scene, camera);
32    renderer.render().save("dragon.png")?;
33    Ok(())
34}
examples/teapot.rs (lines 9-13)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7    let camera = Camera::default(1024, 768);
8    let def_color = Color::new(242, 242, 242);
9    let mut scene = Scene::empty_box(
10        def_color,
11        Material::diffuse(Texture::Solid(Color::new(255, 0, 0))),
12        Material::diffuse(Texture::Solid(Color::new(0, 255, 0))),
13    );
14
15    scene.add(
16        parser::mesh_from_url(
17            TEAPOT_URL,
18            Material::transparent(
19                Texture::Marble(Perlin::default(), Color::new(255, 245, 255)),
20                0.0,
21                1.5,
22            ),
23        )?
24            .to_unit_size()
25            .to_origin()
26            .rotate_y(PI / 4.0)
27            .translate(-0.3, -0.5, -1.3),
28    );
29
30    let renderer = Renderer::new(scene, camera);
31    renderer.render().save("teapot.png")?;
32    Ok(())
33}
examples/box.rs (lines 7-13)
4fn main() -> Result<(), std::io::Error> {
5    let camera = Camera::default(1024, 768);
6    let def_color = Color::new(242, 242, 242);
7    let mut scene = Scene::empty_box(
8        def_color,
9        // left
10        Material::diffuse(Texture::Solid(Color::new(255, 0, 255))),
11        // right
12        Material::diffuse(Texture::Solid(Color::new(0, 255, 255))),
13    );
14
15    scene.add(Sphere::new(
16        Vec3::new(-0.45, -0.5, -1.5),
17        0.25,
18        Material::metallic(
19            Texture::Solid(Color::WHITE),
20            0.0,
21        )
22    ));
23
24    scene.add(Sphere::new(
25        Vec3::new(0.45, -0.5, -1.3),
26        0.25,
27        Material::transparent(
28            Texture::Solid(Color::WHITE),
29            0.0,
30            2.5,
31        ),
32    ));
33
34    let renderer = Renderer::new(scene, camera);
35    renderer.render().save("box.png")?;
36    Ok(())
37}
Source§

impl Scene

Source

pub fn add(&mut self, obj: Box<dyn Object>)

Add a non-light object to the scene

Examples found in repository?
examples/bunny.rs (lines 15-26)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7    let camera = Camera::default(1024, 768);
8    let def_color = Color::new(242, 242, 242);
9    let mut scene = Scene::empty_box(
10        def_color,
11        Material::diffuse(Texture::Solid(Color::new(255, 0, 0))),
12        Material::diffuse(Texture::Solid(Color::new(0, 255, 0))),
13    );
14
15    scene.add(
16        parser::mesh_from_url(
17            BUNNY_URL,
18            Material::transparent(
19                Texture::Solid(Color::new(0, 255, 0)),
20                0.1,
21                1.5,
22            ),
23        )?
24        .scale(0.3, 0.3, 0.3)
25        .translate(0.0, -0.65, -1.5),
26    );
27
28    let renderer = Renderer::new(scene, camera);
29    renderer.render().save("bunny.png")?;
30    Ok(())
31}
More examples
Hide additional examples
examples/hello_sphere.rs (lines 8-12)
4fn main() -> Result<(), png::EncodingError> {
5    let camera = Camera::default(1280, 720);
6    let mut scene = Scene::default();
7
8    scene.add(Plane::new(
9        Vec3::NEG_Y,
10        Vec3::Y,
11        Material::diffuse(Texture::Solid(Color::new(190, 200, 210))),
12    ));
13
14    scene.add_light(Sphere::new(
15        8.0 * Vec3::Y + 1.5 * Vec3::NEG_Z,
16        4.0,
17        Material::Light(Texture::Solid(Color::WHITE)),
18    ));
19
20    scene.add(
21        Sphere::new(
22            Vec3::ZERO,
23            1.0,
24            Material::diffuse(Texture::Solid(Color::new(0, 0, 255))),
25        )
26        .scale(0.3, 0.3, 0.3)
27        .translate(0.0, -0.7, -1.5),
28    );
29
30    let mut renderer = Renderer::new(scene, camera);
31    renderer.set_samples(36);
32    renderer.render().save("hello.png")
33}
examples/dragon.rs (lines 15-29)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7    let camera = Camera::default(1024, 768);
8    let def_color = Color::new(242, 242, 242);
9    let mut scene = Scene::empty_box(
10        def_color,
11        Material::diffuse(Texture::Solid(Color::new(255, 0, 0))),
12        Material::diffuse(Texture::Solid(Color::new(0, 255, 0))),
13    );
14
15    scene.add(
16        parser::mesh_from_url(
17            DRAGON_URL,
18            Material::transparent(
19                Texture::Solid(Color::new(255, 0, 255)),
20                0.03,
21                1.5,
22            ),
23        )?
24        .to_unit_size()
25        .to_origin()
26        .rotate_y(5.0 * PI / 8.0)
27        .scale(1.3, 1.3, 1.3)
28        .translate(0.0, -0.35, -1.4)
29    );
30
31    let renderer = Renderer::new(scene, camera);
32    renderer.render().save("dragon.png")?;
33    Ok(())
34}
examples/teapot.rs (lines 15-28)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7    let camera = Camera::default(1024, 768);
8    let def_color = Color::new(242, 242, 242);
9    let mut scene = Scene::empty_box(
10        def_color,
11        Material::diffuse(Texture::Solid(Color::new(255, 0, 0))),
12        Material::diffuse(Texture::Solid(Color::new(0, 255, 0))),
13    );
14
15    scene.add(
16        parser::mesh_from_url(
17            TEAPOT_URL,
18            Material::transparent(
19                Texture::Marble(Perlin::default(), Color::new(255, 245, 255)),
20                0.0,
21                1.5,
22            ),
23        )?
24            .to_unit_size()
25            .to_origin()
26            .rotate_y(PI / 4.0)
27            .translate(-0.3, -0.5, -1.3),
28    );
29
30    let renderer = Renderer::new(scene, camera);
31    renderer.render().save("teapot.png")?;
32    Ok(())
33}
examples/box.rs (lines 15-22)
4fn main() -> Result<(), std::io::Error> {
5    let camera = Camera::default(1024, 768);
6    let def_color = Color::new(242, 242, 242);
7    let mut scene = Scene::empty_box(
8        def_color,
9        // left
10        Material::diffuse(Texture::Solid(Color::new(255, 0, 255))),
11        // right
12        Material::diffuse(Texture::Solid(Color::new(0, 255, 255))),
13    );
14
15    scene.add(Sphere::new(
16        Vec3::new(-0.45, -0.5, -1.5),
17        0.25,
18        Material::metallic(
19            Texture::Solid(Color::WHITE),
20            0.0,
21        )
22    ));
23
24    scene.add(Sphere::new(
25        Vec3::new(0.45, -0.5, -1.3),
26        0.25,
27        Material::transparent(
28            Texture::Solid(Color::WHITE),
29            0.0,
30            2.5,
31        ),
32    ));
33
34    let renderer = Renderer::new(scene, camera);
35    renderer.render().save("box.png")?;
36    Ok(())
37}
examples/circle.rs (lines 32-36)
16fn main() -> Result<(), std::io::Error> {
17    let camera = Camera::perspective(
18        Vec3::new(0.0, 1.5, 1.5),
19        Vec3::ZERO,
20        Vec3::new(0.0, 1.0, -1.0),
21        90.0,
22        0.0,
23        0.0,
24        1024,
25        768,
26    );
27
28    let mut scene = Scene::default();
29    let ground = -0.2;
30
31    // ground
32    scene.add(Plane::new(
33        ground * Vec3::Y,
34        Vec3::Y,
35        Material::metallic(Texture::Solid(Color::new(150, 40, 39)), 0.009999),
36    ));
37
38    let r = 0.2;
39    scene.add_light(Sphere::new(
40        Vec3::new(0.0, ground + r + 0.1, 0.0),
41        r,
42        Material::Light(Texture::Solid(Color::WHITE)),
43    ));
44
45    let circle_s = 8;
46    let offset = PI / circle_s as Float;
47
48    for i in 0..circle_s {
49        let theta = (i as Float / circle_s as Float) * 2.0 * PI + offset;
50        let x = theta.cos();
51        let y = ground + r;
52        let z = theta.sin();
53
54        scene.add(Sphere::new(
55            Vec3::new(x, y, z),
56            r,
57            Material::specular(Texture::Solid(hsv_to_rgb(theta - offset)), 0.2),
58        ));
59    }
60
61    scene.set_medium(
62        Medium::new(
63            Vec3::new(0.002, 0.003, 0.0001),
64            Vec3::new(0.175, 0.125, 0.11),
65            0.9,
66        )
67    );
68
69    let renderer = Renderer::new(scene, camera);
70    renderer.render().save("circle.png")?;
71
72    Ok(())
73}
Source

pub fn add_light(&mut self, light: Box<dyn Sampleable>)

Adds a light to the scene

Examples found in repository?
examples/fireplace.rs (lines 21-25)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let camera = Camera::perspective(
9        Vec3::new(4.0, 1.0, -3.0),
10        0.5 * Vec3::Y,
11        Vec3::Y,
12        90.0,
13        0.0,
14        1.0,
15        1024,
16        768,
17    );
18
19    let mut scene = parser::scene_from_url(SCENE_URL, SCENE_NAME)?;
20
21    scene.add_light(Sphere::new(
22        Vec3::new(2.0, 1.5, -2.0),
23        0.3,
24        Material::Light(Texture::Solid(Color::WHITE)),
25    ));
26
27    let renderer = Renderer::new(scene, camera);
28    renderer.render().save("fireplace.png")?;
29
30    Ok(())
31}
More examples
Hide additional examples
examples/conference.rs (lines 21-25)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let camera = Camera::perspective(
9        Vec3::new(-50.0, 400.0, -350.0),
10        500.0 * Vec3::X + 250.0 * Vec3::Z,
11        Vec3::Y,
12        90.0,
13        0.0,
14        1.0,
15        1024,
16        768,
17    );
18
19    let mut scene = parser::scene_from_url(SCENE_URL, SCENE_NAME)?;
20
21    scene.add_light(Sphere::new(
22        Vec3::new(-200.0, 40.0, -400.0),
23        100.0,
24        Material::Light(Texture::Solid(Color::WHITE)),
25    ));
26
27    scene.add_light(Sphere::new(
28        Vec3::new(900.0, 300.0, -600.0),
29        100.0,
30        Material::Light(Texture::Solid(Color::WHITE)),
31    ));
32
33    let renderer = Renderer::new(scene, camera);
34    renderer.render().save("conference.png")?;
35
36    Ok(())
37}
examples/hello_sphere.rs (lines 14-18)
4fn main() -> Result<(), png::EncodingError> {
5    let camera = Camera::default(1280, 720);
6    let mut scene = Scene::default();
7
8    scene.add(Plane::new(
9        Vec3::NEG_Y,
10        Vec3::Y,
11        Material::diffuse(Texture::Solid(Color::new(190, 200, 210))),
12    ));
13
14    scene.add_light(Sphere::new(
15        8.0 * Vec3::Y + 1.5 * Vec3::NEG_Z,
16        4.0,
17        Material::Light(Texture::Solid(Color::WHITE)),
18    ));
19
20    scene.add(
21        Sphere::new(
22            Vec3::ZERO,
23            1.0,
24            Material::diffuse(Texture::Solid(Color::new(0, 0, 255))),
25        )
26        .scale(0.3, 0.3, 0.3)
27        .translate(0.0, -0.7, -1.5),
28    );
29
30    let mut renderer = Renderer::new(scene, camera);
31    renderer.set_samples(36);
32    renderer.render().save("hello.png")
33}
examples/circle.rs (lines 39-43)
16fn main() -> Result<(), std::io::Error> {
17    let camera = Camera::perspective(
18        Vec3::new(0.0, 1.5, 1.5),
19        Vec3::ZERO,
20        Vec3::new(0.0, 1.0, -1.0),
21        90.0,
22        0.0,
23        0.0,
24        1024,
25        768,
26    );
27
28    let mut scene = Scene::default();
29    let ground = -0.2;
30
31    // ground
32    scene.add(Plane::new(
33        ground * Vec3::Y,
34        Vec3::Y,
35        Material::metallic(Texture::Solid(Color::new(150, 40, 39)), 0.009999),
36    ));
37
38    let r = 0.2;
39    scene.add_light(Sphere::new(
40        Vec3::new(0.0, ground + r + 0.1, 0.0),
41        r,
42        Material::Light(Texture::Solid(Color::WHITE)),
43    ));
44
45    let circle_s = 8;
46    let offset = PI / circle_s as Float;
47
48    for i in 0..circle_s {
49        let theta = (i as Float / circle_s as Float) * 2.0 * PI + offset;
50        let x = theta.cos();
51        let y = ground + r;
52        let z = theta.sin();
53
54        scene.add(Sphere::new(
55            Vec3::new(x, y, z),
56            r,
57            Material::specular(Texture::Solid(hsv_to_rgb(theta - offset)), 0.2),
58        ));
59    }
60
61    scene.set_medium(
62        Medium::new(
63            Vec3::new(0.002, 0.003, 0.0001),
64            Vec3::new(0.175, 0.125, 0.11),
65            0.9,
66        )
67    );
68
69    let renderer = Renderer::new(scene, camera);
70    renderer.render().save("circle.png")?;
71
72    Ok(())
73}
examples/nefertiti.rs (lines 103-108)
8fn main() -> Result<(), Box<dyn std::error::Error>> {
9    let mut scene = Scene::default();
10
11    /* floor */
12    scene.add(Plane::new(
13        Vec3::NEG_Y,
14        Vec3::Y,
15        Material::diffuse(Texture::Solid(Color::BLACK))
16    ));
17
18    /* roof */
19    scene.add(Plane::new(
20        Vec3::Y,
21        Vec3::NEG_Y,
22        Material::diffuse(Texture::Solid(Color::BLACK))
23    ));
24
25    /* left wall */
26    scene.add(Plane::new(
27        Vec3::NEG_X,
28        Vec3::X,
29        Material::diffuse(Texture::Solid(Color::BLACK)),
30    ));
31
32    /* right wall */
33    scene.add(Plane::new(
34        Vec3::X,
35        Vec3::NEG_X,
36        Material::diffuse(Texture::Solid(Color::BLACK))
37    ));
38
39    /* front */
40    scene.add(Plane::new(
41        2.0 * Vec3::NEG_Z,
42        Vec3::Z,
43        Material::diffuse(Texture::Solid(Color::BLACK))
44    ));
45
46    /* back */
47    scene.add(Plane::new(
48        Vec3::Z,
49        Vec3::NEG_Z,
50        Material::diffuse(Texture::Solid(Color::BLACK))
51    ));
52
53    /* bust */
54    scene.add(
55        Cube::new(Material::metallic(
56            Texture::Solid(Color::new(61, 45, 36)),
57            0.0,
58        ))
59        .translate(-0.5, -0.5, -0.5)
60        .scale(0.45, 0.5, 0.45)
61        .translate(0.0, -0.75, -1.45),
62    );
63
64    /* statue */
65    if cfg!(debug_assertions) {
66	scene.add(
67            Cylinder::new(
68		0.6,
69		0.1,
70		Material::diffuse(Texture::Solid(Color::new(255, 0, 0))))
71		.translate(0.0, -0.5, -1.45)
72	);
73    } else {
74	scene.add(
75	    parser::mesh_from_url(
76                NEFE_URL,
77		Material::specular(
78                    Texture::Image(parser::texture_from_url(NEFE_URL, TEX_FILE)?),
79                    0.8
80                )
81            )?
82		.to_unit_size()
83		.to_origin()
84		.scale(0.5, 0.5, 0.5)
85		.rotate_x(-PI / 2.0)
86		.translate(0.0, -0.25, -1.45),
87	);
88    }
89
90    let xy_rect = Mat3::from_cols(
91        Vec3::ZERO,
92        Vec3::X,
93        Vec3::X + Vec3::Y,
94    );
95
96    let theta = PI / 4.0;
97
98    /* light */
99    let disk_towards = Vec3::new(-0.046, -0.192, -1.314);
100    let disk_dir = Vec3::new(-0.9132592442858147, 0.38194206881899756, -0.05342207528313975);
101
102    // left, w.r.t camera
103    scene.add_light(Disk::new(
104	disk_towards + 0.3 * disk_dir,
105	-disk_dir,
106	0.05,
107	Material::Light(Texture::Solid(30.0 * Color::WHITE))
108    ));
109
110    let right_disk_origin = Vec3::new(0.6, 0.15, -1.6);
111    scene.add_light(Disk::new(
112	right_disk_origin,
113	disk_towards + 0.28 * Vec3::X - right_disk_origin,
114	0.08,
115	Material::Light(Texture::Solid(20.0 * Color::WHITE))
116    ));
117
118    scene.add_light(Rectangle::new(
119        xy_rect,
120        Material::Light(Texture::Solid(2.0 * Color::WHITE)))
121                    .scale(0.4, 0.4, 1.0)
122                    .rotate_y(-theta)
123		    .rotate_axis(Vec3::new(theta.cos(), 0.0, theta.sin()), PI / 8.0)
124                    .translate(0.6, 0.2, -1.7)
125    );
126
127    // behind
128    scene.add_light(Rectangle::new(
129        xy_rect,
130        Material::Light(Texture::Solid(Color::WHITE)))
131                    .scale(0.3, 0.3, 1.0)
132                    .rotate_x(2.0 * PI - 2.0 * theta)
133                    .translate(-0.15, 0.5, -0.8)
134    );
135    scene.add_light(Rectangle::new(
136	xy_rect,
137	Material::Light(Texture::Solid(2.0 * Color::WHITE)))
138		    .scale(0.3, 0.3, 1.0)
139		    .rotate_x(PI)
140		    .translate(-0.1, 0.0, 0.0)
141    );
142
143    // above
144    scene.add_light(Rectangle::new(
145        xy_rect,
146        Material::Light(Texture::Solid(2.0 * Color::WHITE)))
147                    .scale(0.4, 0.4, 1.0)
148                    .rotate_x(PI / 2.0)
149                    .translate(-0.2, 0.5, -1.5)
150    );
151
152    let camera = if cfg!(debug_assertions) {
153	Camera::perspective(
154	    0.5 * Vec3::Z,
155	    Vec3::NEG_Z,
156	    Vec3::Y,
157	    90.0,
158            0.0,
159            0.0,
160	    1000,
161	    1000
162	)
163    } else {
164	Camera::orthographic(
165            Vec3::new(0.12, -0.23, -1.205),
166            Vec3::new(0.0, -0.26, -1.45),
167            Vec3::Y,
168            0.2,
169            0.0,
170            0.0,
171            641,
172            939,
173	)
174    };
175
176    let renderer = Renderer::new(scene, camera);
177    renderer.render().save("nefe.png")?;
178
179    Ok(())
180}
Source

pub fn set_medium(&mut self, medium: Medium)

Sets the volumetric medium of the scene

Examples found in repository?
examples/circle.rs (lines 61-67)
16fn main() -> Result<(), std::io::Error> {
17    let camera = Camera::perspective(
18        Vec3::new(0.0, 1.5, 1.5),
19        Vec3::ZERO,
20        Vec3::new(0.0, 1.0, -1.0),
21        90.0,
22        0.0,
23        0.0,
24        1024,
25        768,
26    );
27
28    let mut scene = Scene::default();
29    let ground = -0.2;
30
31    // ground
32    scene.add(Plane::new(
33        ground * Vec3::Y,
34        Vec3::Y,
35        Material::metallic(Texture::Solid(Color::new(150, 40, 39)), 0.009999),
36    ));
37
38    let r = 0.2;
39    scene.add_light(Sphere::new(
40        Vec3::new(0.0, ground + r + 0.1, 0.0),
41        r,
42        Material::Light(Texture::Solid(Color::WHITE)),
43    ));
44
45    let circle_s = 8;
46    let offset = PI / circle_s as Float;
47
48    for i in 0..circle_s {
49        let theta = (i as Float / circle_s as Float) * 2.0 * PI + offset;
50        let x = theta.cos();
51        let y = ground + r;
52        let z = theta.sin();
53
54        scene.add(Sphere::new(
55            Vec3::new(x, y, z),
56            r,
57            Material::specular(Texture::Solid(hsv_to_rgb(theta - offset)), 0.2),
58        ));
59    }
60
61    scene.set_medium(
62        Medium::new(
63            Vec3::new(0.002, 0.003, 0.0001),
64            Vec3::new(0.175, 0.125, 0.11),
65            0.9,
66        )
67    );
68
69    let renderer = Renderer::new(scene, camera);
70    renderer.render().save("circle.png")?;
71
72    Ok(())
73}
Source

pub fn num_lights(&self) -> usize

Returns number of lights in the scene

Source

pub fn uniform_random_light(&self) -> &dyn Sampleable

Choose one of the lights uniformly at random. Crash if no lights.

Source

pub fn transmittance(&self, t: Float) -> Color

Returns the transmittance due to volumetric medium

Source

pub fn hit(&self, r: &Ray) -> Option<Hit<'_>>

Returns the closest object r hits and None if no hits

Source

pub fn hit_light<'a>( &'a self, r: &Ray, light: &'a dyn Sampleable, ) -> Option<Hit<'_>>

Does ray r reach the light object light?

Trait Implementations§

Source§

impl Default for Scene

Source§

fn default() -> Scene

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Scene

§

impl !RefUnwindSafe for Scene

§

impl !Send for Scene

§

impl Sync for Scene

§

impl Unpin for Scene

§

impl !UnwindSafe for Scene

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,