Crate indefinite

source ·
Expand description

Prefix a noun with an indefinite article - a or an - based on whether it begins with a vowel.

Examples

Returns the input string with the article related to the first word

use indefinite::indefinite;

assert_eq!(indefinite("honor"), "an honor");
assert_eq!(indefinite("euro"), "a euro");

Returns the input string with the article related to the first word with the first letter capitalised

use indefinite::indefinite_capitalized;

assert_eq!(indefinite_capitalized("apple"), "An apple");
assert_eq!(indefinite_capitalized("banana"), "A banana");

Returns only the article related to the first word

use indefinite::indefinite_article_only;

assert_eq!(indefinite_article_only("apple"), "an");
assert_eq!(indefinite_article_only("pear"), "a");

Returns only the article related to the first word with the first letter capitalised

use indefinite::indefinite_article_only_capitalized;

assert_eq!(indefinite_article_only_capitalized("apple"), "An");
assert_eq!(indefinite_article_only_capitalized("pear"), "A");

Macros

  • Returns the input string with the article related to the first word (also accepts a list of input string)
  • Returns only the article related to the first word (also accepts a list of input string)
  • Returns only the article related to the first word with the first letter capitalised (also accepts a list of input string)
  • Returns the input string with the article related to the first word with the first letter capitalised (also accepts a list of input string)

Functions