Either complaining about not fully resolving a macro

The code:

use std::sync::Arc;
use either::{Either, Left, Right};

enum ConsArg {
    Car,
    Cdr,
}

use ConsArg::{Car, Cdr};
// just like cons in lisp
fn cons<A, B>(a: Arc<A>, b: Arc<B>) -> Arc<dyn Fn(ConsArg) -> Either<Arc<A>, Arc<B>>>
where
    A: Clone + 'static, B: Clone + 'static,
{
    Arc::new(move |x| match x {
        ConsArg::Car => Left(a.clone()),
        ConsArg::Cdr => Right(b.clone()),
    })
}

In my main function it complains, but both branches in the for_all! macro return the unit type.

fn main() {
    let my_data = cons(Arc::new(cons(Arc::new(1), Arc::new(2))), Arc::new(3));
    let res = my_data(Cdr);
    let right = Either::for_both!(res, s => println!("{:?}", s));

The specific error i get:

error[E0433]: failed to resolve: partially resolved path in a macro
  --> src/main.rs:29:17
   |
29 |     let right = Either::for_both!(res, s => println!("{:?}", s));
   |                 ^^^^^^^^^^^^^^^^ partially resolved path in a macro

I've looked at the examples in the docs but I don't really know what I'm doing wrong.

It’s either::for_both! not Either::for_both!,

or alternatively just for_both! without any path before it if you add the macro to the import use either::{for_both, Either, Left, Right};

1 Like

Dang, I thought I tried this but that just works thank you