RigidBody

Struct RigidBody 

Source
pub struct RigidBody {
    pub user_data: u128,
    /* private fields */
}
Expand description

A physical object that can move, rotate, and collide with other objects in your simulation.

Rigid bodies are the fundamental moving objects in physics simulations. Think of them as the “physical representation” of your game objects - a character, a crate, a vehicle, etc.

§Body types

  • Dynamic: Affected by forces, gravity, and collisions. Use for objects that should move realistically (falling boxes, projectiles, etc.)
  • Fixed: Never moves. Use for static geometry like walls, floors, and terrain
  • Kinematic: Moved by setting velocity or position directly, not by forces. Use for moving platforms, doors, or player-controlled characters

§Creating bodies

Always use RigidBodyBuilder to create new rigid bodies:

let body = RigidBodyBuilder::dynamic()
    .translation(vector![0.0, 10.0, 0.0])
    .build();
let handle = bodies.insert(body);

Fields§

§user_data: u128

User-defined data associated to this rigid-body.

Implementations§

Source§

impl RigidBody

Source

pub fn copy_from(&mut self, other: &RigidBody)

Copy all the characteristics from other to self.

If you have a mutable reference to a rigid-body rigid_body: &mut RigidBody, attempting to assign it a whole new rigid-body instance, e.g., *rigid_body = RigidBodyBuilder::dynamic().build(), will crash due to some internal indices being overwritten. Instead, use rigid_body.copy_from(&RigidBodyBuilder::dynamic().build()).

This method will allow you to set most characteristics of this rigid-body from another rigid-body instance without causing any breakage.

This method cannot be used for editing the list of colliders attached to this rigid-body. Therefore, the list of colliders attached to self won’t be replaced by the one attached to other.

The pose of other will only copied into self if self doesn’t have a parent (if it has a parent, its position is directly controlled by the parent rigid-body).

Source

pub fn additional_solver_iterations(&self) -> usize

Set the additional number of solver iterations run for this rigid-body and everything interacting with it.

See Self::set_additional_solver_iterations for additional information.

Source

pub fn set_additional_solver_iterations(&mut self, additional_iterations: usize)

Set the additional number of solver iterations run for this rigid-body and everything interacting with it.

Increasing this number will help improve simulation accuracy on this rigid-body and every rigid-body interacting directly or indirectly with it (through joints or contacts). This implies a performance hit.

The default value is 0, meaning exactly IntegrationParameters::num_solver_iterations will be used as number of solver iterations for this body.

Source

pub fn activation(&self) -> &RigidBodyActivation

The activation status of this rigid-body.

Source

pub fn activation_mut(&mut self) -> &mut RigidBodyActivation

Mutable reference to the activation status of this rigid-body.

Source

pub fn is_enabled(&self) -> bool

Is this rigid-body enabled?

Source

pub fn set_enabled(&mut self, enabled: bool)

Sets whether this rigid-body is enabled or not.

Source

pub fn linear_damping(&self) -> f32

The linear damping coefficient (velocity reduction over time).

Damping gradually slows down moving objects. 0.0 = no damping (infinite momentum), higher values = faster slowdown. Use for air resistance, friction, etc.

Source

pub fn set_linear_damping(&mut self, damping: f32)

Sets how quickly linear velocity decreases over time.

  • 0.0 = no slowdown (space/frictionless)
  • 0.1 = gradual slowdown (air resistance)
  • 1.0+ = rapid slowdown (thick fluid)
Source

pub fn angular_damping(&self) -> f32

The angular damping coefficient (rotation slowdown over time).

Like linear damping but for rotation. Higher values make spinning objects stop faster.

Source

pub fn set_angular_damping(&mut self, damping: f32)

Sets how quickly angular velocity decreases over time.

Controls how fast spinning objects slow down.

Source

pub fn body_type(&self) -> RigidBodyType

The type of this rigid-body.

Source

pub fn set_body_type(&mut self, status: RigidBodyType, wake_up: bool)

Sets the type of this rigid-body.

Source

pub fn center_of_mass(&self) -> &Point<f32>

The center of mass position in world coordinates.

This is the “balance point” where the body’s mass is centered. Forces applied here produce no rotation, only translation.

Source

pub fn local_center_of_mass(&self) -> &Point<f32>

The center of mass in the body’s local coordinate system.

This is relative to the body’s position, computed from attached colliders.

Source

pub fn mass_properties(&self) -> &RigidBodyMassProps

The mass-properties of this rigid-body.

Source

pub fn effective_dominance_group(&self) -> i16

The dominance group of this rigid-body.

This method always returns i8::MAX + 1 for non-dynamic rigid-bodies.

Source

pub fn set_locked_axes(&mut self, locked_axes: LockedAxes, wake_up: bool)

Sets the axes along which this rigid-body cannot translate or rotate.

Source

pub fn locked_axes(&self) -> LockedAxes

The axes along which this rigid-body cannot translate or rotate.

Source

pub fn lock_rotations(&mut self, locked: bool, wake_up: bool)

Locks or unlocks all rotational movement for this body.

When locked, the body cannot rotate at all (useful for keeping objects upright). Use for characters that shouldn’t tip over, or objects that should only slide.

Source

pub fn set_enabled_rotations( &mut self, allow_rotations_x: bool, allow_rotations_y: bool, allow_rotations_z: bool, wake_up: bool, )

Locks or unlocks rotations of this rigid-body along each cartesian axes.

Source

pub fn restrict_rotations( &mut self, allow_rotations_x: bool, allow_rotations_y: bool, allow_rotations_z: bool, wake_up: bool, )

👎Deprecated: Use set_enabled_rotations instead

Locks or unlocks rotations of this rigid-body along each cartesian axes.

Source

pub fn lock_translations(&mut self, locked: bool, wake_up: bool)

Locks or unlocks all translational movement for this body.

When locked, the body cannot move from its position (but can still rotate). Use for rotating platforms, turrets, or objects fixed in space.

Source

pub fn set_enabled_translations( &mut self, allow_translation_x: bool, allow_translation_y: bool, allow_translation_z: bool, wake_up: bool, )

Locks or unlocks rotations of this rigid-body along each cartesian axes.

Source

pub fn restrict_translations( &mut self, allow_translation_x: bool, allow_translation_y: bool, allow_translation_z: bool, wake_up: bool, )

👎Deprecated: Use set_enabled_translations instead

Locks or unlocks rotations of this rigid-body along each cartesian axes.

Source

pub fn is_translation_locked(&self) -> bool

Are the translations of this rigid-body locked?

Source

pub fn is_rotation_locked(&self) -> [bool; 3]

Returns true for each rotational degrees of freedom locked on this rigid-body.

Source

pub fn enable_ccd(&mut self, enabled: bool)

Enables or disables Continuous Collision Detection for this body.

CCD prevents fast-moving objects from tunneling through thin walls, but costs more CPU. Enable for bullets, fast projectiles, or any object that must never pass through geometry.

Source

pub fn is_ccd_enabled(&self) -> bool

Checks if CCD is enabled for this body.

Returns true if CCD is turned on (not whether it’s currently active this frame).

Source

pub fn set_soft_ccd_prediction(&mut self, prediction_distance: f32)

Sets the maximum prediction distance Soft Continuous Collision-Detection.

When set to 0, soft-CCD is disabled. Soft-CCD helps prevent tunneling especially of slow-but-thin to moderately fast objects. The soft CCD prediction distance indicates how far in the object’s path the CCD algorithm is allowed to inspect. Large values can impact performance badly by increasing the work needed from the broad-phase.

It is a generally cheaper variant of regular CCD (that can be enabled with RigidBody::enable_ccd since it relies on predictive constraints instead of shape-cast and substeps.

Source

pub fn soft_ccd_prediction(&self) -> f32

The soft-CCD prediction distance for this rigid-body.

See the documentation of RigidBody::set_soft_ccd_prediction for additional details on soft-CCD.

Source

pub fn is_ccd_active(&self) -> bool

Is CCD active for this rigid-body?

The CCD is considered active if the rigid-body is moving at a velocity greater than an automatically-computed threshold.

This is not the same as self.is_ccd_enabled which only checks if CCD is enabled to run for this rigid-body or if it is completely disabled (independently from its velocity).

Source

pub fn recompute_mass_properties_from_colliders( &mut self, colliders: &ColliderSet, )

Recalculates mass, center of mass, and inertia from attached colliders.

Normally automatic, but call this if you modify collider shapes/masses at runtime. Only needed after directly modifying colliders without going through the builder.

Source

pub fn set_additional_mass(&mut self, additional_mass: f32, wake_up: bool)

Adds extra mass on top of collider-computed mass.

Total mass = collider masses + this additional mass. Use when you want to make a body heavier without changing collider densities.

§Example
// Add 50kg to make this body heavier
bodies[body].set_additional_mass(50.0, true);

Angular inertia is automatically scaled to match the mass increase. Updated automatically at next physics step or call recompute_mass_properties_from_colliders().

Source

pub fn set_additional_mass_properties( &mut self, props: MassProperties, wake_up: bool, )

Sets the rigid-body’s additional mass-properties.

This is only the “additional” mass-properties because the total mass-properties of the rigid-body is equal to the sum of this additional mass-properties and the mass computed from the colliders (with non-zero densities) attached to this rigid-body.

That total mass-properties (which include the attached colliders’ contributions) will be updated at the name physics step, or can be updated manually with Self::recompute_mass_properties_from_colliders.

This will override any previous mass-properties set by Self::set_additional_mass, Self::set_additional_mass_properties, RigidBodyBuilder::additional_mass, or RigidBodyBuilder::additional_mass_properties for this rigid-body.

If wake_up is true then the rigid-body will be woken up if it was put to sleep because it did not move for a while.

Source

pub fn colliders(&self) -> &[ColliderHandle]

Returns handles of all colliders attached to this body.

Use to iterate over a body’s collision shapes or to modify them.

§Example
for collider_handle in bodies[body].colliders() {
    if let Some(collider) = colliders.get_mut(*collider_handle) {
        collider.set_friction(0.5);
    }
}
Source

pub fn is_dynamic(&self) -> bool

Checks if this is a dynamic body (moves via forces and collisions).

Dynamic bodies are fully simulated and respond to gravity, forces, and collisions.

Source

pub fn is_kinematic(&self) -> bool

Checks if this is a kinematic body (moves via direct velocity/position control).

Kinematic bodies move by setting velocity directly, not by applying forces.

Source

pub fn is_dynamic_or_kinematic(&self) -> bool

Is this rigid-body a dynamic rigid-body or a kinematic rigid-body?

This method is mostly convenient internally where kinematic and dynamic rigid-body are subject to the same behavior.

Source

pub fn effective_active_set_offset(&self) -> u32

The offset index in the solver’s active set, or u32::MAX if the rigid-body isn’t dynamic or kinematic.

Source

pub fn is_fixed(&self) -> bool

Checks if this is a fixed body (never moves, infinite mass).

Fixed bodies are static geometry: walls, floors, terrain. They never move and are not affected by any forces or collisions.

Source

pub fn mass(&self) -> f32

The mass of this rigid body in kilograms.

Returns zero for fixed bodies (which technically have infinite mass). Mass is computed from attached colliders’ shapes and densities.

Source

pub fn next_position(&self) -> &Isometry<f32>

The predicted position of this rigid-body.

If this rigid-body is kinematic this value is set by the set_next_kinematic_position method and is used for estimating the kinematic body velocity at the next timestep. For non-kinematic bodies, this value is currently unspecified.

Source

pub fn gravity_scale(&self) -> f32

The gravity scale multiplier for this body.

  • 1.0 (default) = normal gravity
  • 0.0 = no gravity (floating)
  • 2.0 = double gravity (heavy/fast falling)
  • Negative values = reverse gravity (objects fall upward!)
Source

pub fn set_gravity_scale(&mut self, scale: f32, wake_up: bool)

Sets how much gravity affects this body (multiplier).

§Examples
bodies[body].set_gravity_scale(0.0, true);  // Zero-G (space)
bodies[body].set_gravity_scale(0.1, true);  // Moon gravity
bodies[body].set_gravity_scale(2.0, true);  // Extra heavy
Source

pub fn dominance_group(&self) -> i8

The dominance group of this rigid-body.

Source

pub fn set_dominance_group(&mut self, dominance: i8)

The dominance group of this rigid-body.

Source

pub fn sleep(&mut self)

Forces this body to sleep immediately (stop simulating it).

Sleeping bodies are excluded from physics simulation until disturbed. Use to manually deactivate bodies you know won’t move for a while.

The body will auto-wake if:

  • Hit by a moving object
  • Connected via joint to a moving body
  • Manually woken with wake_up()
Source

pub fn wake_up(&mut self, strong: bool)

Wakes up this body if it’s sleeping, making it active in the simulation.

§Parameters
  • strong - If true, guarantees the body stays awake for multiple frames. If false, it might sleep again immediately if conditions are met.

Use after manually moving a sleeping body or to keep it active temporarily.

Source

pub fn is_sleeping(&self) -> bool

Is this rigid body sleeping?

Source

pub fn is_moving(&self) -> bool

Returns true if the body has non-zero linear or angular velocity.

Useful for checking if an object is actually moving vs sitting still.

Source

pub fn vels(&self) -> &RigidBodyVelocity<f32>

Returns both linear and angular velocity as a combined structure.

Most users should use linvel() and angvel() separately instead.

Source

pub fn linvel(&self) -> &Vector<f32>

The current linear velocity (speed and direction of movement).

This is how fast the body is moving in units per second. Use with set_linvel() to directly control the body’s movement speed.

Source

pub fn angvel(&self) -> &Vector<f32>

The current angular velocity (rotation speed) in 3D.

Returns a vector in radians per second around each axis (X, Y, Z).

Source

pub fn set_vels(&mut self, vels: RigidBodyVelocity<f32>, wake_up: bool)

Set both the angular and linear velocity of this rigid-body.

If wake_up is true then the rigid-body will be woken up if it was put to sleep because it did not move for a while.

Source

pub fn set_linvel(&mut self, linvel: Vector<f32>, wake_up: bool)

Sets how fast this body is moving (linear velocity).

This directly sets the body’s velocity without applying forces. Use for:

  • Player character movement
  • Kinematic object control
  • Instantly changing an object’s speed

For physics-based movement, consider using apply_impulse() or add_force() instead for more realistic behavior.

§Example
// Make the body move to the right at 5 units/second
bodies[body].set_linvel(vector![5.0, 0.0, 0.0], true);
Source

pub fn set_angvel(&mut self, angvel: Vector<f32>, wake_up: bool)

The angular velocity of this rigid-body.

If wake_up is true then the rigid-body will be woken up if it was put to sleep because it did not move for a while.

Source

pub fn position(&self) -> &Isometry<f32>

The current position (translation + rotation) of this rigid body in world space.

Returns an Isometry which combines both translation and rotation. For just the position vector, use translation() instead.

Source

pub fn translation(&self) -> &Vector<f32>

The current position vector of this rigid body (world coordinates).

This is just the XYZ location, without rotation. For the full pose (position + rotation), use position().

Source

pub fn set_translation(&mut self, translation: Vector<f32>, wake_up: bool)

Teleports this rigid body to a new position (world coordinates).

⚠️ Warning: This instantly moves the body, ignoring physics! The body will “teleport” without checking for collisions in between. Use this for:

  • Respawning objects
  • Level transitions
  • Resetting positions

For smooth physics-based movement, use velocities or forces instead.

§Parameters
  • wake_up - If true, prevents the body from immediately going back to sleep
Source

pub fn rotation(&self) -> &Rotation<f32>

The current rotation/orientation of this rigid body.

Source

pub fn set_rotation(&mut self, rotation: Rotation<f32>, wake_up: bool)

Instantly rotates this rigid body to a new orientation.

⚠️ Warning: This teleports the rotation, ignoring physics! See set_translation() for details.

Source

pub fn set_position(&mut self, pos: Isometry<f32>, wake_up: bool)

Teleports this body to a new position and rotation (ignoring physics).

⚠️ Warning: Instantly moves the body without checking for collisions! For position-based kinematic bodies, this also resets their interpolated velocity to zero.

Use for respawning, level transitions, or resetting positions.

Source

pub fn set_next_kinematic_rotation(&mut self, rotation: Rotation<f32>)

For position-based kinematic bodies: sets where the body should rotate to by next frame.

Only works for KinematicPositionBased bodies. Rapier computes the angular velocity needed to reach this rotation smoothly.

Source

pub fn set_next_kinematic_translation(&mut self, translation: Vector<f32>)

For position-based kinematic bodies: sets where the body should move to by next frame.

Only works for KinematicPositionBased bodies. Rapier computes the velocity needed to reach this position smoothly.

Source

pub fn set_next_kinematic_position(&mut self, pos: Isometry<f32>)

For position-based kinematic bodies: sets the target pose (position + rotation) for next frame.

Only works for KinematicPositionBased bodies. Combines translation and rotation control.

Source

pub fn predict_position_using_velocity_and_forces( &self, dt: f32, ) -> Isometry<f32>

Calculates where this body will be after dt seconds, considering current velocity AND forces.

Useful for predicting future positions or implementing custom integration. Accounts for gravity and applied forces.

Source

pub fn predict_position_using_velocity(&self, dt: f32) -> Isometry<f32>

Calculates where this body will be after dt seconds, considering only current velocity (not forces).

Like predict_position_using_velocity_and_forces() but ignores applied forces. Useful when you only care about inertial motion without acceleration.

Source§

impl RigidBody

§Applying forces and torques
Source

pub fn reset_forces(&mut self, wake_up: bool)

Clears all forces that were added with add_force().

Forces are automatically cleared each physics step, so you rarely need this. Useful if you want to cancel forces mid-frame.

Source

pub fn reset_torques(&mut self, wake_up: bool)

Clears all torques that were added with add_torque().

Torques are automatically cleared each physics step. Rarely needed.

Source

pub fn add_force(&mut self, force: Vector<f32>, wake_up: bool)

Applies a continuous force to this body (like thrust, wind, or magnets).

Unlike apply_impulse() which is instant, forces are applied continuously over time and accumulate until the next physics step. Use for:

  • Rocket/jet thrust
  • Wind or water currents
  • Magnetic/gravity fields
  • Continuous pushing/pulling

Forces are automatically cleared after each physics step, so you typically call this every frame if you want continuous force application.

§Example
// Apply thrust every frame
bodies[body].add_force(vector![0.0, 100.0, 0.0], true);

Only affects dynamic bodies (does nothing for kinematic/fixed bodies).

Source

pub fn add_torque(&mut self, torque: Vector<f32>, wake_up: bool)

Applies a continuous rotational force (torque) to spin this body.

Like add_force() but for rotation. In 3D, the torque vector direction determines the rotation axis (right-hand rule).

Only affects dynamic bodies.

Source

pub fn add_force_at_point( &mut self, force: Vector<f32>, point: Point<f32>, wake_up: bool, )

Applies force at a specific point on the body (creates both force and torque).

When you push an object off-center, it both moves AND spins. This method handles both effects. The force creates linear acceleration, and the offset from center-of-mass creates torque.

Use for: Forces applied at contact points, explosions at specific locations, pushing objects.

§Parameters
  • force - The force vector to apply
  • point - Where to apply the force (world coordinates)

Only affects dynamic bodies.

Source§

impl RigidBody

§Applying impulses and angular impulses
Source

pub fn apply_impulse(&mut self, impulse: Vector<f32>, wake_up: bool)

Instantly changes the velocity by applying an impulse (like a kick or explosion).

An impulse is an instant change in momentum. Think of it as a “one-time push” that immediately affects velocity. Use for:

  • Jumping (apply upward impulse)
  • Explosions pushing objects away
  • Getting hit by something
  • Launching projectiles

The effect depends on the body’s mass - heavier objects will be affected less by the same impulse.

For continuous forces (like rocket thrust or wind), use add_force() instead.

§Example
// Make a character jump
bodies[body].apply_impulse(vector![0.0, 300.0, 0.0], true);

Only affects dynamic bodies (does nothing for kinematic/fixed bodies).

Source

pub fn apply_torque_impulse( &mut self, torque_impulse: Vector<f32>, wake_up: bool, )

Instantly changes rotation speed by applying angular impulse (like a sudden spin).

In 3D, the impulse vector direction determines the spin axis (right-hand rule). Like apply_impulse() but for rotation. Only affects dynamic bodies.

Source

pub fn apply_impulse_at_point( &mut self, impulse: Vector<f32>, point: Point<f32>, wake_up: bool, )

Applies impulse at a specific point on the body (creates both linear and angular effects).

Like add_force_at_point() but instant instead of continuous. When you hit an object off-center, it both flies away AND spins - this method handles both.

§Example
// Hit the top-left corner of a box
bodies[body].apply_impulse_at_point(
    vector![100.0, 0.0, 0.0],
    point![-0.5, 0.5, 0.0],  // Top-left of a 1x1 box
    true
);
// Box will move right AND spin

Only affects dynamic bodies.

Source

pub fn user_force(&self) -> Vector<f32>

Returns the total force currently queued to be applied this frame.

This is the sum of all add_force() calls since the last physics step. Returns zero for non-dynamic bodies.

Source

pub fn user_torque(&self) -> AngVector<f32>

Returns the total torque currently queued to be applied this frame.

This is the sum of all add_torque() calls since the last physics step. Returns zero for non-dynamic bodies.

Source

pub fn gyroscopic_forces_enabled(&self) -> bool

Checks if gyroscopic forces are enabled (3D only).

Gyroscopic forces cause spinning objects to resist changes in rotation axis (like how spinning tops stay upright). Adds slight CPU cost.

Source

pub fn enable_gyroscopic_forces(&mut self, enabled: bool)

Enables/disables gyroscopic forces for more realistic spinning behavior.

When enabled, rapidly spinning objects resist rotation axis changes (like gyroscopes). Examples: spinning tops, flywheels, rotating spacecraft.

Default: Disabled (costs performance, rarely needed in games).

Source§

impl RigidBody

Source

pub fn velocity_at_point(&self, point: &Point<f32>) -> Vector<f32>

Calculates the velocity at a specific point on this body.

Due to rotation, different points on a rigid body move at different speeds. This computes the linear velocity at any world-space point.

Useful for: impact calculations, particle effects, sound volume based on impact speed.

Source

pub fn kinetic_energy(&self) -> f32

Calculates the kinetic energy of this body (energy from motion).

Returns 0.5 * mass * velocity² + 0.5 * inertia * angular_velocity² Useful for physics-based gameplay (energy tracking, damage based on impact energy).

Source

pub fn gravitational_potential_energy( &self, dt: f32, gravity: Vector<f32>, ) -> f32

Calculates the gravitational potential energy of this body.

Returns mass * gravity * height. Useful for energy conservation checks.

Source

pub fn angvel_with_gyroscopic_forces(&self, dt: f32) -> AngVector<f32>

Computes the angular velocity of this rigid-body after application of gyroscopic forces.

Trait Implementations§

Source§

impl Clone for RigidBody

Source§

fn clone(&self) -> RigidBody

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 RigidBody

Source§

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

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

impl Default for RigidBody

Source§

fn default() -> Self

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

impl From<RigidBodyBuilder> for RigidBody

Source§

fn from(val: RigidBodyBuilder) -> RigidBody

Converts to this type from the input type.
Source§

impl HasModifiedFlag for RigidBody

Source§

fn has_modified_flag(&self) -> bool

Whether the object has been modified
Source§

fn set_modified_flag(&mut self)

Mark object as modified

Auto Trait Implementations§

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> 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> 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> 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_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

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

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

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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> 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.