Trait oxford_join::OxfordJoin [−][src]
pub trait OxfordJoin { fn oxford_join(&self, glue: Conjunction<'_>) -> Cow<'_, str>; fn oxford_and(&self) -> Cow<'_, str> { ... } fn oxford_and_or(&self) -> Cow<'_, str> { ... } fn oxford_nor(&self) -> Cow<'_, str> { ... } fn oxford_or(&self) -> Cow<'_, str> { ... } }
Expand description
Oxford Join.
Join a slice of strings with Oxford Commas inserted as necessary.
The return formatting depends on the size of the set:
ⓘ
"" // Zero. "first" // One. "first <CONJUNCTION> last" // Two. "first, second, …, <CONJUNCTION> last" // Three+.
Examples
use oxford_join::{Conjunction, OxfordJoin}; let set = ["Apples", "Oranges"]; assert_eq!(set.oxford_join(Conjunction::And), "Apples and Oranges"); let set = ["Apples", "Oranges", "Bananas"]; assert_eq!(set.oxford_join(Conjunction::And), "Apples, Oranges, and Bananas");
Required methods
fn oxford_join(&self, glue: Conjunction<'_>) -> Cow<'_, str>
[src]
fn oxford_join(&self, glue: Conjunction<'_>) -> Cow<'_, str>
[src]Oxford Join.
Join a slice of strings with Oxford Commas inserted as necessary.
Provided methods
fn oxford_and(&self) -> Cow<'_, str>
[src]
fn oxford_and(&self) -> Cow<'_, str>
[src]Oxford Join (and).
This is equivalent to calling oxford_join(Conjunction::And)
.
Examples
use oxford_join::{Conjunction, OxfordJoin}; let set = ["Apples", "Oranges"]; assert_eq!(set.oxford_join(Conjunction::And), set.oxford_and());
fn oxford_and_or(&self) -> Cow<'_, str>
[src]
fn oxford_and_or(&self) -> Cow<'_, str>
[src]Oxford Join (and/or).
This is equivalent to calling oxford_join(Conjunction::AndOr)
.
Examples
use oxford_join::{Conjunction, OxfordJoin}; let set = ["Apples", "Oranges"]; assert_eq!(set.oxford_join(Conjunction::AndOr), set.oxford_and_or());
fn oxford_nor(&self) -> Cow<'_, str>
[src]
fn oxford_nor(&self) -> Cow<'_, str>
[src]Oxford Join (nor).
This is equivalent to calling oxford_join(Conjunction::Nor)
.
Examples
use oxford_join::{Conjunction, OxfordJoin}; let set = ["Apples", "Oranges"]; assert_eq!(set.oxford_join(Conjunction::Nor), set.oxford_nor());
Implementations on Foreign Types
Oxford Join.
This is a special case; the only array entry will be returned as-is.
Oxford Join.
This is a special case; it will always read “first