[−][src]Struct web_glitz::image::texture_cube::LevelsMut
Returned from TextureCube::levels_mut, a mutable reference to the levels of a TextureCube.
See TextureCube::levels_mut for details.
Methods
impl<'a, F> LevelsMut<'a, F> where
F: TextureFormat,
[src]
F: TextureFormat,
pub fn get_mut<'b, I>(&'b mut self, index: I) -> Option<I::Output> where
I: LevelsMutIndex<'b, F>,
[src]
I: LevelsMutIndex<'b, F>,
Returns a mutable reference to level at the index
, or None
if the index
is out of
bounds.
See also [get_unchecked_mut] for an unsafe variant or this method that does not do any bounds checks.
Example
use web_glitz::image::MipmapLevels; use web_glitz::image::format::RGB8; use web_glitz::image::texture_cube::TextureCubeDescriptor; let mut texture = context.create_texture_cube(&TextureCubeDescriptor { format: RGB8, width: 256, height: 256, levels: MipmapLevels::Partial(3) }).unwrap(); let mut levels = texture.levels_mut(); assert_eq!(levels.get_mut(1).map(|l| (l.width(), l.height())), Some((128, 128))); assert_eq!(levels.get_mut(4).map(|l| (l.width(), l.height())), None);
pub unsafe fn get_unchecked_mut<'b, I>(&'b mut self, index: I) -> I::Output where
I: LevelsMutIndex<'b, F>,
[src]
I: LevelsMutIndex<'b, F>,
Returns a mutable reference to level at the index
, without doing any bounds checks.
Example
use web_glitz::image::MipmapLevels; use web_glitz::image::format::RGB8; use web_glitz::image::texture_cube::TextureCubeDescriptor; let mut texture = context.create_texture_cube(&TextureCubeDescriptor { format: RGB8, width: 256, height: 256, levels: MipmapLevels::Partial(3) }).unwrap(); let mut levels = texture.levels_mut(); let level = unsafe { levels.get_unchecked_mut(1) }; assert_eq!((level.width(), level.height()), (128, 128));
Unsafe
The index
must be in bounds. See also [get_mut] for a safe variant of this method that
does bounds checks.
ⓘImportant traits for LevelsMutIter<'a, F>pub fn iter_mut(&mut self) -> LevelsMutIter<F>
[src]
Returns an iterator over mutable references to the levels.
Example
use web_glitz::image::MipmapLevels; use web_glitz::image::format::RGB8; use web_glitz::image::texture_cube::TextureCubeDescriptor; let mut texture = context.create_texture_cube(&TextureCubeDescriptor { format: RGB8, width: 256, height: 256, levels: MipmapLevels::Partial(3) }).unwrap(); let mut levels = texture.levels_mut(); let mut iter = levels.iter_mut(); assert_eq!(iter.next().map(|l| (l.width(), l.height())), Some((128, 128))); assert_eq!(iter.next().map(|l| (l.width(), l.height())), Some((64, 64))); assert_eq!(iter.next().map(|l| (l.width(), l.height())), Some((32, 32))); assert_eq!(iter.next().map(|l| (l.width(), l.height())), None);
Methods from Deref<Target = Levels<'a, F>>
pub fn len(&self) -> usize
[src]
The number of levels defined for the TextureCube.
pub fn get<'b, I>(&'b self, index: I) -> Option<I::Output> where
I: LevelsIndex<'b, F>,
[src]
I: LevelsIndex<'b, F>,
Returns a reference to level at the index
, or None
if the index
is out of bounds.
See also [get_unchecked] for an unsafe variant of this method that does not do any bounds checks.
Example
use web_glitz::image::MipmapLevels; use web_glitz::image::format::RGB8; use web_glitz::image::texture_cube::TextureCubeDescriptor; let texture = context.create_texture_cube(&TextureCubeDescriptor { format: RGB8, width: 256, height: 256, levels: MipmapLevels::Partial(3) }).unwrap(); let levels = texture.levels(); assert_eq!(levels.get(1).map(|l| (l.width(), l.height())), Some((128, 128))); assert_eq!(levels.get(4).map(|l| (l.width(), l.height())), None);
pub unsafe fn get_unchecked<'b, I>(&'b self, index: I) -> I::Output where
I: LevelsIndex<'b, F>,
[src]
I: LevelsIndex<'b, F>,
Returns a reference to level at the index
, without doing any bounds checks.
Example
use web_glitz::image::MipmapLevels; use web_glitz::image::format::RGB8; use web_glitz::image::texture_cube::TextureCubeDescriptor; let texture = context.create_texture_cube(&TextureCubeDescriptor { format: RGB8, width: 256, height: 256, levels: MipmapLevels::Partial(3) }).unwrap(); let levels = texture.levels(); let level = unsafe { levels.get_unchecked(1) }; assert_eq!((level.width(), level.height()), (128, 128));
Unsafe
The index
must be in bounds. See also [get] for a safe variant of this method that does
bounds checks.
ⓘImportant traits for LevelsIter<'a, F>pub fn iter(&self) -> LevelsIter<F>
[src]
Returns an iterator over the levels.
Example
use web_glitz::image::MipmapLevels; use web_glitz::image::format::RGB8; use web_glitz::image::texture_cube::TextureCubeDescriptor; let texture = context.create_texture_cube(&TextureCubeDescriptor { format: RGB8, width: 256, height: 256, levels: MipmapLevels::Partial(3) }).unwrap(); let levels = texture.levels(); let mut iter = levels.iter(); assert_eq!(iter.next().map(|l| (l.width(), l.height())), Some((128, 128))); assert_eq!(iter.next().map(|l| (l.width(), l.height())), Some((64, 64))); assert_eq!(iter.next().map(|l| (l.width(), l.height())), Some((32, 32))); assert_eq!(iter.next().map(|l| (l.width(), l.height())), None);
Trait Implementations
impl<'a, F> IntoIterator for LevelsMut<'a, F> where
F: TextureFormat,
[src]
F: TextureFormat,
type Item = LevelMut<'a, F>
The type of the elements being iterated over.
type IntoIter = LevelsMutIter<'a, F>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<'a, F> Deref for LevelsMut<'a, F> where
F: TextureFormat,
[src]
F: TextureFormat,
Auto Trait Implementations
impl<'a, F> !Send for LevelsMut<'a, F>
impl<'a, F> Unpin for LevelsMut<'a, F>
impl<'a, F> !Sync for LevelsMut<'a, F>
impl<'a, F> !UnwindSafe for LevelsMut<'a, F>
impl<'a, F> !RefUnwindSafe for LevelsMut<'a, F>
Blanket Implementations
impl<D, T> IntoBuffer<T> for D where
D: Borrow<T> + 'static,
T: Copy + 'static,
[src]
D: Borrow<T> + 'static,
T: Copy + 'static,
fn into_buffer<Rc>(Self, &Rc, UsageHint) -> Buffer<T> where
Rc: RenderingContext + Clone + 'static,
[src]
Rc: RenderingContext + Clone + 'static,
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,