Struct bevy::math::bounding::BoundingCircle
pub struct BoundingCircle {
pub center: Vec2,
pub circle: Circle,
}
Expand description
A bounding circle
Fields§
§center: Vec2
The center of the bounding circle
circle: Circle
The circle
Implementations§
§impl BoundingCircle
impl BoundingCircle
pub fn new(center: Vec2, radius: f32) -> BoundingCircle
pub fn new(center: Vec2, radius: f32) -> BoundingCircle
Constructs a bounding circle from its center and radius.
Examples found in repository?
examples/2d/bounding_2d.rs (line 375)
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438
fn bounding_circle_cast_system(
mut gizmos: Gizmos,
time: Res<Time>,
mut volumes: Query<(&CurrentVolume, &mut Intersects)>,
) {
let ray_cast = get_and_draw_ray(&mut gizmos, &time);
let circle_cast = BoundingCircleCast {
circle: BoundingCircle::new(Vec2::ZERO, 15.),
ray: ray_cast,
};
for (volume, mut intersects) in volumes.iter_mut() {
let toi = match *volume {
CurrentVolume::Aabb(_) => None,
CurrentVolume::Circle(c) => circle_cast.circle_collision_at(c),
};
**intersects = toi.is_some();
if let Some(toi) = toi {
gizmos.circle_2d(
circle_cast.ray.ray.origin + *circle_cast.ray.ray.direction * toi,
circle_cast.circle.radius(),
LIME,
);
}
}
}
fn get_intersection_position(time: &Time) -> Vec2 {
let x = (0.8 * time.elapsed_seconds()).cos() * 250.;
let y = (0.4 * time.elapsed_seconds()).sin() * 100.;
Vec2::new(x, y)
}
fn aabb_intersection_system(
mut gizmos: Gizmos,
time: Res<Time>,
mut volumes: Query<(&CurrentVolume, &mut Intersects)>,
) {
let center = get_intersection_position(&time);
let aabb = Aabb2d::new(center, Vec2::splat(50.));
gizmos.rect_2d(center, 0., aabb.half_size() * 2., YELLOW);
for (volume, mut intersects) in volumes.iter_mut() {
let hit = match volume {
CurrentVolume::Aabb(a) => aabb.intersects(a),
CurrentVolume::Circle(c) => aabb.intersects(c),
};
**intersects = hit;
}
}
fn circle_intersection_system(
mut gizmos: Gizmos,
time: Res<Time>,
mut volumes: Query<(&CurrentVolume, &mut Intersects)>,
) {
let center = get_intersection_position(&time);
let circle = BoundingCircle::new(center, 50.);
gizmos.circle_2d(center, circle.radius(), YELLOW);
for (volume, mut intersects) in volumes.iter_mut() {
let hit = match volume {
CurrentVolume::Aabb(a) => circle.intersects(a),
CurrentVolume::Circle(c) => circle.intersects(c),
};
**intersects = hit;
}
}
More examples
examples/games/breakout.rs (line 371)
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
fn check_for_collisions(
mut commands: Commands,
mut score: ResMut<Score>,
mut ball_query: Query<(&mut Velocity, &Transform), With<Ball>>,
collider_query: Query<(Entity, &Transform, Option<&Brick>), With<Collider>>,
mut collision_events: EventWriter<CollisionEvent>,
) {
let (mut ball_velocity, ball_transform) = ball_query.single_mut();
for (collider_entity, collider_transform, maybe_brick) in &collider_query {
let collision = ball_collision(
BoundingCircle::new(ball_transform.translation.truncate(), BALL_DIAMETER / 2.),
Aabb2d::new(
collider_transform.translation.truncate(),
collider_transform.scale.truncate() / 2.,
),
);
if let Some(collision) = collision {
// Sends a collision event so that other systems can react to the collision
collision_events.send_default();
// Bricks should be despawned and increment the scoreboard on collision
if maybe_brick.is_some() {
commands.entity(collider_entity).despawn();
**score += 1;
}
// Reflect the ball's velocity when it collides
let mut reflect_x = false;
let mut reflect_y = false;
// Reflect only if the velocity is in the opposite direction of the collision
// This prevents the ball from getting stuck inside the bar
match collision {
Collision::Left => reflect_x = ball_velocity.x > 0.0,
Collision::Right => reflect_x = ball_velocity.x < 0.0,
Collision::Top => reflect_y = ball_velocity.y < 0.0,
Collision::Bottom => reflect_y = ball_velocity.y > 0.0,
}
// Reflect velocity on the x-axis if we hit something on the x-axis
if reflect_x {
ball_velocity.x = -ball_velocity.x;
}
// Reflect velocity on the y-axis if we hit something on the y-axis
if reflect_y {
ball_velocity.y = -ball_velocity.y;
}
}
}
}
pub fn from_point_cloud(
translation: Vec2,
rotation: impl Into<Rotation2d>,
points: &[Vec2]
) -> BoundingCircle
pub fn from_point_cloud( translation: Vec2, rotation: impl Into<Rotation2d>, points: &[Vec2] ) -> BoundingCircle
Computes a BoundingCircle
containing the given set of points,
transformed by translation
and rotation
.
The bounding circle is not guaranteed to be the smallest possible.
pub fn radius(&self) -> f32
pub fn radius(&self) -> f32
Get the radius of the bounding circle
Examples found in repository?
examples/2d/bounding_2d.rs (line 186)
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438
fn render_volumes(mut gizmos: Gizmos, query: Query<(&CurrentVolume, &Intersects)>) {
for (volume, intersects) in query.iter() {
let color = if **intersects { AQUA } else { ORANGE_RED };
match volume {
CurrentVolume::Aabb(a) => {
gizmos.rect_2d(a.center(), 0., a.half_size() * 2., color);
}
CurrentVolume::Circle(c) => {
gizmos.circle_2d(c.center(), c.radius(), color);
}
}
}
}
#[derive(Component, Deref, DerefMut, Default)]
struct Intersects(bool);
const OFFSET_X: f32 = 125.;
const OFFSET_Y: f32 = 75.;
fn setup(mut commands: Commands, loader: Res<AssetServer>) {
commands.spawn(Camera2dBundle::default());
commands.spawn((
SpatialBundle {
transform: Transform::from_xyz(-OFFSET_X, OFFSET_Y, 0.),
..default()
},
Shape::Circle(Circle::new(45.)),
DesiredVolume::Aabb,
Intersects::default(),
));
commands.spawn((
SpatialBundle {
transform: Transform::from_xyz(0., OFFSET_Y, 0.),
..default()
},
Shape::Rectangle(Rectangle::new(80., 80.)),
Spin,
DesiredVolume::Circle,
Intersects::default(),
));
commands.spawn((
SpatialBundle {
transform: Transform::from_xyz(OFFSET_X, OFFSET_Y, 0.),
..default()
},
Shape::Triangle(Triangle2d::new(
Vec2::new(-40., -40.),
Vec2::new(-20., 40.),
Vec2::new(40., 50.),
)),
Spin,
DesiredVolume::Aabb,
Intersects::default(),
));
commands.spawn((
SpatialBundle {
transform: Transform::from_xyz(-OFFSET_X, -OFFSET_Y, 0.),
..default()
},
Shape::Line(Segment2d::new(Dir2::from_xy(1., 0.3).unwrap(), 90.)),
Spin,
DesiredVolume::Circle,
Intersects::default(),
));
commands.spawn((
SpatialBundle {
transform: Transform::from_xyz(0., -OFFSET_Y, 0.),
..default()
},
Shape::Capsule(Capsule2d::new(25., 50.)),
Spin,
DesiredVolume::Aabb,
Intersects::default(),
));
commands.spawn((
SpatialBundle {
transform: Transform::from_xyz(OFFSET_X, -OFFSET_Y, 0.),
..default()
},
Shape::Polygon(RegularPolygon::new(50., 6)),
Spin,
DesiredVolume::Circle,
Intersects::default(),
));
commands.spawn(
TextBundle::from_section(
"",
TextStyle {
font: loader.load("fonts/FiraMono-Medium.ttf"),
font_size: 26.0,
..default()
},
)
.with_style(Style {
position_type: PositionType::Absolute,
bottom: Val::Px(10.0),
left: Val::Px(10.0),
..default()
}),
);
}
fn draw_filled_circle(gizmos: &mut Gizmos, position: Vec2, color: Srgba) {
for r in [1., 2., 3.] {
gizmos.circle_2d(position, r, color);
}
}
fn draw_ray(gizmos: &mut Gizmos, ray: &RayCast2d) {
gizmos.line_2d(
ray.ray.origin,
ray.ray.origin + *ray.ray.direction * ray.max,
WHITE,
);
draw_filled_circle(gizmos, ray.ray.origin, FUCHSIA);
}
fn get_and_draw_ray(gizmos: &mut Gizmos, time: &Time) -> RayCast2d {
let ray = Vec2::new(time.elapsed_seconds().cos(), time.elapsed_seconds().sin());
let dist = 150. + (0.5 * time.elapsed_seconds()).sin().abs() * 500.;
let aabb_ray = Ray2d {
origin: ray * 250.,
direction: Dir2::new_unchecked(-ray),
};
let ray_cast = RayCast2d::from_ray(aabb_ray, dist - 20.);
draw_ray(gizmos, &ray_cast);
ray_cast
}
fn ray_cast_system(
mut gizmos: Gizmos,
time: Res<Time>,
mut volumes: Query<(&CurrentVolume, &mut Intersects)>,
) {
let ray_cast = get_and_draw_ray(&mut gizmos, &time);
for (volume, mut intersects) in volumes.iter_mut() {
let toi = match volume {
CurrentVolume::Aabb(a) => ray_cast.aabb_intersection_at(a),
CurrentVolume::Circle(c) => ray_cast.circle_intersection_at(c),
};
**intersects = toi.is_some();
if let Some(toi) = toi {
draw_filled_circle(
&mut gizmos,
ray_cast.ray.origin + *ray_cast.ray.direction * toi,
LIME,
);
}
}
}
fn aabb_cast_system(
mut gizmos: Gizmos,
time: Res<Time>,
mut volumes: Query<(&CurrentVolume, &mut Intersects)>,
) {
let ray_cast = get_and_draw_ray(&mut gizmos, &time);
let aabb_cast = AabbCast2d {
aabb: Aabb2d::new(Vec2::ZERO, Vec2::splat(15.)),
ray: ray_cast,
};
for (volume, mut intersects) in volumes.iter_mut() {
let toi = match *volume {
CurrentVolume::Aabb(a) => aabb_cast.aabb_collision_at(a),
CurrentVolume::Circle(_) => None,
};
**intersects = toi.is_some();
if let Some(toi) = toi {
gizmos.rect_2d(
aabb_cast.ray.ray.origin + *aabb_cast.ray.ray.direction * toi,
0.,
aabb_cast.aabb.half_size() * 2.,
LIME,
);
}
}
}
fn bounding_circle_cast_system(
mut gizmos: Gizmos,
time: Res<Time>,
mut volumes: Query<(&CurrentVolume, &mut Intersects)>,
) {
let ray_cast = get_and_draw_ray(&mut gizmos, &time);
let circle_cast = BoundingCircleCast {
circle: BoundingCircle::new(Vec2::ZERO, 15.),
ray: ray_cast,
};
for (volume, mut intersects) in volumes.iter_mut() {
let toi = match *volume {
CurrentVolume::Aabb(_) => None,
CurrentVolume::Circle(c) => circle_cast.circle_collision_at(c),
};
**intersects = toi.is_some();
if let Some(toi) = toi {
gizmos.circle_2d(
circle_cast.ray.ray.origin + *circle_cast.ray.ray.direction * toi,
circle_cast.circle.radius(),
LIME,
);
}
}
}
fn get_intersection_position(time: &Time) -> Vec2 {
let x = (0.8 * time.elapsed_seconds()).cos() * 250.;
let y = (0.4 * time.elapsed_seconds()).sin() * 100.;
Vec2::new(x, y)
}
fn aabb_intersection_system(
mut gizmos: Gizmos,
time: Res<Time>,
mut volumes: Query<(&CurrentVolume, &mut Intersects)>,
) {
let center = get_intersection_position(&time);
let aabb = Aabb2d::new(center, Vec2::splat(50.));
gizmos.rect_2d(center, 0., aabb.half_size() * 2., YELLOW);
for (volume, mut intersects) in volumes.iter_mut() {
let hit = match volume {
CurrentVolume::Aabb(a) => aabb.intersects(a),
CurrentVolume::Circle(c) => aabb.intersects(c),
};
**intersects = hit;
}
}
fn circle_intersection_system(
mut gizmos: Gizmos,
time: Res<Time>,
mut volumes: Query<(&CurrentVolume, &mut Intersects)>,
) {
let center = get_intersection_position(&time);
let circle = BoundingCircle::new(center, 50.);
gizmos.circle_2d(center, circle.radius(), YELLOW);
for (volume, mut intersects) in volumes.iter_mut() {
let hit = match volume {
CurrentVolume::Aabb(a) => circle.intersects(a),
CurrentVolume::Circle(c) => circle.intersects(c),
};
**intersects = hit;
}
}
pub fn aabb_2d(&self) -> Aabb2d
pub fn aabb_2d(&self) -> Aabb2d
Computes the smallest Aabb2d
containing this BoundingCircle
.
pub fn closest_point(&self, point: Vec2) -> Vec2
pub fn closest_point(&self, point: Vec2) -> Vec2
Finds the point on the bounding circle that is closest to the given point
.
If the point is outside the circle, the returned point will be on the perimeter of the circle. Otherwise, it will be inside the circle and returned as is.
Trait Implementations§
§impl BoundingVolume for BoundingCircle
impl BoundingVolume for BoundingCircle
§type Translation = Vec2
type Translation = Vec2
The position type used for the volume. This should be
Vec2
for 2D and Vec3
for 3D.§type Rotation = Rotation2d
type Rotation = Rotation2d
The rotation type used for the volume. This should be
f32
for 2D and Quat
for 3D.§type HalfSize = f32
type HalfSize = f32
The type used for the size of the bounding volume. Usually a half size. For example an
f32
radius for a circle, or a Vec3
with half sizes for x, y and z for a 3D axis-aligned
bounding box§fn center(&self) -> <BoundingCircle as BoundingVolume>::Translation
fn center(&self) -> <BoundingCircle as BoundingVolume>::Translation
Returns the center of the bounding volume.
§fn half_size(&self) -> <BoundingCircle as BoundingVolume>::HalfSize
fn half_size(&self) -> <BoundingCircle as BoundingVolume>::HalfSize
Returns the half size of the bounding volume.
§fn visible_area(&self) -> f32
fn visible_area(&self) -> f32
Computes the visible surface area of the bounding volume.
This method can be useful to make decisions about merging bounding volumes,
using a Surface Area Heuristic. Read more
§fn contains(&self, other: &BoundingCircle) -> bool
fn contains(&self, other: &BoundingCircle) -> bool
Checks if this bounding volume contains another one.
§fn merge(&self, other: &BoundingCircle) -> BoundingCircle
fn merge(&self, other: &BoundingCircle) -> BoundingCircle
Computes the smallest bounding volume that contains both
self
and other
.§fn grow(
&self,
amount: impl Into<<BoundingCircle as BoundingVolume>::HalfSize>
) -> BoundingCircle
fn grow( &self, amount: impl Into<<BoundingCircle as BoundingVolume>::HalfSize> ) -> BoundingCircle
Increases the size of the bounding volume in each direction by the given amount.
§fn shrink(
&self,
amount: impl Into<<BoundingCircle as BoundingVolume>::HalfSize>
) -> BoundingCircle
fn shrink( &self, amount: impl Into<<BoundingCircle as BoundingVolume>::HalfSize> ) -> BoundingCircle
Decreases the size of the bounding volume in each direction by the given amount.
§fn scale_around_center(
&self,
scale: impl Into<<BoundingCircle as BoundingVolume>::HalfSize>
) -> BoundingCircle
fn scale_around_center( &self, scale: impl Into<<BoundingCircle as BoundingVolume>::HalfSize> ) -> BoundingCircle
Scale the size of the bounding volume around its center by the given amount
§fn translate_by(
&mut self,
translation: impl Into<<BoundingCircle as BoundingVolume>::Translation>
)
fn translate_by( &mut self, translation: impl Into<<BoundingCircle as BoundingVolume>::Translation> )
Translates the bounding volume by the given translation.
§fn rotate_by(
&mut self,
rotation: impl Into<<BoundingCircle as BoundingVolume>::Rotation>
)
fn rotate_by( &mut self, rotation: impl Into<<BoundingCircle as BoundingVolume>::Rotation> )
Rotates the bounding volume around the origin by the given rotation. Read more
§fn transformed_by(
self,
translation: impl Into<Self::Translation>,
rotation: impl Into<Self::Rotation>
) -> Self
fn transformed_by( self, translation: impl Into<Self::Translation>, rotation: impl Into<Self::Rotation> ) -> Self
Transforms the bounding volume by first rotating it around the origin and then applying a translation.
§fn transform_by(
&mut self,
translation: impl Into<Self::Translation>,
rotation: impl Into<Self::Rotation>
)
fn transform_by( &mut self, translation: impl Into<Self::Translation>, rotation: impl Into<Self::Rotation> )
Transforms the bounding volume by first rotating it around the origin and then applying a translation.
§fn translated_by(self, translation: impl Into<Self::Translation>) -> Self
fn translated_by(self, translation: impl Into<Self::Translation>) -> Self
Translates the bounding volume by the given translation.
§fn rotated_by(self, rotation: impl Into<Self::Rotation>) -> Self
fn rotated_by(self, rotation: impl Into<Self::Rotation>) -> Self
Rotates the bounding volume around the origin by the given rotation. Read more
§impl Clone for BoundingCircle
impl Clone for BoundingCircle
§fn clone(&self) -> BoundingCircle
fn clone(&self) -> BoundingCircle
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more§impl Debug for BoundingCircle
impl Debug for BoundingCircle
§impl IntersectsVolume<Aabb2d> for BoundingCircle
impl IntersectsVolume<Aabb2d> for BoundingCircle
§fn intersects(&self, aabb: &Aabb2d) -> bool
fn intersects(&self, aabb: &Aabb2d) -> bool
Check if a volume intersects with this intersection test
§impl IntersectsVolume<BoundingCircle> for Aabb2d
impl IntersectsVolume<BoundingCircle> for Aabb2d
§fn intersects(&self, circle: &BoundingCircle) -> bool
fn intersects(&self, circle: &BoundingCircle) -> bool
Check if a volume intersects with this intersection test
§impl IntersectsVolume<BoundingCircle> for BoundingCircle
impl IntersectsVolume<BoundingCircle> for BoundingCircle
§fn intersects(&self, other: &BoundingCircle) -> bool
fn intersects(&self, other: &BoundingCircle) -> bool
Check if a volume intersects with this intersection test
§impl IntersectsVolume<BoundingCircle> for BoundingCircleCast
impl IntersectsVolume<BoundingCircle> for BoundingCircleCast
§fn intersects(&self, volume: &BoundingCircle) -> bool
fn intersects(&self, volume: &BoundingCircle) -> bool
Check if a volume intersects with this intersection test
§impl IntersectsVolume<BoundingCircle> for RayCast2d
impl IntersectsVolume<BoundingCircle> for RayCast2d
§fn intersects(&self, volume: &BoundingCircle) -> bool
fn intersects(&self, volume: &BoundingCircle) -> bool
Check if a volume intersects with this intersection test
impl Copy for BoundingCircle
Auto Trait Implementations§
impl Freeze for BoundingCircle
impl RefUnwindSafe for BoundingCircle
impl Send for BoundingCircle
impl Sync for BoundingCircle
impl Unpin for BoundingCircle
impl UnwindSafe for BoundingCircle
Blanket Implementations§
§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
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
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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
.§fn as_any(&self) -> &(dyn Any + 'static)
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.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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