Rust 2021
- Consts map generated using iterators
This commit is contained in:
parent
81f713a5e2
commit
a23dac3ce0
|
@ -2,7 +2,7 @@
|
|||
name = "ablescript"
|
||||
version = "0.2.0"
|
||||
authors = ["able <abl3theabove@gmail.com>"]
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
|
||||
description = "The best programming language"
|
||||
license = "MIT"
|
||||
|
|
|
@ -9,8 +9,7 @@ use crate::variables::{Value, Variable};
|
|||
pub fn ablescript_consts() -> HashMap<String, Variable> {
|
||||
use Value::*;
|
||||
|
||||
let mut map = HashMap::new();
|
||||
for (name, value) in &[
|
||||
[
|
||||
("TAU", Int(6)), // Circumference / radius
|
||||
("PI", Int(3)), // Deprecated, do not use
|
||||
("EULER", Int(3)), // Mathematical constant e
|
||||
|
@ -31,11 +30,10 @@ pub fn ablescript_consts() -> HashMap<String, Variable> {
|
|||
),
|
||||
("OCTOTHORPE", Str("#".to_owned())), // It's an octothorpe
|
||||
("ANSWER", Int(ANSWER)),
|
||||
] {
|
||||
map.insert((*name).to_owned(), Variable::from_value(value.to_owned()));
|
||||
}
|
||||
|
||||
map
|
||||
]
|
||||
.into_iter()
|
||||
.map(|(name, value)| (name.to_owned(), Variable::from_value(value)))
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub const ANSWER: isize = 42;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
name = "ablescript_cli"
|
||||
version = "0.2.0"
|
||||
authors = ["able <abl3theabove@gmail.com>"]
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
|
||||
description = "The best programming language"
|
||||
license = "MIT"
|
||||
|
|
Loading…
Reference in a new issue