Skip to main content

Crate parse_author

Crate parse_author 

Source
Expand description

§parse-author — parse an npm-style author string

Parse a person string in the "Name <email> (url)" form used by package.json author/contributors fields into its components. A faithful Rust port of the parse-author npm package (and the author-regex it is built on). Zero dependencies and #![no_std].

use parse_author::parse_author;

let a = parse_author("Jon Schlinkert <jon@example.com> (https://github.com/jonschlinkert)");
assert_eq!(a.name.as_deref(), Some("Jon Schlinkert"));
assert_eq!(a.email.as_deref(), Some("jon@example.com"));
assert_eq!(a.url.as_deref(), Some("https://github.com/jonschlinkert"));

assert_eq!(parse_author("Jane Doe").name.as_deref(), Some("Jane Doe"));
assert_eq!(parse_author("<me@example.com>").email.as_deref(), Some("me@example.com"));

Structs§

Author
A parsed author. Each field is present only when found in the input.

Functions§

parse_author
Parse an author string into its Author parts.