Struct jni::objects::JMapIter

source ·
pub struct JMapIter<'map, 'local, 'other_local_1: 'obj_ref, 'obj_ref, 'iter_local> { /* private fields */ }
Expand description

An iterator over the keys and values in a map. See JMap::iter for more information.

TODO: make the iterator implementation for java iterators its own thing and generic enough to use elsewhere.

Implementations§

source§

impl<'map, 'local, 'other_local_1: 'obj_ref, 'obj_ref, 'iter_local> JMapIter<'map, 'local, 'other_local_1, 'obj_ref, 'iter_local>

source

pub fn next<'other_local_2>( &mut self, env: &mut JNIEnv<'other_local_2> ) -> Result<Option<(JObject<'other_local_2>, JObject<'other_local_2>)>>

Advances the iterator and returns the next key-value pair in the java.util.Map, or None if there are no more objects.

See JMap::iter for more information.

This method creates two new local references. To prevent excessive memory usage or overflow error, the local references should be deleted using JNIEnv::delete_local_ref or JNIEnv::auto_local before the next loop iteration. Alternatively, if the map is known to have a small, predictable size, the loop could be wrapped in JNIEnv::with_local_frame to delete all of the local references at once.

This method returns:

  • Ok(Some(_)): if there was another key-value pair in the map.
  • Ok(None): if there are no more key-value pairs in the map.
  • Err(_): if there was an error calling the Java method to get the next key-value pair.

This is like std::iter::Iterator::next, but requires a parameter of type &mut JNIEnv in order to call into Java.

Auto Trait Implementations§

§

impl<'map, 'local, 'other_local_1, 'obj_ref, 'iter_local> RefUnwindSafe for JMapIter<'map, 'local, 'other_local_1, 'obj_ref, 'iter_local>

§

impl<'map, 'local, 'other_local_1, 'obj_ref, 'iter_local> !Send for JMapIter<'map, 'local, 'other_local_1, 'obj_ref, 'iter_local>

§

impl<'map, 'local, 'other_local_1, 'obj_ref, 'iter_local> !Sync for JMapIter<'map, 'local, 'other_local_1, 'obj_ref, 'iter_local>

§

impl<'map, 'local, 'other_local_1, 'obj_ref, 'iter_local> Unpin for JMapIter<'map, 'local, 'other_local_1, 'obj_ref, 'iter_local>where 'local: 'map, 'obj_ref: 'map, 'other_local_1: 'map,

§

impl<'map, 'local, 'other_local_1, 'obj_ref, 'iter_local> UnwindSafe for JMapIter<'map, 'local, 'other_local_1, 'obj_ref, 'iter_local>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.