diff options
Diffstat (limited to 'syn/examples/lazy-static/example')
-rw-r--r-- | syn/examples/lazy-static/example/Cargo.toml | 10 | ||||
-rw-r--r-- | syn/examples/lazy-static/example/src/main.rs | 20 |
2 files changed, 0 insertions, 30 deletions
diff --git a/syn/examples/lazy-static/example/Cargo.toml b/syn/examples/lazy-static/example/Cargo.toml deleted file mode 100644 index 716b08c..0000000 --- a/syn/examples/lazy-static/example/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "example" -version = "0.0.0" -authors = ["David Tolnay <dtolnay@gmail.com>"] -edition = "2018" -publish = false - -[dependencies] -lazy_static = { path = "../lazy-static" } -regex = "0.2" diff --git a/syn/examples/lazy-static/example/src/main.rs b/syn/examples/lazy-static/example/src/main.rs deleted file mode 100644 index c4f64af..0000000 --- a/syn/examples/lazy-static/example/src/main.rs +++ /dev/null @@ -1,20 +0,0 @@ -use lazy_static::lazy_static; -use regex::Regex; - -lazy_static! { - static ref USERNAME: Regex = { - println!("Compiling username regex..."); - Regex::new("^[a-z0-9_-]{3,16}$").unwrap() - }; -} - -fn main() { - println!("Let's validate some usernames."); - validate("fergie"); - validate("will.i.am"); -} - -fn validate(name: &str) { - // The USERNAME regex is compiled lazily the first time its value is accessed. - println!("is_match({:?}): {}", name, USERNAME.is_match(name)); -} |