MrPicklePinosaur / shrs

The rusty shell toolkit for hackers
https://mrpicklepinosaur.github.io/shrs/
Apache License 2.0
301 stars 24 forks source link

[Feature]: Make Shell optional in Dependency injection #448

Open nithinmuthukumar opened 4 months ago

nithinmuthukumar commented 4 months ago

The simplest solution is barred by the impl being the same definition, specialization is unstable


impl<F, C: Ctx> IntoHook<(), C> for F
where
    for<'a, 'b> &'a F: Fn(&C) -> Result<()>,
{
    type Hook = FunctionHook<C, Self>;

    fn into_system(self) -> Self::Hook {
        FunctionHook {
            f: self,
            marker: Default::default(),
        }
    }
}
impl<F, C: Ctx> IntoHook<(), C> for F
where
    for<'a, 'b> &'a F: Fn(&Shell, &C) -> Result<()>,
{
    type Hook = FunctionHook<(Shell, C), Self>;

    fn into_system(self) -> Self::Hook {
        FunctionHook {
            f: self,
            marker: Default::default(),
        }
    }
}

Figure out a way to work around this