Rot2

Struct Rot2 

Source
pub struct Rot2 {
    pub cos: f32,
    pub sin: f32,
}
Expand description

A 2D rotation.

§Example

use std::f32::consts::PI;

// Create rotations from counterclockwise angles in radians or degrees
let rotation1 = Rot2::radians(PI / 2.0);
let rotation2 = Rot2::degrees(45.0);

// Get the angle back as radians or degrees
assert_eq!(rotation1.as_degrees(), 90.0);
assert_eq!(rotation2.as_radians(), PI / 4.0);

// "Add" rotations together using `*`
#[cfg(feature = "approx")]
assert_relative_eq!(rotation1 * rotation2, Rot2::degrees(135.0));

// Rotate vectors
#[cfg(feature = "approx")]
assert_relative_eq!(rotation1 * Vec2::X, Vec2::Y);

Fields§

§cos: f32

The cosine of the rotation angle.

This is the real part of the unit complex number representing the rotation.

§sin: f32

The sine of the rotation angle.

This is the imaginary part of the unit complex number representing the rotation.

Implementations§

Source§

impl Rot2

Source

pub const IDENTITY: Rot2

No rotation. Also equals a full turn that returns back to its original position.

#[cfg(feature = "approx")]
assert_relative_eq!(Rot2::IDENTITY, Rot2::degrees(360.0), epsilon = 2e-7);
Source

pub const PI: Rot2

A rotation of π radians. Corresponds to a half-turn.

Source

pub const FRAC_PI_2: Rot2

A counterclockwise rotation of π/2 radians. Corresponds to a counterclockwise quarter-turn.

Source

pub const FRAC_PI_3: Rot2

A counterclockwise rotation of π/3 radians. Corresponds to a counterclockwise turn by 60°.

Source

pub const FRAC_PI_4: Rot2

A counterclockwise rotation of π/4 radians. Corresponds to a counterclockwise turn by 45°.

Source

pub const FRAC_PI_6: Rot2

A counterclockwise rotation of π/6 radians. Corresponds to a counterclockwise turn by 30°.

Source

pub const FRAC_PI_8: Rot2

A counterclockwise rotation of π/8 radians. Corresponds to a counterclockwise turn by 22.5°.

Source

pub fn radians(radians: f32) -> Rot2

Creates a Rot2 from a counterclockwise angle in radians. A negative argument corresponds to a clockwise rotation.

§Note

Angles larger than or equal to 2π (in either direction) loop around to smaller rotations, since a full rotation returns an object to its starting orientation.

§Example

let rot1 = Rot2::radians(3.0 * FRAC_PI_2);
let rot2 = Rot2::radians(-FRAC_PI_2);
#[cfg(feature = "approx")]
assert_relative_eq!(rot1, rot2);

let rot3 = Rot2::radians(PI);
#[cfg(feature = "approx")]
assert_relative_eq!(rot1 * rot1, rot3);

// A rotation by 3π and 1π are the same
#[cfg(feature = "approx")]
assert_relative_eq!(Rot2::radians(3.0 * PI), Rot2::radians(PI));
Examples found in repository?
examples/ui/overflow_debug.rs (line 71)
70    fn update(&self, t: f32, transform: &mut UiTransform) {
71        transform.rotation = Rot2::radians(ops::cos(t * TAU) * 45.0);
72    }
More examples
Hide additional examples
examples/2d/mesh2d_arcs.rs (line 112)
104fn draw_bounds<Shape: Bounded2d + Send + Sync + 'static>(
105    q: Query<(&DrawBounds<Shape>, &GlobalTransform)>,
106    mut gizmos: Gizmos,
107) {
108    for (shape, transform) in &q {
109        let (_, rotation, translation) = transform.to_scale_rotation_translation();
110        let translation = translation.truncate();
111        let rotation = rotation.to_euler(EulerRot::XYZ).2;
112        let isometry = Isometry2d::new(translation, Rot2::radians(rotation));
113
114        let aabb = shape.0.aabb_2d(isometry);
115        gizmos.rect_2d(aabb.center(), aabb.half_size() * 2.0, RED);
116
117        let bounding_circle = shape.0.bounding_circle(isometry);
118        gizmos.circle_2d(bounding_circle.center, bounding_circle.radius(), BLUE);
119    }
120}
examples/math/bounding_2d.rs (line 106)
101fn render_shapes(mut gizmos: Gizmos, query: Query<(&Shape, &Transform)>) {
102    let color = GRAY;
103    for (shape, transform) in query.iter() {
104        let translation = transform.translation.xy();
105        let rotation = transform.rotation.to_euler(EulerRot::YXZ).2;
106        let isometry = Isometry2d::new(translation, Rot2::radians(rotation));
107        match shape {
108            Shape::Rectangle(r) => {
109                gizmos.primitive_2d(r, isometry, color);
110            }
111            Shape::Circle(c) => {
112                gizmos.primitive_2d(c, isometry, color);
113            }
114            Shape::Triangle(t) => {
115                gizmos.primitive_2d(t, isometry, color);
116            }
117            Shape::Line(l) => {
118                gizmos.primitive_2d(l, isometry, color);
119            }
120            Shape::Capsule(c) => {
121                gizmos.primitive_2d(c, isometry, color);
122            }
123            Shape::Polygon(p) => {
124                gizmos.primitive_2d(p, isometry, color);
125            }
126        }
127    }
128}
129
130#[derive(Component)]
131enum DesiredVolume {
132    Aabb,
133    Circle,
134}
135
136#[derive(Component, Debug)]
137enum CurrentVolume {
138    Aabb(Aabb2d),
139    Circle(BoundingCircle),
140}
141
142fn update_volumes(
143    mut commands: Commands,
144    query: Query<
145        (Entity, &DesiredVolume, &Shape, &Transform),
146        Or<(Changed<DesiredVolume>, Changed<Shape>, Changed<Transform>)>,
147    >,
148) {
149    for (entity, desired_volume, shape, transform) in query.iter() {
150        let translation = transform.translation.xy();
151        let rotation = transform.rotation.to_euler(EulerRot::YXZ).2;
152        let isometry = Isometry2d::new(translation, Rot2::radians(rotation));
153        match desired_volume {
154            DesiredVolume::Aabb => {
155                let aabb = match shape {
156                    Shape::Rectangle(r) => r.aabb_2d(isometry),
157                    Shape::Circle(c) => c.aabb_2d(isometry),
158                    Shape::Triangle(t) => t.aabb_2d(isometry),
159                    Shape::Line(l) => l.aabb_2d(isometry),
160                    Shape::Capsule(c) => c.aabb_2d(isometry),
161                    Shape::Polygon(p) => p.aabb_2d(isometry),
162                };
163                commands.entity(entity).insert(CurrentVolume::Aabb(aabb));
164            }
165            DesiredVolume::Circle => {
166                let circle = match shape {
167                    Shape::Rectangle(r) => r.bounding_circle(isometry),
168                    Shape::Circle(c) => c.bounding_circle(isometry),
169                    Shape::Triangle(t) => t.bounding_circle(isometry),
170                    Shape::Line(l) => l.bounding_circle(isometry),
171                    Shape::Capsule(c) => c.bounding_circle(isometry),
172                    Shape::Polygon(p) => p.bounding_circle(isometry),
173                };
174                commands
175                    .entity(entity)
176                    .insert(CurrentVolume::Circle(circle));
177            }
178        }
179    }
180}
examples/math/custom_primitives.rs (line 188)
180fn bounding_shapes_2d(
181    shapes: Query<&Transform, With<Shape2d>>,
182    mut gizmos: Gizmos,
183    bounding_shape: Res<State<BoundingShape>>,
184) {
185    for transform in shapes.iter() {
186        // Get the rotation angle from the 3D rotation.
187        let rotation = transform.rotation.to_scaled_axis().z;
188        let rotation = Rot2::radians(rotation);
189        let isometry = Isometry2d::new(transform.translation.xy(), rotation);
190
191        match bounding_shape.get() {
192            BoundingShape::None => (),
193            BoundingShape::BoundingBox => {
194                // Get the AABB of the primitive with the rotation and translation of the mesh.
195                let aabb = HEART.aabb_2d(isometry);
196                gizmos.rect_2d(aabb.center(), aabb.half_size() * 2., WHITE);
197            }
198            BoundingShape::BoundingSphere => {
199                // Get the bounding sphere of the primitive with the rotation and translation of the mesh.
200                let bounding_circle = HEART.bounding_circle(isometry);
201                gizmos
202                    .circle_2d(bounding_circle.center(), bounding_circle.radius(), WHITE)
203                    .resolution(64);
204            }
205        }
206    }
207}
examples/gizmos/2d_gizmos.rs (line 91)
40fn draw_example_collection(
41    mut gizmos: Gizmos,
42    mut my_gizmos: Gizmos<MyRoundGizmos>,
43    time: Res<Time>,
44) {
45    let sin_t_scaled = ops::sin(time.elapsed_secs()) * 50.;
46    gizmos.line_2d(Vec2::Y * -sin_t_scaled, Vec2::splat(-80.), RED);
47    gizmos.ray_2d(Vec2::Y * sin_t_scaled, Vec2::splat(80.), LIME);
48
49    gizmos
50        .grid_2d(
51            Isometry2d::IDENTITY,
52            UVec2::new(16, 9),
53            Vec2::new(80., 80.),
54            // Dark gray
55            LinearRgba::gray(0.05),
56        )
57        .outer_edges();
58
59    // Triangle
60    gizmos.linestrip_gradient_2d([
61        (Vec2::Y * 300., BLUE),
62        (Vec2::new(-255., -155.), RED),
63        (Vec2::new(255., -155.), LIME),
64        (Vec2::Y * 300., BLUE),
65    ]);
66
67    gizmos.rect_2d(Isometry2d::IDENTITY, Vec2::splat(650.), BLACK);
68
69    gizmos.cross_2d(Vec2::new(-160., 120.), 12., FUCHSIA);
70
71    let domain = Interval::EVERYWHERE;
72    let curve = FunctionCurve::new(domain, |t| Vec2::new(t, ops::sin(t / 25.0) * 100.0));
73    let resolution = ((ops::sin(time.elapsed_secs()) + 1.0) * 50.0) as usize;
74    let times_and_colors = (0..=resolution)
75        .map(|n| n as f32 / resolution as f32)
76        .map(|t| (t - 0.5) * 600.0)
77        .map(|t| (t, TEAL.mix(&HOT_PINK, (t + 300.0) / 600.0)));
78    gizmos.curve_gradient_2d(curve, times_and_colors);
79
80    my_gizmos
81        .rounded_rect_2d(Isometry2d::IDENTITY, Vec2::splat(630.), BLACK)
82        .corner_radius(ops::cos(time.elapsed_secs() / 3.) * 100.);
83
84    // Circles have 32 line-segments by default.
85    // You may want to increase this for larger circles.
86    my_gizmos
87        .circle_2d(Isometry2d::IDENTITY, 300., NAVY)
88        .resolution(64);
89
90    my_gizmos.ellipse_2d(
91        Rot2::radians(time.elapsed_secs() % TAU),
92        Vec2::new(100., 200.),
93        YELLOW_GREEN,
94    );
95
96    // Arcs default resolution is linearly interpolated between
97    // 1 and 32, using the arc length as scalar.
98    my_gizmos.arc_2d(
99        Rot2::radians(sin_t_scaled / 10.),
100        FRAC_PI_2,
101        310.,
102        ORANGE_RED,
103    );
104    my_gizmos.arc_2d(Isometry2d::IDENTITY, FRAC_PI_2, 80.0, ORANGE_RED);
105    my_gizmos.long_arc_2d_between(Vec2::ZERO, Vec2::X * 20.0, Vec2::Y * 20.0, ORANGE_RED);
106    my_gizmos.short_arc_2d_between(Vec2::ZERO, Vec2::X * 40.0, Vec2::Y * 40.0, ORANGE_RED);
107
108    gizmos.arrow_2d(
109        Vec2::ZERO,
110        Vec2::from_angle(sin_t_scaled / -10. + PI / 2.) * 50.,
111        YELLOW,
112    );
113
114    // You can create more complex arrows using the arrow builder.
115    gizmos
116        .arrow_2d(
117            Vec2::ZERO,
118            Vec2::from_angle(sin_t_scaled / -10.) * 50.,
119            GREEN,
120        )
121        .with_double_end()
122        .with_tip_length(10.);
123}
examples/math/render_primitives.rs (line 407)
404fn draw_gizmos_2d(mut gizmos: Gizmos, state: Res<State<PrimitiveSelected>>, time: Res<Time>) {
405    const POSITION: Vec2 = Vec2::new(-LEFT_RIGHT_OFFSET_2D, 0.0);
406    let angle = time.elapsed_secs();
407    let isometry = Isometry2d::new(POSITION, Rot2::radians(angle));
408    let color = Color::WHITE;
409
410    #[expect(
411        clippy::match_same_arms,
412        reason = "Certain primitives don't have any 2D rendering support yet."
413    )]
414    match state.get() {
415        PrimitiveSelected::RectangleAndCuboid => {
416            gizmos.primitive_2d(&RECTANGLE, isometry, color);
417        }
418        PrimitiveSelected::CircleAndSphere => {
419            gizmos.primitive_2d(&CIRCLE, isometry, color);
420        }
421        PrimitiveSelected::Ellipse => drop(gizmos.primitive_2d(&ELLIPSE, isometry, color)),
422        PrimitiveSelected::Triangle => gizmos.primitive_2d(&TRIANGLE_2D, isometry, color),
423        PrimitiveSelected::Plane => gizmos.primitive_2d(&PLANE_2D, isometry, color),
424        PrimitiveSelected::Line => drop(gizmos.primitive_2d(&LINE2D, isometry, color)),
425        PrimitiveSelected::Segment => {
426            drop(gizmos.primitive_2d(&SEGMENT_2D, isometry, color));
427        }
428        PrimitiveSelected::Polyline => gizmos.primitive_2d(
429            &Polyline2d {
430                vertices: vec![
431                    Vec2::new(-BIG_2D, -SMALL_2D),
432                    Vec2::new(-SMALL_2D, SMALL_2D),
433                    Vec2::new(SMALL_2D, -SMALL_2D),
434                    Vec2::new(BIG_2D, SMALL_2D),
435                ],
436            },
437            isometry,
438            color,
439        ),
440        PrimitiveSelected::Polygon => gizmos.primitive_2d(
441            &Polygon {
442                vertices: vec![
443                    Vec2::new(-BIG_2D, -SMALL_2D),
444                    Vec2::new(BIG_2D, -SMALL_2D),
445                    Vec2::new(BIG_2D, SMALL_2D),
446                    Vec2::new(0.0, 0.0),
447                    Vec2::new(-BIG_2D, SMALL_2D),
448                ],
449            },
450            isometry,
451            color,
452        ),
453        PrimitiveSelected::RegularPolygon => {
454            gizmos.primitive_2d(&REGULAR_POLYGON, isometry, color);
455        }
456        PrimitiveSelected::Capsule => gizmos.primitive_2d(&CAPSULE_2D, isometry, color),
457        PrimitiveSelected::Cylinder => {}
458        PrimitiveSelected::Cone => {}
459        PrimitiveSelected::ConicalFrustum => {}
460        PrimitiveSelected::Torus => drop(gizmos.primitive_2d(&ANNULUS, isometry, color)),
461        PrimitiveSelected::Tetrahedron => {}
462        PrimitiveSelected::Arc => gizmos.primitive_2d(&ARC, isometry, color),
463        PrimitiveSelected::CircularSector => {
464            gizmos.primitive_2d(&CIRCULAR_SECTOR, isometry, color);
465        }
466        PrimitiveSelected::CircularSegment => {
467            gizmos.primitive_2d(&CIRCULAR_SEGMENT, isometry, color);
468        }
469    }
470}
Source

pub fn degrees(degrees: f32) -> Rot2

Creates a Rot2 from a counterclockwise angle in degrees. A negative argument corresponds to a clockwise rotation.

§Note

Angles larger than or equal to 360° (in either direction) loop around to smaller rotations, since a full rotation returns an object to its starting orientation.

§Example

let rot1 = Rot2::degrees(270.0);
let rot2 = Rot2::degrees(-90.0);
#[cfg(feature = "approx")]
assert_relative_eq!(rot1, rot2);

let rot3 = Rot2::degrees(180.0);
#[cfg(feature = "approx")]
assert_relative_eq!(rot1 * rot1, rot3);

// A rotation by 365° and 5° are the same
#[cfg(feature = "approx")]
assert_abs_diff_eq!(Rot2::degrees(365.0), Rot2::degrees(5.0), epsilon = 2e-7);
Examples found in repository?
examples/3d/pbr.rs (line 89)
15fn setup(
16    mut commands: Commands,
17    mut meshes: ResMut<Assets<Mesh>>,
18    mut materials: ResMut<Assets<StandardMaterial>>,
19    asset_server: Res<AssetServer>,
20) {
21    let sphere_mesh = meshes.add(Sphere::new(0.45));
22    // add entities to the world
23    for y in -2..=2 {
24        for x in -5..=5 {
25            let x01 = (x + 5) as f32 / 10.0;
26            let y01 = (y + 2) as f32 / 4.0;
27            // sphere
28            commands.spawn((
29                Mesh3d(sphere_mesh.clone()),
30                MeshMaterial3d(materials.add(StandardMaterial {
31                    base_color: Srgba::hex("#ffd891").unwrap().into(),
32                    // vary key PBR parameters on a grid of spheres to show the effect
33                    metallic: y01,
34                    perceptual_roughness: x01,
35                    ..default()
36                })),
37                Transform::from_xyz(x as f32, y as f32 + 0.5, 0.0),
38            ));
39        }
40    }
41    // unlit sphere
42    commands.spawn((
43        Mesh3d(sphere_mesh),
44        MeshMaterial3d(materials.add(StandardMaterial {
45            base_color: Srgba::hex("#ffd891").unwrap().into(),
46            // vary key PBR parameters on a grid of spheres to show the effect
47            unlit: true,
48            ..default()
49        })),
50        Transform::from_xyz(-5.0, -2.5, 0.0),
51    ));
52
53    commands.spawn((
54        DirectionalLight {
55            illuminance: 1_500.,
56            ..default()
57        },
58        Transform::from_xyz(50.0, 50.0, 50.0).looking_at(Vec3::ZERO, Vec3::Y),
59    ));
60
61    // labels
62    commands.spawn((
63        Text::new("Perceptual Roughness"),
64        TextFont {
65            font_size: 30.0,
66            ..default()
67        },
68        Node {
69            position_type: PositionType::Absolute,
70            top: px(20),
71            left: px(100),
72            ..default()
73        },
74    ));
75
76    commands.spawn((
77        Text::new("Metallic"),
78        TextFont {
79            font_size: 30.0,
80            ..default()
81        },
82        Node {
83            position_type: PositionType::Absolute,
84            top: px(130),
85            right: Val::ZERO,
86            ..default()
87        },
88        UiTransform {
89            rotation: Rot2::degrees(90.),
90            ..default()
91        },
92    ));
93
94    commands.spawn((
95        Text::new("Loading Environment Map..."),
96        TextFont {
97            font_size: 30.0,
98            ..default()
99        },
100        Node {
101            position_type: PositionType::Absolute,
102            bottom: px(20),
103            right: px(20),
104            ..default()
105        },
106        EnvironmentMapLabel,
107    ));
108
109    // camera
110    commands.spawn((
111        Camera3d::default(),
112        Transform::from_xyz(0.0, 0.0, 8.0).looking_at(Vec3::default(), Vec3::Y),
113        Projection::from(OrthographicProjection {
114            scale: 0.01,
115            scaling_mode: ScalingMode::WindowSize,
116            ..OrthographicProjection::default_3d()
117        }),
118        EnvironmentMapLight {
119            diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
120            specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
121            intensity: 900.0,
122            ..default()
123        },
124    ));
125}
Source

pub fn turn_fraction(fraction: f32) -> Rot2

Creates a Rot2 from a counterclockwise fraction of a full turn of 360 degrees. A negative argument corresponds to a clockwise rotation.

§Note

Angles larger than or equal to 1 turn (in either direction) loop around to smaller rotations, since a full rotation returns an object to its starting orientation.

§Example

let rot1 = Rot2::turn_fraction(0.75);
let rot2 = Rot2::turn_fraction(-0.25);
#[cfg(feature = "approx")]
assert_relative_eq!(rot1, rot2);

let rot3 = Rot2::turn_fraction(0.5);
#[cfg(feature = "approx")]
assert_relative_eq!(rot1 * rot1, rot3);

// A rotation by 1.5 turns and 0.5 turns are the same
#[cfg(feature = "approx")]
assert_relative_eq!(Rot2::turn_fraction(1.5), Rot2::turn_fraction(0.5));
Source

pub fn from_sin_cos(sin: f32, cos: f32) -> Rot2

Creates a Rot2 from the sine and cosine of an angle.

The rotation is only valid if sin * sin + cos * cos == 1.0.

§Panics

Panics if sin * sin + cos * cos != 1.0 when the glam_assert feature is enabled.

Source

pub fn as_radians(self) -> f32

Returns a corresponding rotation angle in radians in the (-pi, pi] range.

Source

pub fn as_degrees(self) -> f32

Returns a corresponding rotation angle in degrees in the (-180, 180] range.

Source

pub fn as_turn_fraction(self) -> f32

Returns a corresponding rotation angle as a fraction of a full 360 degree turn in the (-0.5, 0.5] range.

Source

pub const fn sin_cos(self) -> (f32, f32)

Returns the sine and cosine of the rotation angle.

Source

pub fn length(self) -> f32

Computes the length or norm of the complex number used to represent the rotation.

The length is typically expected to be 1.0. Unexpectedly denormalized rotations can be a result of incorrect construction or floating point error caused by successive operations.

Source

pub fn length_squared(self) -> f32

Computes the squared length or norm of the complex number used to represent the rotation.

This is generally faster than Rot2::length(), as it avoids a square root operation.

The length is typically expected to be 1.0. Unexpectedly denormalized rotations can be a result of incorrect construction or floating point error caused by successive operations.

Source

pub fn length_recip(self) -> f32

Computes 1.0 / self.length().

For valid results, self must not have a length of zero.

Source

pub fn try_normalize(self) -> Option<Rot2>

Returns self with a length of 1.0 if possible, and None otherwise.

None will be returned if the sine and cosine of self are both zero (or very close to zero), or if either of them is NaN or infinite.

Note that Rot2 should typically already be normalized by design. Manual normalization is only needed when successive operations result in accumulated floating point error, or if the rotation was constructed with invalid values.

Source

pub fn normalize(self) -> Rot2

Returns self with a length of 1.0.

Note that Rot2 should typically already be normalized by design. Manual normalization is only needed when successive operations result in accumulated floating point error, or if the rotation was constructed with invalid values.

§Panics

Panics if self has a length of zero, NaN, or infinity when debug assertions are enabled.

Source

pub fn fast_renormalize(self) -> Rot2

Returns self after an approximate normalization, assuming the value is already nearly normalized. Useful for preventing numerical error accumulation. See Dir3::fast_renormalize for an example of when such error accumulation might occur.

Source

pub const fn is_finite(self) -> bool

Returns true if the rotation is neither infinite nor NaN.

Source

pub const fn is_nan(self) -> bool

Returns true if the rotation is NaN.

Source

pub fn is_normalized(self) -> bool

Returns whether self has a length of 1.0 or not.

Uses a precision threshold of approximately 1e-4.

Source

pub fn is_near_identity(self) -> bool

Returns true if the rotation is near Rot2::IDENTITY.

Source

pub fn angle_to(self, other: Rot2) -> f32

Returns the angle in radians needed to make self and other coincide.

Source

pub const fn inverse(self) -> Rot2

Returns the inverse of the rotation. This is also the conjugate of the unit complex number representing the rotation.

Source

pub fn nlerp(self, end: Rot2, s: f32) -> Rot2

Performs a linear interpolation between self and rhs based on the value s, and normalizes the rotation afterwards.

When s == 0.0, the result will be equal to self. When s == 1.0, the result will be equal to rhs.

This is slightly more efficient than slerp, and produces a similar result when the difference between the two rotations is small. At larger differences, the result resembles a kind of ease-in-out effect.

If you would like the angular velocity to remain constant, consider using slerp instead.

§Details

nlerp corresponds to computing an angle for a point at position s on a line drawn between the endpoints of the arc formed by self and rhs on a unit circle, and normalizing the result afterwards.

Note that if the angles are opposite like 0 and π, the line will pass through the origin, and the resulting angle will always be either self or rhs depending on s. If s happens to be 0.5 in this case, a valid rotation cannot be computed, and self will be returned as a fallback.

§Example
let rot1 = Rot2::IDENTITY;
let rot2 = Rot2::degrees(135.0);

let result1 = rot1.nlerp(rot2, 1.0 / 3.0);
assert_eq!(result1.as_degrees(), 28.675055);

let result2 = rot1.nlerp(rot2, 0.5);
assert_eq!(result2.as_degrees(), 67.5);
Source

pub fn slerp(self, end: Rot2, s: f32) -> Rot2

Performs a spherical linear interpolation between self and end based on the value s.

This corresponds to interpolating between the two angles at a constant angular velocity.

When s == 0.0, the result will be equal to self. When s == 1.0, the result will be equal to rhs.

If you would like the rotation to have a kind of ease-in-out effect, consider using the slightly more efficient nlerp instead.

§Example
let rot1 = Rot2::IDENTITY;
let rot2 = Rot2::degrees(135.0);

let result1 = rot1.slerp(rot2, 1.0 / 3.0);
assert_eq!(result1.as_degrees(), 45.0);

let result2 = rot1.slerp(rot2, 0.5);
assert_eq!(result2.as_degrees(), 67.5);

Trait Implementations§

Source§

impl Clone for Rot2

Source§

fn clone(&self) -> Rot2

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Rot2

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Rot2

Source§

fn default() -> Rot2

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

impl<'de> Deserialize<'de> for Rot2

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Rot2, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Ease for Rot2

Source§

fn interpolating_curve_unbounded(start: Rot2, end: Rot2) -> impl Curve<Rot2>

Given start and end values, produce a curve with unlimited domain that: Read more
Source§

impl From<Rot2> for Isometry2d

Source§

fn from(rotation: Rot2) -> Isometry2d

Converts to this type from the input type.
Source§

impl From<Rot2> for Mat2

Source§

fn from(rot: Rot2) -> Mat2

Creates a Mat2 rotation matrix from a Rot2.

Source§

impl From<f32> for Rot2

Source§

fn from(rotation: f32) -> Rot2

Creates a Rot2 from a counterclockwise angle in radians.

Source§

impl FromArg for Rot2

Source§

type This<'from_arg> = Rot2

The type to convert into. Read more
Source§

fn from_arg(arg: Arg<'_>) -> Result<<Rot2 as FromArg>::This<'_>, ArgError>

Creates an item from an argument. Read more
Source§

impl FromReflect for Rot2

Source§

fn from_reflect(reflect: &(dyn PartialReflect + 'static)) -> Option<Rot2>

Constructs a concrete instance of Self from a reflected value.
Source§

fn take_from_reflect( reflect: Box<dyn PartialReflect>, ) -> Result<Self, Box<dyn PartialReflect>>

Attempts to downcast the given value to Self using, constructing the value using from_reflect if that fails. Read more
Source§

impl FromRng for Rot2

Source§

fn from_rng<R>(rng: &mut R) -> Self
where R: Rng + ?Sized,

Construct a value of this type uniformly at random using rng as the source of randomness.
Source§

impl GetOwnership for Rot2

Source§

fn ownership() -> Ownership

Returns the ownership of Self.
Source§

impl GetTypeRegistration for Rot2

Source§

fn get_type_registration() -> TypeRegistration

Returns the default TypeRegistration for this type.
Source§

fn register_type_dependencies(registry: &mut TypeRegistry)

Registers other types needed by this type. Read more
Source§

impl IntoReturn for Rot2

Source§

fn into_return<'into_return>(self) -> Return<'into_return>
where Rot2: 'into_return,

Converts Self into a Return value.
Source§

impl Mul<Dir2> for Rot2

Source§

fn mul(self, direction: Dir2) -> <Rot2 as Mul<Dir2>>::Output

Rotates the Dir2 using a Rot2.

Source§

type Output = Dir2

The resulting type after applying the * operator.
Source§

impl Mul<Vec2> for Rot2

Source§

fn mul(self, rhs: Vec2) -> <Rot2 as Mul<Vec2>>::Output

Rotates a Vec2 by a Rot2.

Source§

type Output = Vec2

The resulting type after applying the * operator.
Source§

impl Mul for Rot2

Source§

type Output = Rot2

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Rot2) -> <Rot2 as Mul>::Output

Performs the * operation. Read more
Source§

impl MulAssign for Rot2

Source§

fn mul_assign(&mut self, rhs: Rot2)

Performs the *= operation. Read more
Source§

impl PartialEq for Rot2

Source§

fn eq(&self, other: &Rot2) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialReflect for Rot2

Source§

fn get_represented_type_info(&self) -> Option<&'static TypeInfo>

Returns the TypeInfo of the type represented by this value. Read more
Source§

fn try_apply( &mut self, value: &(dyn PartialReflect + 'static), ) -> Result<(), ApplyError>

Tries to apply a reflected value to this value. Read more
Source§

fn reflect_kind(&self) -> ReflectKind

Returns a zero-sized enumeration of “kinds” of type. Read more
Source§

fn reflect_ref(&self) -> ReflectRef<'_>

Returns an immutable enumeration of “kinds” of type. Read more
Source§

fn reflect_mut(&mut self) -> ReflectMut<'_>

Returns a mutable enumeration of “kinds” of type. Read more
Source§

fn reflect_owned(self: Box<Rot2>) -> ReflectOwned

Returns an owned enumeration of “kinds” of type. Read more
Source§

fn try_into_reflect( self: Box<Rot2>, ) -> Result<Box<dyn Reflect>, Box<dyn PartialReflect>>

Attempts to cast this type to a boxed, fully-reflected value.
Source§

fn try_as_reflect(&self) -> Option<&(dyn Reflect + 'static)>

Attempts to cast this type to a fully-reflected value.
Source§

fn try_as_reflect_mut(&mut self) -> Option<&mut (dyn Reflect + 'static)>

Attempts to cast this type to a mutable, fully-reflected value.
Source§

fn into_partial_reflect(self: Box<Rot2>) -> Box<dyn PartialReflect>

Casts this type to a boxed, reflected value. Read more
Source§

fn as_partial_reflect(&self) -> &(dyn PartialReflect + 'static)

Casts this type to a reflected value. Read more
Source§

fn as_partial_reflect_mut(&mut self) -> &mut (dyn PartialReflect + 'static)

Casts this type to a mutable, reflected value. Read more
Source§

fn reflect_partial_eq( &self, value: &(dyn PartialReflect + 'static), ) -> Option<bool>

Returns a “partial equality” comparison result. Read more
Source§

fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Debug formatter for the value. Read more
Source§

fn reflect_clone(&self) -> Result<Box<dyn Reflect>, ReflectCloneError>

Attempts to clone Self using reflection. Read more
Source§

fn apply(&mut self, value: &(dyn PartialReflect + 'static))

Applies a reflected value to this value. Read more
Source§

fn to_dynamic(&self) -> Box<dyn PartialReflect>

Converts this reflected value into its dynamic representation based on its kind. Read more
Source§

fn reflect_clone_and_take<T>(&self) -> Result<T, ReflectCloneError>
where T: 'static, Self: Sized + TypePath,

For a type implementing PartialReflect, combines reflect_clone and take in a useful fashion, automatically constructing an appropriate ReflectCloneError if the downcast fails. Read more
Source§

fn reflect_hash(&self) -> Option<u64>

Returns a hash of the value (which includes the type). Read more
Source§

fn is_dynamic(&self) -> bool

Indicates whether or not this type is a dynamic type. Read more
Source§

impl Reflect for Rot2

Source§

fn into_any(self: Box<Rot2>) -> Box<dyn Any>

Returns the value as a Box<dyn Any>. Read more
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Returns the value as a &dyn Any. Read more
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Returns the value as a &mut dyn Any. Read more
Source§

fn into_reflect(self: Box<Rot2>) -> Box<dyn Reflect>

Casts this type to a boxed, fully-reflected value.
Source§

fn as_reflect(&self) -> &(dyn Reflect + 'static)

Casts this type to a fully-reflected value.
Source§

fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)

Casts this type to a mutable, fully-reflected value.
Source§

fn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>

Performs a type-checked assignment of a reflected value to this value. Read more
Source§

impl Serialize for Rot2

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StableInterpolate for Rot2

Source§

fn interpolate_stable(&self, other: &Rot2, t: f32) -> Rot2

Interpolate between this value and the other given value using the parameter t. At t = 0.0, a value equivalent to self is recovered, while t = 1.0 recovers a value equivalent to other, with intermediate values interpolating between the two. See the trait-level documentation for details.
Source§

fn interpolate_stable_assign(&mut self, other: &Self, t: f32)

A version of interpolate_stable that assigns the result to self for convenience.
Source§

fn smooth_nudge(&mut self, target: &Self, decay_rate: f32, delta: f32)

Smoothly nudge this value towards the target at a given decay rate. The decay_rate parameter controls how fast the distance between self and target decays relative to the units of delta; the intended usage is for decay_rate to generally remain fixed, while delta is something like delta_time from an updating system. This produces a smooth following of the target that is independent of framerate. Read more
Source§

impl Struct for Rot2

Source§

fn field(&self, name: &str) -> Option<&(dyn PartialReflect + 'static)>

Returns a reference to the value of the field named name as a &dyn PartialReflect.
Source§

fn field_mut( &mut self, name: &str, ) -> Option<&mut (dyn PartialReflect + 'static)>

Returns a mutable reference to the value of the field named name as a &mut dyn PartialReflect.
Source§

fn field_at(&self, index: usize) -> Option<&(dyn PartialReflect + 'static)>

Returns a reference to the value of the field with index index as a &dyn PartialReflect.
Source§

fn field_at_mut( &mut self, index: usize, ) -> Option<&mut (dyn PartialReflect + 'static)>

Returns a mutable reference to the value of the field with index index as a &mut dyn PartialReflect.
Source§

fn name_at(&self, index: usize) -> Option<&str>

Returns the name of the field with index index.
Source§

fn field_len(&self) -> usize

Returns the number of fields in the struct.
Source§

fn iter_fields(&self) -> FieldIter<'_>

Returns an iterator over the values of the reflectable fields for this struct.
Source§

fn to_dynamic_struct(&self) -> DynamicStruct

Creates a new DynamicStruct from this struct.
Source§

fn get_represented_struct_info(&self) -> Option<&'static StructInfo>

Will return None if TypeInfo is not available.
Source§

impl TypePath for Rot2

Source§

fn type_path() -> &'static str

Returns the fully qualified path of the underlying type. Read more
Source§

fn short_type_path() -> &'static str

Returns a short, pretty-print enabled path to the type. Read more
Source§

fn type_ident() -> Option<&'static str>

Returns the name of the type, or None if it is anonymous. Read more
Source§

fn crate_name() -> Option<&'static str>

Returns the name of the crate the type is in, or None if it is anonymous. Read more
Source§

fn module_path() -> Option<&'static str>

Returns the path to the module the type is in, or None if it is anonymous. Read more
Source§

impl Typed for Rot2

Source§

fn type_info() -> &'static TypeInfo

Returns the compile-time info for the underlying type.
Source§

impl Copy for Rot2

Source§

impl StructuralPartialEq for Rot2

Auto Trait Implementations§

§

impl Freeze for Rot2

§

impl RefUnwindSafe for Rot2

§

impl Send for Rot2

§

impl Sync for Rot2

§

impl Unpin for Rot2

§

impl UnwindSafe for Rot2

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, U> AsBindGroupShaderType<U> for T
where U: ShaderType, &'a T: for<'a> Into<U>,

Source§

fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U

Return the T ShaderType for self. When used in AsBindGroup derives, it is safe to assume that all images in self exist.
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynamicTypePath for T
where T: TypePath,

Source§

impl<T> DynamicTyped for T
where T: Typed,

Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> FromWorld for T
where T: Default,

Source§

fn from_world(_world: &mut World) -> T

Creates Self using default().

Source§

impl<S> GetField for S
where S: Struct,

Source§

fn get_field<T>(&self, name: &str) -> Option<&T>
where T: Reflect,

Returns a reference to the value of the field named name, downcast to T.
Source§

fn get_field_mut<T>(&mut self, name: &str) -> Option<&mut T>
where T: Reflect,

Returns a mutable reference to the value of the field named name, downcast to T.
Source§

impl<T> GetPath for T
where T: Reflect + ?Sized,

Source§

fn reflect_path<'p>( &self, path: impl ReflectPath<'p>, ) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>>

Returns a reference to the value specified by path. Read more
Source§

fn reflect_path_mut<'p>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>>

Returns a mutable reference to the value specified by path. Read more
Source§

fn path<'p, T>( &self, path: impl ReflectPath<'p>, ) -> Result<&T, ReflectPathError<'p>>
where T: Reflect,

Returns a statically typed reference to the value specified by path. Read more
Source§

fn path_mut<'p, T>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut T, ReflectPathError<'p>>
where T: Reflect,

Returns a statically typed mutable reference to the value specified by path. Read more
Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

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

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
Source§

impl<T> InitializeFromFunction<T> for T

Source§

fn initialize_from_function(f: fn() -> T) -> T

Create an instance of this type from an initialization function
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoResult<T> for T

Source§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<A> Is for A
where A: Any,

Source§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

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

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
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<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<Ret> SpawnIfAsync<(), Ret> for Ret

Source§

fn spawn(self) -> Ret

Spawn the value into the dioxus runtime if it is an async block
Source§

impl<T, O> SuperFrom<T> for O
where O: From<T>,

Source§

fn super_from(input: T) -> O

Convert from a type to another type.
Source§

impl<T, O, M> SuperInto<O, M> for T
where O: SuperFrom<T, M>,

Source§

fn super_into(self) -> O

Convert from a type to another type.
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
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<T> TypeData for T
where T: 'static + Send + Sync + Clone,

Source§

fn clone_type_data(&self) -> Box<dyn TypeData>

Creates a type-erased clone of this value.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ConditionalSend for T
where T: Send,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> Reflectable for T

Source§

impl<T> Settings for T
where T: 'static + Send + Sync,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,