Skip to content

Commit

Permalink
Simplify ServiceObjectsExt::insert
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Mar 22, 2023
1 parent cb578fc commit 310a48e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ macro_rules! impl_insert {
fn insert(self, objects: &mut Service<Objects>) -> Handle<Self>
{
let handle = objects.$store.reserve();
objects.insert(handle.clone(), self);
objects.insert((handle.clone(), self).into());
handle
}
}
Expand Down
18 changes: 4 additions & 14 deletions crates/fj-kernel/src/services/objects.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use crate::{
objects::{Object, Objects, WithHandle},
storage::Handle,
};
use crate::objects::{Object, Objects, WithHandle};

use super::{Service, State};

Expand Down Expand Up @@ -45,18 +42,11 @@ pub struct InsertObject {
/// Convenient API for `Service<Objects>`
pub trait ServiceObjectsExt {
/// Insert an object
fn insert<T>(&mut self, handle: Handle<T>, object: T)
where
(Handle<T>, T): Into<Object<WithHandle>>;
fn insert(&mut self, object: Object<WithHandle>);
}

impl ServiceObjectsExt for Service<Objects> {
fn insert<T>(&mut self, handle: Handle<T>, object: T)
where
(Handle<T>, T): Into<Object<WithHandle>>,
{
self.execute(Operation::InsertObject {
object: (handle, object).into(),
});
fn insert(&mut self, object: Object<WithHandle>) {
self.execute(Operation::InsertObject { object });
}
}

0 comments on commit 310a48e

Please sign in to comment.