Skip to content

Commit 6089675

Browse files
committed
[deps] remove lazy_static dependency
1 parent f61302f commit 6089675

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rasterize"
3-
version = "0.4.2"
3+
version = "0.4.3"
44
authors = ["Pavel Aslanov <asl.pavel@gmail.com>"]
55
description = "Simple and small 2D rendering library"
66
edition = "2021"
@@ -30,7 +30,6 @@ serde = { version = "1.0", features = ["rc", "derive"], optional = true }
3030
serde_json = { version = "1.0", features = ["preserve_order"], optional = true }
3131
png = { version = "^0.17", optional = true }
3232
bytemuck = { version = "1.13", features = ["derive"] }
33-
lazy_static = "^1.1"
3433

3534
[dev-dependencies]
3635
criterion = { version = "^0.5", features = ["html_reports"] }

src/color.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,22 @@ use std::{
77
fmt,
88
ops::{Add, Mul},
99
str::FromStr,
10+
sync::LazyLock,
1011
};
1112

12-
lazy_static::lazy_static! {
13-
pub static ref SVG_COLORS: HashMap<String, RGBA> = {
14-
let empty = HashMap::new(); // do not use parse to avoid recursive lock
15-
include_str!("./svg-colors.txt")
16-
.lines()
17-
.map(|line| {
18-
let mut iter = line.split(' ');
19-
let name = iter.next()?;
20-
let color = RGBA::from_str_named(iter.next()?, &empty).ok()?;
21-
Some((name.to_owned(), color))
22-
})
23-
.collect::<Option<HashMap<String, RGBA>>>()
24-
.expect("failed to parse embedded svg colors")
25-
};
26-
}
13+
pub static SVG_COLORS: LazyLock<HashMap<String, RGBA>> = LazyLock::new(|| {
14+
let empty = HashMap::new(); // do not use parse to avoid recursive lock
15+
include_str!("./svg-colors.txt")
16+
.lines()
17+
.map(|line| {
18+
let mut iter = line.split(' ');
19+
let name = iter.next()?;
20+
let color = RGBA::from_str_named(iter.next()?, &empty).ok()?;
21+
Some((name.to_owned(), color))
22+
})
23+
.collect::<Option<HashMap<String, RGBA>>>()
24+
.expect("failed to parse embedded svg colors")
25+
});
2726

2827
/// Common interface to all color representations
2928
pub trait Color: Copy {

0 commit comments

Comments
 (0)