qfall_math/rational/q/
unsafe_functions.rs1use super::Q;
13use crate::macros::unsafe_passthrough::{unsafe_getter, unsafe_setter};
14use flint3_sys::{fmpq, fmpq_clear};
15
16unsafe_getter!(Q, value, fmpq);
17
18unsafe_setter!(Q, value, fmpq, fmpq_clear);
19
20#[cfg(test)]
21mod test_get_fmpq {
22 use super::Q;
23
24 #[test]
27 #[allow(unused_mut)]
28 fn availability_and_modification() {
29 let mut rational = Q::from(1);
30
31 let mut fmpq_rat = unsafe { rational.get_fmpq() };
32
33 fmpq_rat.num = 2;
34
35 assert_eq!(Q::from(2), rational);
36 }
37}
38
39#[cfg(test)]
40mod test_set_fmpq {
41 use super::Q;
42 use flint3_sys::fmpq;
43
44 #[test]
47 #[allow(unused_mut)]
48 fn availability_and_modification() {
49 let mut rational = Q::from(1);
50 let flint_struct = fmpq { num: 2, den: 1 };
51
52 unsafe { rational.set_fmpq(flint_struct) };
53
54 assert_eq!(Q::from(2), rational);
55 }
56}