Rust 2021

- Consts map generated using iterators
This commit is contained in:
Erin 2022-02-23 21:47:07 +01:00 committed by ondra05
parent 81f713a5e2
commit a23dac3ce0
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"