Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Pass copyable types by value #186

Merged
merged 1 commit into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/rmrk/catalog/app/src/services/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ where
pub fn seed(exec_context: TExecContext) {
unsafe {
CATALOG_DATA = Some(CatalogData::default());
CATALOG_ADMIN = Some(*exec_context.actor_id());
CATALOG_ADMIN = Some(exec_context.actor_id());
}
}

Expand Down Expand Up @@ -231,6 +231,6 @@ where
}
}

fn catalog_admin() -> &'static ActorId {
unsafe { CATALOG_ADMIN.as_ref().unwrap() }
fn catalog_admin() -> ActorId {
unsafe { CATALOG_ADMIN.unwrap() }
}
14 changes: 7 additions & 7 deletions examples/rmrk/resource/app/src/services/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ where
pub fn seed(exec_context: TExecContext) {
unsafe {
RESOURCE_STORAGE_DATA = Some(ResourceStorageData::default());
RESOURCE_STORAGE_ADMIN = Some(*exec_context.actor_id());
RESOURCE_STORAGE_ADMIN = Some(exec_context.actor_id());
}
}

Expand Down Expand Up @@ -152,8 +152,8 @@ where
}
}

fn resource_storage_admin() -> &'static ActorId {
unsafe { RESOURCE_STORAGE_ADMIN.as_ref().unwrap() }
fn resource_storage_admin() -> ActorId {
unsafe { RESOURCE_STORAGE_ADMIN.unwrap() }
}

#[cfg(test)]
Expand Down Expand Up @@ -204,12 +204,12 @@ mod tests {
}

impl ExecContext for ExecContextMock {
fn actor_id(&self) -> &ActorId {
&self.actor_id
fn actor_id(&self) -> ActorId {
self.actor_id
}

fn message_id(&self) -> &MessageId {
&self.message_id
fn message_id(&self) -> MessageId {
self.message_id
}
}

Expand Down
9 changes: 4 additions & 5 deletions rtl/src/gstd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ impl GStdExecContext {
}

impl ExecContext for GStdExecContext {
fn actor_id(&self) -> &ActorId {
self.msg_source
.get_or_init(|| msg::source().as_ref().into())
fn actor_id(&self) -> ActorId {
*self.msg_source.get_or_init(|| msg::source().into())
}

fn message_id(&self) -> &MessageId {
self.msg_id.get_or_init(|| msg::id().as_ref().into())
fn message_id(&self) -> MessageId {
*self.msg_id.get_or_init(|| msg::id().into())
}
}
4 changes: 2 additions & 2 deletions rtl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub mod scale {
}

pub trait ExecContext {
fn actor_id(&self) -> &ActorId;
fn actor_id(&self) -> ActorId;

fn message_id(&self) -> &MessageId;
fn message_id(&self) -> MessageId;
}