Skip to content

Generics in mocked methods #18

@nrxus

Description

@nrxus

Neither of these work.

pub fn new_generic_input<T>(&self, a: T) { /* some code here */ } 
pub fn new_generic_output<T>(&self) -> T { /* some code here */ } 
pub fn impl_arg(&self, a: impl SomeTrait) { /* some code here */ } 
pub fn impl_out(&self) -> impl SomeTrait { /* some code here */ } 

The issue is on the definition of the _when_{} method.
The first two seem solvable together. Add all the generics from the mocked method to the when method.
The third one seems like it would require "de-sugaring" the impl Foo into <T: Foo> for the when method only.
The last one.... 🤷‍♂️ We could change it into a generic argument to the when method as a first-step MVP (read: hack).

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