Skip to content

Instantly share code, notes, and snippets.

@daboross
Created February 13, 2019 02:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daboross/a4bd5c71156e436172b9e2eea37fe766 to your computer and use it in GitHub Desktop.
Save daboross/a4bd5c71156e436172b9e2eea37fe766 to your computer and use it in GitHub Desktop.
error[E0412]: cannot find type `F` in this scope
--> derive/tests/derive_generics.rs:15:53
|
15 | fn get<F>(&mut self, _: &mut (), msg: GetTarget<F>) -> u32
| ^ help: a trait with a similar name exists: `Fn`
error[E0412]: cannot find type `F` in this scope
--> derive/tests/derive_generics.rs:15:53
|
15 | fn get<F>(&mut self, _: &mut (), msg: GetTarget<F>) -> u32
| ^ help: a type parameter with a similar name exists: `A`
#[derive(Clone, Default, Debug, Deserialize, Serialize, TransferOwnership)]
pub struct RoomTargets;
#[process(process_type = ::ProcessType)]
impl RoomTargets {
#[sync_msg]
fn get<F>(&mut self, _: &mut (), msg: GetTarget<F>) -> u32
where
F: FnOnce(u32) -> u32 + Message,
{
(msg.get)(5)
}
}
#[derive(Clone, Default, Debug, Deserialize, Serialize, TransferOwnership)]
pub struct GetTarget<F: FnOnce(u32) -> u32> {
get: F,
}
impl<F> ::tungsten::SyncMessageReceiver<GetTarget<F>> for RoomTargets
where
F: FnOnce(u32) -> u32 + Message,
{
type Result = u32;
fn recv(&mut self, _: &mut (), msg: GetTarget<F>) -> u32 {
(msg.get)(5)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment