strum icon indicating copy to clipboard operation
strum copied to clipboard

Produce fully-qualified variant with AsRefStr?

Open seanpianka opened this issue 3 years ago • 1 comments

I'm looking for a way to ensure that the Register variant in the Activities enum within each module does not collide when being converted to a &str using .as_ref(). Is there anyway supported/blessed way to do this, besides modifying the variant names to explicitly include the module name?

mod user {
    #[derive(AsRefStr)]
    enum Activities {
        Register,
    }
}

mod task {
    #[derive(AsRefStr)]
    enum Activities {
        Register,
    }
}


#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn do_not_collide() {
        assert_ne!(user::Activities::Register.as_ref(), task::Activities::Register.as_ref())
    }
}

seanpianka avatar Sep 25 '20 19:09 seanpianka

I believe #92 would help solve this, but we don't have support for this type of feature currently

Peternator7 avatar Sep 27 '20 21:09 Peternator7