[−][src]Function beaver::sequence_a
pub fn sequence_a(from: &str, n: u16) -> String
Returns a consecutive letter. from
is the first letter.
Example
- If
from
is "z" andn
is 1, this function returns "z". - If
from
is "z" andn
is 2, this function returns "aa". - If
from
is "z" andn
is 20, this function returns "ba".
Usage
use chrono::{NaiveDate, NaiveDateTime}; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize)] struct Post { id: u16, title: String, approved: bool, created_at: NaiveDateTime, } beaver::define! { PostFactory (Post) { id -> |n| n, // First post's title: "post-a" // Second post's title: "post-b" title -> |n| format!("post-{}", beaver::sequence_a("a", n)), approved -> |_| false, created_at -> |_| NaiveDate::from_ymd(2020, 1, 1).and_hms(0, 0, 0), } }