Rust 2021

- Consts map generated using iterators
pull/6/head
ondra05 2022-02-23 21:47:07 +01:00
parent 67823468b1
commit 260e9efa84
3 changed files with 7 additions and 9 deletions

View File

@ -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"

View File

@ -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;

View File

@ -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"