logo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! The conversions in this file is not lossless. On the contrary, it is lossy
//! and the type that Dart receives will not be the same as the type you send in
//! Rust. For example, numeric types can become String.

use crate::{ffi::*, IntoDart};

impl IntoDart for i8 {
    fn into_dart(self) -> DartCObject { (self as i32).into_dart() }
}

impl IntoDart for i16 {
    fn into_dart(self) -> DartCObject { (self as i32).into_dart() }
}

impl IntoDart for u8 {
    fn into_dart(self) -> DartCObject { (self as i32).into_dart() }
}

impl IntoDart for u16 {
    fn into_dart(self) -> DartCObject { (self as i32).into_dart() }
}

impl IntoDart for u32 {
    fn into_dart(self) -> DartCObject { (self as i64).into_dart() }
}

impl IntoDart for u64 {
    fn into_dart(self) -> DartCObject { (self as i64).into_dart() }
}

impl IntoDart for i128 {
    fn into_dart(self) -> DartCObject { self.to_string().into_dart() }
}

impl IntoDart for u128 {
    fn into_dart(self) -> DartCObject { self.to_string().into_dart() }
}

#[cfg(target_pointer_width = "64")]
impl IntoDart for usize {
    fn into_dart(self) -> DartCObject { (self as u64 as i64).into_dart() }
}

#[cfg(target_pointer_width = "32")]
impl IntoDart for usize {
    fn into_dart(self) -> DartCObject { (self as u32 as i32).into_dart() }
}