faker_rust/default/
code.rs1use crate::base::bothify;
4use crate::locale::{fetch_locale_with_context, sample_with_resolve};
5
6pub fn asin() -> String {
8 fetch_locale_with_context("code.asin", "en", Some("code"))
9 .map(|v| sample_with_resolve(&v, Some("code")))
10 .unwrap_or_else(|| bothify("B000#######"))
11}
12
13pub fn isbn() -> String {
15 fetch_locale_with_context("code.isbn", "en", Some("code"))
16 .map(|v| sample_with_resolve(&v, Some("code")))
17 .unwrap_or_else(|| bothify("#########-#"))
18}
19
20pub fn ean() -> String {
22 fetch_locale_with_context("code.ean", "en", Some("code"))
23 .map(|v| sample_with_resolve(&v, Some("code")))
24 .unwrap_or_else(|| bothify("#############"))
25}
26
27#[cfg(test)]
28mod tests {
29 use super::*;
30
31 #[test]
32 fn test_isbn() {
33 assert!(!isbn().is_empty());
34 }
35
36 #[test]
37 fn test_ean() {
38 assert!(!ean().is_empty());
39 }
40}