#conversion #chaining #safe #declarative #compile #i32 #explict

to_that

Declarative compile safe explict type conversion. Useful for chaining.

2 stable releases

1.0.1 Oct 27, 2023

#5 in #chaining

29 downloads per month

MIT license

3KB

to_that

Declarative compile safe explict type conversion. Useful for chaining.

Example

For

    #[derive(Debug, PartialEq)]
    struct A(i32);

    #[derive(Debug, PartialEq)]
    struct B(i32);

    impl From<A> for B {
        fn from(a: A) -> Self {
            B(a.0)
        }
    }

Instead of

    fn main() {
        let result = B::from(A(1));
        assert_eq!(result, B(1));
    }

You can now do

    fn main() {
        let result = A(1).to::<B>();
        assert_eq!(result, B(1));
    }

lib.rs:

Declarative compile safe explict type conversion. Useful for chaining.

No runtime deps