Skip to content

Commit

Permalink
Use cgp_type! to derive HasRuntimeType
Browse files Browse the repository at this point in the history
  • Loading branch information
soareschen committed Jan 7, 2025
1 parent 2c5ea87 commit a444258
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
4 changes: 2 additions & 2 deletions crates/cgp-core/src/prelude.rs
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};
19 changes: 2 additions & 17 deletions crates/cgp-runtime/src/traits/has_runtime_type.rs
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
}

0 comments on commit a444258

Please sign in to comment.