RawField

Type Alias RawField 

Source
pub type RawField<'a> = Field<&'a str, &'a str>;
Expand description

Raw string field of a .SRCINFO file.

Aliased Type§

pub struct RawField<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> RawField<'a>

Source

pub fn parse_raw(input: &'a str) -> Self

Parse a RawField from a str.

Without architecture:

let raw_field = RawField::parse_raw("source");
assert_eq!(raw_field.name_str(), "source");
assert_eq!(raw_field.architecture_str(), None);

With architecture:

let raw_field = RawField::parse_raw("source_x86_64");
assert_eq!(raw_field.name_str(), "source");
assert_eq!(raw_field.architecture_str(), Some("x86_64"));
Source

pub fn to_parsed<Name, Architecture>( &self, ) -> Result<Field<Name, Architecture>, ParseFieldError<<&'a str as TryInto<Name>>::Error, <&'a str as TryInto<Architecture>>::Error>>
where &'a str: TryInto<Name> + TryInto<Architecture>,

Try converting a RawField into a Field<Name, Architecture>.

let raw_field = RawField::parse_raw("source_x86_64");
let parsed_field: ParsedField<&str> = raw_field.to_parsed().unwrap();
assert_eq!(parsed_field.name(), &FieldName::Source);
assert_eq!(parsed_field.architecture_str(), Some("x86_64"));