Struct objc2_foundation::NSSize
source · [−]#[repr(C)]pub struct NSSize { /* private fields */ }
Expand description
A two-dimensional size.
The width and height are guaranteed to be non-negative, so methods that
expect that can safely accept NSSize
as a parameter.
For ease of use, this is available on all platforms, though in practice it is only useful on macOS.
See Apple’s documentation.
and the related core_graphics_types::geometry::CGSize
.
Implementations
sourceimpl NSSize
impl NSSize
sourcepub fn new(width: CGFloat, height: CGFloat) -> Self
pub fn new(width: CGFloat, height: CGFloat) -> Self
Create a new size with the given dimensions.
Examples
use objc2_foundation::NSSize;
let size = NSSize::new(10.0, 2.3);
assert_eq!(size.width(), 10.0);
assert_eq!(size.height(), 2.3);
ⓘ
use objc2_foundation::NSSize;
let size = NSSize::new(-1.0, 0.0);
sourcepub const ZERO: Self = Self {
width: 0.0,
height: 0.0,
}
pub const ZERO: Self = Self { width: 0.0, height: 0.0, }
A size that is 0.0 in both dimensions.
pub const fn width(self) -> CGFloat
pub const fn height(self) -> CGFloat
Trait Implementations
sourceimpl RefEncode for NSSize
impl RefEncode for NSSize
sourceconst ENCODING_REF: Encoding<'static> = Encoding::Pointer(&Self::ENCODING)
const ENCODING_REF: Encoding<'static> = Encoding::Pointer(&Self::ENCODING)
The Objective-C type-encoding for a reference of this type. Read more
impl Copy for NSSize
impl StructuralPartialEq for NSSize
Auto Trait Implementations
impl RefUnwindSafe for NSSize
impl Send for NSSize
impl Sync for NSSize
impl Unpin for NSSize
impl UnwindSafe for NSSize
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more