Skip to content

Commit

Permalink
Remove Async bounds in component traits and macros (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
soareschen authored Aug 8, 2024
1 parent 778fb3f commit c545eb3
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use syn::punctuated::Punctuated;
use syn::{parse_quote, Ident, ItemTrait, TraitItem};

use crate::derive_component::replace_self_receiver::replace_self_receiver;
Expand Down Expand Up @@ -42,7 +43,7 @@ pub fn derive_provider_trait(
&local_assoc_types,
)?;

provider_trait.supertraits = parse_quote!(Async);
provider_trait.supertraits = Punctuated::default();

if !context_constraints.is_empty() {
if let Some(where_clause) = &mut provider_trait.generics.where_clause {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn test_derive_component_with_const_generic() {

pub struct FooComponent;

pub trait FooProvider<Context, const BAR: usize>: Async {
pub trait FooProvider<Context, const BAR: usize> {
type Foo;

fn foo(context: &Context) -> Self::Foo;
Expand Down
4 changes: 1 addition & 3 deletions crates/cgp-component/src/traits/delegate_component.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use cgp_async::Async;

pub trait DelegateComponent<Name>: Async {
pub trait DelegateComponent<Name> {
type Delegate;
}
6 changes: 2 additions & 4 deletions crates/cgp-component/src/traits/has_components.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use cgp_async::Async;

pub trait HasComponents: Async {
type Components: Async;
pub trait HasComponents {
type Components;
}
1 change: 0 additions & 1 deletion crates/cgp-error/src/can_raise_error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use cgp_async::Async;
use cgp_component::{derive_component, DelegateComponent, HasComponents};

use crate::has_error_type::HasErrorType;
Expand Down
2 changes: 1 addition & 1 deletion crates/cgp-error/src/has_error_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use cgp_component::{derive_component, DelegateComponent, HasComponents};
`Self::Error` type.
*/
#[derive_component(ErrorTypeComponent, ProvideErrorType<Context>)]
pub trait HasErrorType: Async {
pub trait HasErrorType {
/**
The `Error` associated type is also required to implement [`Debug`].
Expand Down
2 changes: 1 addition & 1 deletion crates/cgp-run/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ use cgp_error::HasErrorType;

#[derive_component(RunnerComponent, Runner<Context>)]
#[async_trait]
pub trait CanRun: HasErrorType {
pub trait CanRun: Async + HasErrorType {
async fn run(&self) -> Result<(), Self::Error>;
}

0 comments on commit c545eb3

Please sign in to comment.