to_that 1.0.1

Declarative compile safe explict type conversion. Useful for chaining.
Documentation
  • Coverage
  • 66.67%
    2 out of 3 items documented0 out of 2 items with examples
  • Size
  • Source code size: 3.06 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • mcmah309/to_that
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • mcmah309

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));
    }