From 424e5ac5ae5919b854e9d87faf71aaeae36b7e3b Mon Sep 17 00:00:00 2001 From: fzyzcjy <5236035+fzyzcjy@users.noreply.github.com> Date: Sun, 24 Dec 2023 04:24:35 +0800 Subject: [PATCH] Support `isize` (#53) * Support `isize` * Update containers.rs --- src/into_dart_extra.rs | 14 ++++++++++++++ tests/containers.rs | 1 + 2 files changed, 15 insertions(+) diff --git a/src/into_dart_extra.rs b/src/into_dart_extra.rs index ccc73e7..9100a68 100644 --- a/src/into_dart_extra.rs +++ b/src/into_dart_extra.rs @@ -66,6 +66,20 @@ impl IntoDart for usize { } } +#[cfg(target_pointer_width = "64")] +impl IntoDart for isize { + fn into_dart(self) -> DartCObject { + (self as i64).into_dart() + } +} + +#[cfg(target_pointer_width = "32")] +impl IntoDart for isize { + fn into_dart(self) -> DartCObject { + (self as i32).into_dart() + } +} + impl IntoDart for char { fn into_dart(self) -> DartCObject { (self as u32).into_dart() diff --git a/tests/containers.rs b/tests/containers.rs index 9f9e2ec..ed73980 100644 --- a/tests/containers.rs +++ b/tests/containers.rs @@ -78,6 +78,7 @@ fn main() { assert!(isolate.post(42i128)); assert!(isolate.post(42u128)); assert!(isolate.post(42usize)); + assert!(isolate.post(42isize)); assert!(isolate.post(true)); assert!(isolate.post(false)); assert!(isolate.post('🎊'));