parse-suffix 0.1.2

Process the string suffix as `.parse::<suffix>().unwrap()`
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented2 out of 2 items with examples
  • Size
  • Source code size: 8.03 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 260.12 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
  • A4-Tacks/parse-suffix-rs
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • A4-Tacks

Process the string suffix as .parse::<suffix>().unwrap()

Examples

use std::{net::Ipv4Addr, path::PathBuf};

#[parse_suffix::parse_string_suffix]
fn test() {
    assert_eq!("23"i32, 23);
    assert_eq!("23"PathBuf, PathBuf::from("23"));
    assert_eq!("true"bool, true);
    assert_eq!("false"bool, false);
    assert_eq!("192.168.1.1"Ipv4Addr, Ipv4Addr::new(192, 168, 1, 1));
    assert_eq!(r"192.168.1.1"Ipv4Addr, Ipv4Addr::new(192, 168, 1, 1));
    assert_eq!(r#"192.168.1.1"#Ipv4Addr, Ipv4Addr::new(192, 168, 1, 1));
}

Expand to:

use std::{net::Ipv4Addr, path::PathBuf};

fn test() {
    assert_eq!("23".parse::<i32>().unwrap(), 23);
    assert_eq!("23".parse::<PathBuf>().unwrap(), PathBuf::from("23"));
    assert_eq!("true".parse::<bool>().unwrap(), true);
    assert_eq!("false".parse::<bool>().unwrap(), false);
    assert_eq!("192.168.1.1".parse::<Ipv4Addr>().unwrap(), Ipv4Addr::new(192, 168, 1, 1));
    assert_eq!(r"192.168.1.1".parse::<Ipv4Addr>().unwrap(), Ipv4Addr::new(192, 168, 1, 1));
    assert_eq!(r#"192.168.1.1"#.parse::<Ipv4Addr>().unwrap(), Ipv4Addr::new(192, 168, 1, 1));
}