Construct an optional containing the Java object `t` (equivalent to [`Option::Some`])
(env: &mut JNIEnv<'a>, t: T)
| 181 | |
| 182 | /// Construct an optional containing the Java object `t` (equivalent to [`Option::Some`]) |
| 183 | pub fn of(env: &mut JNIEnv<'a>, t: T) -> Result<Self> { |
| 184 | let value = env.call_static_method( |
| 185 | "java/util/Optional", |
| 186 | "of", |
| 187 | "(Ljava/lang/Object;)Ljava/util/Optional;", |
| 188 | &[JValueGen::Object(t.as_ref())], |
| 189 | )?; |
| 190 | Ok(Self { |
| 191 | value, |
| 192 | marker: PhantomData, |
| 193 | }) |
| 194 | } |
| 195 | |
| 196 | /// Move from a Rust [Option] to a Java optional |
| 197 | pub fn from_optional(env: &mut JNIEnv<'a>, t: Option<T>) -> Result<Self> { |