Expand description
A 2D size, also known as an extent
This is both a size and a relative position. One can add or subtract a size
from a Coord
. One can multiply a size by a scalar.
A Size
is expected to be non-negative; some methods such as Size::new
and implementations of subtraction will check this, but only in debug mode
(similar to overflow checks on integers).
Subtraction is defined to be saturating subtraction.
This may be converted to Offset
with from
/ into
.
Tuple Fields§
§0: i32
§1: i32
Implementations§
source§impl Size
impl Size
sourcepub fn as_physical(self) -> Size
Available on crate feature winit
only.
pub fn as_physical(self) -> Size
winit
only.Convert to a “physical” winit::dpi::Size
This implies that the Size
was calculated using the correct
scale factor. Before the window has been constructed (when the
scale factor is supposedly unknown) this should not be used.
sourcepub fn as_logical(self) -> Size
Available on crate feature winit
only.
pub fn as_logical(self) -> Size
winit
only.Convert to a “logical” winit::dpi::Size
This implies that the Size
was calculated using scale_factor = 1
.
source§impl Size
impl Size
sourcepub fn min(self, other: Self) -> Self
pub fn min(self, other: Self) -> Self
Return the minimum, componentwise
Examples found in repository?
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
pub fn align_rect(&mut self, rect: Rect, scale_factor: f32) -> Rect {
let mut size = rect.size;
if self.stretch == Stretch::None {
let ideal = self.size.to_physical(scale_factor * self.ideal_factor);
size = size.min(ideal);
}
if self.fix_aspect {
let logical_size = Vec2::from(self.size);
let Vec2(rw, rh) = Vec2::conv(size) / logical_size;
// Use smaller ratio, if any is finite
if rw < rh {
size.1 = i32::conv_nearest(rw * logical_size.1);
} else if rh < rw {
size.0 = i32::conv_nearest(rh * logical_size.0);
}
}
self.align.aligned_rect(size, rect)
}
sourcepub fn clamp(self, min: Self, max: Self) -> Self
pub fn clamp(self, min: Self, max: Self) -> Self
Restrict a value to the specified interval, componentwise
sourcepub fn distance_l1(self) -> i32
pub fn distance_l1(self) -> i32
Return the L1 (rectilinear / taxicab) distance
sourcepub fn distance_l_inf(self) -> i32
pub fn distance_l_inf(self) -> i32
Return the L-inf (max) distance
sourcepub fn extract<D: Directional>(self, dir: D) -> i32
pub fn extract<D: Directional>(self, dir: D) -> i32
Extract one component, based on a direction
This merely extracts the horizontal or vertical component. It never negates it, even if the axis is reversed.
Examples found in repository?
More examples
253 254 255 256 257 258 259 260 261 262 263 264 265 266
pub fn size_rules(&mut self, mgr: SizeMgr, axis: AxisInfo) -> SizeRules {
let margins = mgr.margins(self.margins).extract(axis);
let scale_factor = mgr.scale_factor();
let min = self
.size
.to_physical(scale_factor * self.min_factor)
.extract(axis);
let ideal = self
.size
.to_physical(scale_factor * self.ideal_factor)
.extract(axis);
self.align.set_component(axis, axis.align_or_center());
SizeRules::new(min, ideal, margins, self.stretch)
}
sourcepub fn set_component<D: Directional>(&mut self, dir: D, value: i32)
pub fn set_component<D: Directional>(&mut self, dir: D, value: i32)
Set one component of self, based on a direction
This does not negate components when the direction is reversed.
Examples found in repository?
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 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548
fn size_rules_(&mut self, mgr: SizeMgr, axis: AxisInfo) -> SizeRules {
match &mut self.layout {
LayoutType::None => SizeRules::EMPTY,
LayoutType::Component(component) => component.size_rules(mgr, axis),
LayoutType::BoxComponent(component) => component.size_rules(mgr, axis),
LayoutType::Single(child) => child.size_rules(mgr, axis),
LayoutType::AlignSingle(child, hints) => {
child.size_rules(mgr, axis.with_align_hints(*hints))
}
LayoutType::Align(layout, hints) => {
layout.size_rules_(mgr, axis.with_align_hints(*hints))
}
LayoutType::Pack(layout, stor, hints) => {
let rules = layout.size_rules_(mgr, stor.apply_align(axis, *hints));
stor.size.set_component(axis, rules.ideal_size());
rules
}
LayoutType::Margins(child, dirs, margins) => {
let mut child_rules = child.size_rules_(mgr.re(), axis);
if dirs.intersects(Directions::from(axis)) {
let mut rule_margins = child_rules.margins();
let margins = mgr.margins(*margins).extract(axis);
if dirs.intersects(Directions::LEFT | Directions::UP) {
rule_margins.0 = margins.0;
}
if dirs.intersects(Directions::RIGHT | Directions::DOWN) {
rule_margins.1 = margins.1;
}
child_rules.set_margins(rule_margins);
}
child_rules
}
LayoutType::Frame(child, storage, style) => {
let child_rules = child.size_rules_(mgr.re(), storage.child_axis(axis));
storage.size_rules(mgr, axis, child_rules, *style)
}
LayoutType::Button(child, storage, _) => {
let child_rules = child.size_rules_(mgr.re(), storage.child_axis_centered(axis));
storage.size_rules(mgr, axis, child_rules, FrameStyle::Button)
}
}
}
/// Apply a given `rect` to self
#[inline]
pub fn set_rect(mut self, mgr: &mut ConfigMgr, rect: Rect) {
self.set_rect_(mgr, rect);
}
fn set_rect_(&mut self, mgr: &mut ConfigMgr, rect: Rect) {
match &mut self.layout {
LayoutType::None => (),
LayoutType::Component(component) => component.set_rect(mgr, rect),
LayoutType::BoxComponent(layout) => layout.set_rect(mgr, rect),
LayoutType::Single(child) => child.set_rect(mgr, rect),
LayoutType::Align(layout, _) => layout.set_rect_(mgr, rect),
LayoutType::AlignSingle(child, _) => child.set_rect(mgr, rect),
LayoutType::Pack(layout, stor, _) => layout.set_rect_(mgr, stor.aligned_rect(rect)),
LayoutType::Margins(child, _, _) => child.set_rect_(mgr, rect),
LayoutType::Frame(child, storage, _) | LayoutType::Button(child, storage, _) => {
storage.rect = rect;
let child_rect = Rect {
pos: rect.pos + storage.offset,
size: rect.size - storage.size,
};
child.set_rect_(mgr, child_rect);
}
}
}
/// Find a widget by coordinate
///
/// Does not return the widget's own identifier. See example usage in
/// [`Visitor::find_id`].
#[inline]
pub fn find_id(mut self, coord: Coord) -> Option<WidgetId> {
self.find_id_(coord)
}
fn find_id_(&mut self, coord: Coord) -> Option<WidgetId> {
match &mut self.layout {
LayoutType::None => None,
LayoutType::Component(component) => component.find_id(coord),
LayoutType::BoxComponent(layout) => layout.find_id(coord),
LayoutType::Single(child) | LayoutType::AlignSingle(child, _) => child.find_id(coord),
LayoutType::Align(layout, _) => layout.find_id_(coord),
LayoutType::Pack(layout, _, _) => layout.find_id_(coord),
LayoutType::Margins(layout, _, _) => layout.find_id_(coord),
LayoutType::Frame(child, _, _) => child.find_id_(coord),
// Buttons steal clicks, hence Button never returns ID of content
LayoutType::Button(_, _, _) => None,
}
}
/// Draw a widget's children
#[inline]
pub fn draw(mut self, draw: DrawMgr) {
self.draw_(draw);
}
fn draw_(&mut self, mut draw: DrawMgr) {
match &mut self.layout {
LayoutType::None => (),
LayoutType::Component(component) => component.draw(draw),
LayoutType::BoxComponent(layout) => layout.draw(draw),
LayoutType::Single(child) | LayoutType::AlignSingle(child, _) => draw.recurse(*child),
LayoutType::Align(layout, _) => layout.draw_(draw),
LayoutType::Pack(layout, _, _) => layout.draw_(draw),
LayoutType::Margins(layout, _, _) => layout.draw_(draw),
LayoutType::Frame(child, storage, style) => {
draw.frame(storage.rect, *style, Background::Default);
child.draw_(draw);
}
LayoutType::Button(child, storage, color) => {
let bg = match color {
Some(rgb) => Background::Rgb(*rgb),
None => Background::Default,
};
draw.frame(storage.rect, FrameStyle::Button, bg);
child.draw_(draw);
}
}
}
}
/// Implement row/column layout for children
struct List<'a, S, D, I> {
data: &'a mut S,
direction: D,
children: I,
}
impl<'a, S: RowStorage, D: Directional, I> Layout for List<'a, S, D, I>
where
I: ExactSizeIterator<Item = Visitor<'a>>,
{
fn size_rules(&mut self, mgr: SizeMgr, axis: AxisInfo) -> SizeRules {
let dim = (self.direction, self.children.len());
let mut solver = RowSolver::new(axis, dim, self.data);
for (n, child) in (&mut self.children).enumerate() {
solver.for_child(self.data, n, |axis| child.size_rules(mgr.re(), axis));
}
solver.finish(self.data)
}
fn set_rect(&mut self, mgr: &mut ConfigMgr, rect: Rect) {
let dim = (self.direction, self.children.len());
let mut setter = RowSetter::<D, Vec<i32>, _>::new(rect, dim, self.data);
for (n, child) in (&mut self.children).enumerate() {
child.set_rect(mgr, setter.child_rect(self.data, n));
}
}
fn find_id(&mut self, coord: Coord) -> Option<WidgetId> {
// TODO(opt): more efficient search strategy?
self.children.find_map(|child| child.find_id(coord))
}
fn draw(&mut self, mut draw: DrawMgr) {
for child in &mut self.children {
child.draw(draw.re_clone());
}
}
}
/// Float layout
struct Float<'a, I>
where
I: DoubleEndedIterator<Item = Visitor<'a>>,
{
children: I,
}
impl<'a, I> Layout for Float<'a, I>
where
I: DoubleEndedIterator<Item = Visitor<'a>>,
{
fn size_rules(&mut self, mgr: SizeMgr, axis: AxisInfo) -> SizeRules {
let mut rules = SizeRules::EMPTY;
for child in &mut self.children {
rules = rules.max(child.size_rules(mgr.re(), axis));
}
rules
}
fn set_rect(&mut self, mgr: &mut ConfigMgr, rect: Rect) {
for child in &mut self.children {
child.set_rect(mgr, rect);
}
}
fn find_id(&mut self, coord: Coord) -> Option<WidgetId> {
self.children.find_map(|child| child.find_id(coord))
}
fn draw(&mut self, mut draw: DrawMgr) {
let mut iter = (&mut self.children).rev();
if let Some(first) = iter.next() {
first.draw(draw.re_clone());
}
for child in iter {
draw.with_pass(|draw| child.draw(draw));
}
}
}
/// A row/column over a slice
struct Slice<'a, W: Widget, D: Directional> {
data: &'a mut DynRowStorage,
direction: D,
children: &'a mut [W],
}
impl<'a, W: Widget, D: Directional> Layout for Slice<'a, W, D> {
fn size_rules(&mut self, mgr: SizeMgr, axis: AxisInfo) -> SizeRules {
let dim = (self.direction, self.children.len());
let mut solver = RowSolver::new(axis, dim, self.data);
for (n, child) in self.children.iter_mut().enumerate() {
solver.for_child(self.data, n, |axis| child.size_rules(mgr.re(), axis));
}
solver.finish(self.data)
}
fn set_rect(&mut self, mgr: &mut ConfigMgr, rect: Rect) {
let dim = (self.direction, self.children.len());
let mut setter = RowSetter::<D, Vec<i32>, _>::new(rect, dim, self.data);
for (n, child) in self.children.iter_mut().enumerate() {
child.set_rect(mgr, setter.child_rect(self.data, n));
}
}
fn find_id(&mut self, coord: Coord) -> Option<WidgetId> {
let solver = RowPositionSolver::new(self.direction);
solver
.find_child_mut(self.children, coord)
.and_then(|child| child.find_id(coord))
}
fn draw(&mut self, mut draw: DrawMgr) {
let solver = RowPositionSolver::new(self.direction);
solver.for_children(self.children, draw.get_clip_rect(), |w| draw.recurse(w));
}
}
/// Implement grid layout for children
struct Grid<'a, S, I> {
data: &'a mut S,
dim: GridDimensions,
children: I,
}
impl<'a, S: GridStorage, I> Layout for Grid<'a, S, I>
where
I: Iterator<Item = (GridChildInfo, Visitor<'a>)>,
{
fn size_rules(&mut self, mgr: SizeMgr, axis: AxisInfo) -> SizeRules {
let mut solver = GridSolver::<Vec<_>, Vec<_>, _>::new(axis, self.dim, self.data);
for (info, child) in &mut self.children {
solver.for_child(self.data, info, |axis| child.size_rules(mgr.re(), axis));
}
solver.finish(self.data)
}
fn set_rect(&mut self, mgr: &mut ConfigMgr, rect: Rect) {
let mut setter = GridSetter::<Vec<_>, Vec<_>, _>::new(rect, self.dim, self.data);
for (info, child) in &mut self.children {
child.set_rect(mgr, setter.child_rect(self.data, info));
}
}
fn find_id(&mut self, coord: Coord) -> Option<WidgetId> {
// TODO(opt): more efficient search strategy?
self.children.find_map(|(_, child)| child.find_id(coord))
}
fn draw(&mut self, mut draw: DrawMgr) {
for (_, child) in &mut self.children {
child.draw(draw.re_clone());
}
}
}
/// Layout storage for alignment
#[derive(Clone, Default, Debug)]
pub struct PackStorage {
align: AlignPair,
size: Size,
}
impl PackStorage {
/// Set alignment
fn apply_align(&mut self, axis: AxisInfo, hints: AlignHints) -> AxisInfo {
let axis = axis.with_align_hints(hints);
self.align.set_component(axis, axis.align_or_default());
axis
}
/// Align rect
fn aligned_rect(&self, rect: Rect) -> Rect {
self.align.aligned_rect(self.size, rect)
}
}
/// Layout storage for frame layout
#[derive(Clone, Default, Debug)]
pub struct FrameStorage {
/// Size used by frame (sum of widths of borders)
pub size: Size,
/// Offset of frame contents from parent position
pub offset: Offset,
// NOTE: potentially rect is redundant (e.g. with widget's rect) but if we
// want an alternative as a generic solution then all draw methods must
// calculate and pass the child's rect, which is probably worse.
rect: Rect,
}
impl FrameStorage {
/// Calculate child's "other axis" size
pub fn child_axis(&self, mut axis: AxisInfo) -> AxisInfo {
axis.sub_other(self.size.extract(axis.flipped()));
axis
}
/// Calculate child's "other axis" size, forcing center-alignment of content
pub fn child_axis_centered(&self, mut axis: AxisInfo) -> AxisInfo {
axis.sub_other(self.size.extract(axis.flipped()));
axis.set_align(Some(Align::Center));
axis
}
/// Generate [`SizeRules`]
pub fn size_rules(
&mut self,
mgr: SizeMgr,
axis: AxisInfo,
child_rules: SizeRules,
style: FrameStyle,
) -> SizeRules {
let frame_rules = mgr.frame(style, axis);
let (rules, offset, size) = frame_rules.surround(child_rules);
self.offset.set_component(axis, offset);
self.size.set_component(axis, size);
rules
}
source§impl Size
impl Size
sourcepub fn new(w: i32, h: i32) -> Self
pub fn new(w: i32, h: i32) -> Self
Construct
In debug mode, this asserts that components are non-negative.
Examples found in repository?
More examples
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
fn resize_popup(&mut self, mgr: &mut ConfigMgr, index: usize) {
// Notation: p=point/coord, s=size, m=margin
// r=window/root rect, c=anchor rect
let r = self.core.rect;
let popup = &mut self.popups[index].1;
let c = find_rect(&self.w, popup.parent.clone()).unwrap();
let widget = self.w.find_widget_mut(&popup.id).unwrap();
let mut cache = layout::SolveCache::find_constraints(widget, mgr.size_mgr());
let ideal = cache.ideal(false);
let m = cache.margins();
let is_reversed = popup.direction.is_reversed();
let place_in = |rp, rs: i32, cp: i32, cs: i32, ideal, m: (u16, u16)| -> (i32, i32) {
let m: (i32, i32) = (m.0.into(), m.1.into());
let before: i32 = cp - (rp + m.1);
let before = before.max(0);
let after = (rs - (cs + before + m.0)).max(0);
if after >= ideal {
if is_reversed && before >= ideal {
(cp - ideal - m.1, ideal)
} else {
(cp + cs + m.0, ideal)
}
} else if before >= ideal {
(cp - ideal - m.1, ideal)
} else if before > after {
(rp, before)
} else {
(cp + cs + m.0, after)
}
};
#[allow(clippy::manual_clamp)]
let place_out = |rp, rs, cp: i32, cs, ideal: i32| -> (i32, i32) {
let pos = cp.min(rp + rs - ideal).max(rp);
let size = ideal.max(cs).min(rs);
(pos, size)
};
let rect = if popup.direction.is_horizontal() {
let (x, w) = place_in(r.pos.0, r.size.0, c.pos.0, c.size.0, ideal.0, m.horiz);
let (y, h) = place_out(r.pos.1, r.size.1, c.pos.1, c.size.1, ideal.1);
Rect::new(Coord(x, y), Size::new(w, h))
} else {
let (x, w) = place_out(r.pos.0, r.size.0, c.pos.0, c.size.0, ideal.0);
let (y, h) = place_in(r.pos.1, r.size.1, c.pos.1, c.size.1, ideal.1, m.vert);
Rect::new(Coord(x, y), Size::new(w, h))
};
cache.apply_rect(widget, mgr, rect, false, true);
}
sourcepub fn splat(n: i32) -> Self
pub fn splat(n: i32) -> Self
Construct, using the same value on all axes
In debug mode, this asserts that components are non-negative.
Examples found in repository?
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602
pub fn shrink(&self, n: i32) -> Rect {
let pos = self.pos + Offset::splat(n);
let size = self.size - Size::splat(n + n);
Rect { pos, size }
}
/// Expand self in all directions by the given `n`
///
/// In debug mode this asserts that `n` is non-negative.
#[inline]
#[must_use = "method does not modify self but returns a new value"]
pub fn expand(&self, n: i32) -> Rect {
debug_assert!(n >= 0);
let pos = self.pos - Offset::splat(n);
let size = self.size + Size::splat(n + n);
Rect { pos, size }
}
sourcepub fn aspect_scale_to(self, target: Size) -> Option<Size>
pub fn aspect_scale_to(self, target: Size) -> Option<Size>
Scale to fit within the target size, keeping aspect ratio
If either dimension of self is 0, this returns None.
Trait Implementations§
source§impl AddAssign<Size> for Coord
impl AddAssign<Size> for Coord
source§fn add_assign(&mut self, rhs: Size)
fn add_assign(&mut self, rhs: Size)
+=
operation. Read moresource§impl AddAssign<Size> for Size
impl AddAssign<Size> for Size
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+=
operation. Read moresource§impl Conv<Size> for LogicalSize
impl Conv<Size> for LogicalSize
source§impl ConvApprox<DVec2> for Size
impl ConvApprox<DVec2> for Size
source§fn try_conv_approx(arg: DVec2) -> Result<Self>
fn try_conv_approx(arg: DVec2) -> Result<Self>
source§fn conv_approx(x: T) -> Self
fn conv_approx(x: T) -> Self
source§impl ConvApprox<Vec2> for Size
impl ConvApprox<Vec2> for Size
source§fn try_conv_approx(arg: Vec2) -> Result<Self>
fn try_conv_approx(arg: Vec2) -> Result<Self>
source§fn conv_approx(x: T) -> Self
fn conv_approx(x: T) -> Self
source§impl ConvFloat<DVec2> for Size
impl ConvFloat<DVec2> for Size
source§fn try_conv_trunc(x: DVec2) -> Result<Self>
fn try_conv_trunc(x: DVec2) -> Result<Self>
source§fn conv_trunc(x: T) -> Self
fn conv_trunc(x: T) -> Self
source§fn conv_nearest(x: T) -> Self
fn conv_nearest(x: T) -> Self
source§fn conv_floor(x: T) -> Self
fn conv_floor(x: T) -> Self
source§impl ConvFloat<Vec2> for Size
impl ConvFloat<Vec2> for Size
source§fn try_conv_trunc(x: Vec2) -> Result<Self>
fn try_conv_trunc(x: Vec2) -> Result<Self>
source§fn conv_trunc(x: T) -> Self
fn conv_trunc(x: T) -> Self
source§fn conv_nearest(x: T) -> Self
fn conv_nearest(x: T) -> Self
source§fn conv_floor(x: T) -> Self
fn conv_floor(x: T) -> Self
source§impl<'de> Deserialize<'de> for Size
impl<'de> Deserialize<'de> for Size
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Div<i32> for Size
impl Div<i32> for Size
Divide a Size
by an integer
In debug mode this asserts that the result is non-negative.
source§impl Mul<i32> for Size
impl Mul<i32> for Size
Multiply a Size
by an integer
In debug mode this asserts that the result is non-negative.
source§impl PartialEq<Size> for Size
impl PartialEq<Size> for Size
source§impl Sub<Size> for Size
impl Sub<Size> for Size
Subtract a Size
from a Size
This is saturating subtraction: Size::ZERO - Size::splat(6) == Size::ZERO
.
source§impl SubAssign<Size> for Coord
impl SubAssign<Size> for Coord
source§fn sub_assign(&mut self, rhs: Size)
fn sub_assign(&mut self, rhs: Size)
-=
operation. Read moresource§impl SubAssign<Size> for Size
impl SubAssign<Size> for Size
Subtract a Size
from a Size
This is saturating subtraction.
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-=
operation. Read moreimpl Copy for Size
impl Eq for Size
impl StructuralEq for Size
impl StructuralPartialEq for Size
Auto Trait Implementations§
impl RefUnwindSafe for Size
impl Send for Size
impl Sync for Size
impl Unpin for Size
impl UnwindSafe for Size
Blanket Implementations§
source§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
source§fn cast_floor(self) -> T
fn cast_floor(self) -> T
source§impl<S, T> ConvApprox<S> for Twhere
T: Conv<S>,
impl<S, T> ConvApprox<S> for Twhere
T: Conv<S>,
source§fn try_conv_approx(x: S) -> Result<T, Error>
fn try_conv_approx(x: S) -> Result<T, Error>
source§fn conv_approx(x: S) -> T
fn conv_approx(x: S) -> T
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.