tryfromfail 0.1.0

Derive failing TryFrom for a set of target types.
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 6.55 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 270.52 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 3s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • samgreen/tryfromfail
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • green-s

tryfromfail

Latest Version Documentation

Custom derive failing TryFrom implementations for a set of target types.

Returns the original value as Err(value).

Example

#[macro_use]
extern crate tryfromfail;

use std::convert::TryInto;

#[derive(Debug, PartialEq, FailingTryFrom)]
#[FailingTryFrom(OtherType)]
struct SomeType {}

#[derive(Debug, PartialEq)]
struct OtherType {}

#[test]
fn works() {
    let val = OtherType {};
    let failed_try_from: Result<SomeType, OtherType> = val.try_into();
    assert_eq!(failed_try_from, Err(OtherType {}));
}