pub struct ImagesMut<'w> { /* private fields */ }Expand description
A mutable view over the images (frames) held by a MagickWand.
Obtained from MagickWand::images_mut. Because ImageMagick exposes a
single internal iterator, only one ImageMut may be borrowed at a time;
this is enforced by the borrow checker, as each accessor borrows the view
mutably.
Implementations§
Source§impl<'w> ImagesMut<'w>
impl<'w> ImagesMut<'w>
Sourcepub fn get(&mut self, index: usize) -> Option<ImageMut<'_>>
pub fn get(&mut self, index: usize) -> Option<ImageMut<'_>>
Mutably borrow the frame at index, or None if out of bounds.
Sourcepub fn first(&mut self) -> Option<ImageMut<'_>>
pub fn first(&mut self) -> Option<ImageMut<'_>>
Mutably borrow the first frame, or None if the list is empty.
Sourcepub fn last(&mut self) -> Option<ImageMut<'_>>
pub fn last(&mut self) -> Option<ImageMut<'_>>
Mutably borrow the last frame, or None if the list is empty.
Sourcepub fn remove(&mut self, index: usize) -> Result<(), MagickError>
pub fn remove(&mut self, index: usize) -> Result<(), MagickError>
Remove the frame at index from the list.
Note that removing a frame shifts the indices of all later frames down by one, so any indices computed before the removal are stale afterwards.
Sourcepub fn append(&mut self, other: &MagickWand) -> Result<(), MagickError>
pub fn append(&mut self, other: &MagickWand) -> Result<(), MagickError>
Append all frames from other to the end of this list.
Sourcepub fn for_each(&mut self, f: impl FnMut(usize, ImageMut<'_>))
pub fn for_each(&mut self, f: impl FnMut(usize, ImageMut<'_>))
Visit every frame in order, passing its index and a mutable borrow to
f.
f must not add or remove frames (e.g. via ImageMut’s deref to
MagickWand::remove_image / MagickWand::add_image): the set of
indices to visit is fixed when iteration begins, so changing the frame
count mid-iteration visits the wrong frames. Use ImagesMut::remove
or ImagesMut::append before or after iterating instead.
Sourcepub fn try_for_each(
&mut self,
f: impl FnMut(usize, ImageMut<'_>) -> Result<(), MagickError>,
) -> Result<(), MagickError>
pub fn try_for_each( &mut self, f: impl FnMut(usize, ImageMut<'_>) -> Result<(), MagickError>, ) -> Result<(), MagickError>
Like ImagesMut::for_each, but f may fail; the first error stops
iteration and is returned. The same “do not add or remove frames”
caveat as ImagesMut::for_each applies.