#[repr(C)]pub struct CRange<T> {
pub start: T,
pub end: T,
}Expand description
A utility type to represent range.
Note that the parametrized type T should have have CReprOf and AsRust trait implementated.
§Example
use ffi_convert::{CReprOf, AsRust, CDrop, CRange};
use std::ops::Range;
#[derive(Clone, Debug, PartialEq)]
pub struct Foo {
pub range: Range<i32>
}
#[derive(AsRust, CDrop, CReprOf, Debug, PartialEq)]
#[target_type(Foo)]
pub struct CFoo {
pub range: CRange<i32>
}
let foo = Foo {
range: Range {
start: 20,
end: 30,
}
};
let c_foo = CFoo {
range: CRange {
start: 20,
end: 30,
}
};
let c_foo_converted = CFoo::c_repr_of(foo.clone()).unwrap();
assert_eq!(c_foo, c_foo_converted);
let foo_converted = c_foo.as_rust().unwrap();
assert_eq!(foo_converted, foo);Fields§
§start: T§end: TTrait Implementations§
impl<T: Eq> Eq for CRange<T>
impl<T> StructuralPartialEq for CRange<T>
Auto Trait Implementations§
impl<T> Freeze for CRange<T>where
T: Freeze,
impl<T> RefUnwindSafe for CRange<T>where
T: RefUnwindSafe,
impl<T> Send for CRange<T>where
T: Send,
impl<T> Sync for CRange<T>where
T: Sync,
impl<T> Unpin for CRange<T>where
T: Unpin,
impl<T> UnwindSafe for CRange<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> RawBorrow<T> for T
impl<T> RawBorrow<T> for T
Source§unsafe fn raw_borrow<'a>(
input: *const T,
) -> Result<&'a T, UnexpectedNullPointerError>
unsafe fn raw_borrow<'a>( input: *const T, ) -> Result<&'a T, UnexpectedNullPointerError>
Get a reference on the value behind the pointer or return an error if the pointer is
null. Read moreSource§impl<T> RawBorrowMut<T> for T
impl<T> RawBorrowMut<T> for T
Source§unsafe fn raw_borrow_mut<'a>(
input: *mut T,
) -> Result<&'a mut T, UnexpectedNullPointerError>
unsafe fn raw_borrow_mut<'a>( input: *mut T, ) -> Result<&'a mut T, UnexpectedNullPointerError>
Get a mutable reference on the value behind the pointer or return an error if the pointer is
null. Read more