Skip to content

Support module level attribute #16

@mversic

Description

@mversic

this can be supported if there is need or interest:

use core::mem::ManuallyDrop;

pub trait Dispatch {
    type Group;
}

pub enum GroupA {}
impl Dispatch for String {
    type Group = GroupA;
}
impl<T> Dispatch for Vec<T> {
    type Group = GroupA;
}

pub enum GroupB {}
impl Dispatch for i32 {
    type Group = GroupB;
}
impl Dispatch for u32 {
    type Group = GroupB;
}

pub enum GroupC {}
pub enum GroupD {}

#[disjoint_impls::disjoint_impls_mod]
pub mod kita {
    use super::*;

    pub trait Kita<'d> {
        type Wrapped;
    }
    impl<'d, R: Dispatch<Group = GroupA> + 'd> Kita<'d> for Option<R>
    where
        Self: Dispatch<Group = Option<GroupA>>,
    {
        type Wrapped = Self;
    }
    impl<'d, R: Dispatch<Group = GroupB> + 'd> Kita<'d> for Option<R>
    where
        Self: Dispatch<Group = Option<GroupA>>,
    {
        type Wrapped = Option<ManuallyDrop<R>>;
    }
    impl<'d, R: Kita<'d>> Kita<'d> for Option<R>
    where
        Self: Dispatch<Group = Option<GroupB>>,
    {
        type Wrapped = Option<R::Wrapped>;
    }
}

but the name of the attribute cannot be disjoint_impls because it would conflict with existing name

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions