java_jni/cleanups: replace Swig* traits impl with foreign_typemap!
@@ -915,12 +915,11 @@ define_array_handling_code!(
]
);
-impl<T> SwigDeref for Vec<T> {
- type Target = [T];
- fn swig_deref(&self) -> &Self::Target {
- &*self
- }
-}
+foreign_typemap!(
+ ($p:r_type) <T> Vec<T> => &[T] {
+ $out = $p.as_slice();
+ };
+);
foreign_typemap!(
($p:r_type) &[i32] => jintArray {
@@ -1036,12 +1035,11 @@ foreign_typemap!(
};
);
-impl SwigDeref for String {
- type Target = str;
- fn swig_deref(&self) -> &str {
- self
- }
-}
+foreign_typemap!(
+ ($p:r_type) String => &str {
+ $out = $p.as_str();
+ };
+);
impl<T> SwigDeref for Arc<Mutex<T>> {
type Target = Mutex<T>;
@@ -1153,11 +1151,11 @@ impl SwigFrom<usize> for jlong {
}
}
-impl<'a> SwigInto<String> for &'a str {
- fn swig_into(self, _: *mut JNIEnv) -> String {
- self.into()
- }
-}
+foreign_typemap!(
+ ($p:r_type) &str => String {
+ $out = $p.to_string();
+ };
+);
#[allow(dead_code)]
fn to_java_util_optional_double(
