-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use cgp_type! to derive HasRuntimeType
- Loading branch information
1 parent
2c5ea87
commit a444258
Showing
2 changed files
with
4 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
pub use cgp_async::{async_trait, Async, MaybeSend, MaybeStatic, MaybeSync}; | ||
pub use cgp_component::{DelegateComponent, HasComponents, WithContext, WithProvider}; | ||
pub use cgp_component_macro::{ | ||
cgp_component, cgp_preset, delegate_components, for_each_replace, replace_with, | ||
cgp_component, cgp_preset, cgp_type, delegate_components, for_each_replace, replace_with, | ||
}; | ||
pub use cgp_error::{CanRaiseError, CanWrapError, HasErrorType}; | ||
pub use cgp_field::{Char, Cons, Either, HasField, HasFieldMut, Nil, Void}; | ||
pub use cgp_field_macro::{product, symbol, HasField, Product, Sum}; | ||
pub use cgp_type::{HasType, UseType}; | ||
pub use cgp_type::{HasType, ProvideType, UseType}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,5 @@ | ||
use cgp_core::component::WithProvider; | ||
use cgp_core::prelude::*; | ||
use cgp_core::types::ProvideType; | ||
|
||
#[cgp_component { | ||
name: RuntimeTypeComponent, | ||
provider: ProvideRuntimeType, | ||
}] | ||
pub trait HasRuntimeType { | ||
type Runtime; | ||
} | ||
|
||
pub type RuntimeOf<Context> = <Context as HasRuntimeType>::Runtime; | ||
|
||
impl<Context, Provider, Runtime> ProvideRuntimeType<Context> for WithProvider<Provider> | ||
where | ||
Provider: ProvideType<Context, RuntimeTypeComponent, Type = Runtime>, | ||
{ | ||
type Runtime = Runtime; | ||
cgp_type! { | ||
Runtime | ||
} |