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
48
49
50
51
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use core::{cmp::Ordering, fmt};
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
impl fmt::Debug for Janet {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.pad(core::any::type_name::<Self>())
}
}
impl PartialEq<Janet> for Janet {
#[inline]
fn eq(&self, other: &Janet) -> bool { unsafe { janet_equals(*self, *other) != 0 } }
}
impl Eq for Janet {}
impl PartialOrd<Janet> for Janet {
#[inline]
fn partial_cmp(&self, other: &Janet) -> Option<Ordering> {
let res = unsafe { janet_compare(*self, *other) };
Some(match res {
-1 => Ordering::Less,
0 => Ordering::Equal,
1 => Ordering::Greater,
_ => return None,
})
}
}
impl Ord for Janet {
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
let res = unsafe { janet_compare(*self, *other) };
match res {
-1 => Ordering::Less,
0 => Ordering::Equal,
1 => Ordering::Greater,
_ => unsafe { core::hint::unreachable_unchecked() },
}
}
}