Complete refactor of the FFI to use handles instead of pointers.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -15,13 +15,17 @@ pub trait DataLibrary<T: ?Sized> {
|
||||
fn get_modify(&mut self) -> &mut IndexMap<StringKey, Arc<T>>;
|
||||
|
||||
/// Adds a new value to the library.
|
||||
fn add(&mut self, key: &StringKey, value: Arc<T>) {
|
||||
self.get_modify().insert(key.clone(), value);
|
||||
fn add(&self, key: &StringKey, value: Arc<T>) {
|
||||
#[allow(clippy::unwrap_used)] // We know this cant fail.
|
||||
let self_mut = unsafe { (self as *const Self as *mut Self).as_mut() }.unwrap();
|
||||
self_mut.get_modify().insert(key.clone(), value);
|
||||
}
|
||||
|
||||
/// Removes a value from the library.
|
||||
fn remove(&mut self, key: &StringKey) {
|
||||
self.get_modify().remove(key);
|
||||
fn remove(&self, key: &StringKey) {
|
||||
#[allow(clippy::unwrap_used)] // We know this cant fail.
|
||||
let self_mut = unsafe { (self as *const Self as *mut Self).as_mut() }.unwrap();
|
||||
self_mut.get_modify().remove(key);
|
||||
}
|
||||
|
||||
/// Gets a value from the library.
|
||||
|
||||
Reference in New Issue
Block a user