nvzqz / impls

A Rust macro to determine if a type implements a logical trait expression

Home Page:https://docs.rs/impls

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does Not Work Well With Generic Types

brunoczim opened this issue · comments

Considers this example:

use impls::impls;
use std::fs::File;

fn impls_clone<T>() -> bool {
    impls!(T: Clone)
}

fn main() {
    // false (wrong!)
    println!("{:?}", impls_clone::<String>());
    // false (right)
    println!("{:?}", impls_clone::<File>());
}

It says that String does not implements Clone, which is wrong (I mean, String does implement Clone). I am not sure if this possible to be fixed though.

This limitation is mentioned in "Generic Types". Without plugging into the compiler, this unfortunately is not possible.