Skip to content

Commit 166e60c

Browse files
committed
Replace use of unmaintained and deprecated generational-area with slotmap
Unfortunately this requires a major version bump as the g-a's Index is in the public API. While we're at this, this change also makes that field private. Fixes femtovg#198
1 parent 60adc6a commit 166e60c

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file.
33

44
## Unreleased
55

6+
## [0.9.0] - 2024-TBD
7+
8+
- **breaking**: Removed pub key field in ImageId. This accidentally
9+
exposed the implementation detail of the image store (generational-arena),
10+
which has been replaced with slotmap.
611
- Bumped MSRV to 1.66.
712

813
## [0.8.2] - 2024-01-20

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "femtovg"
33
description = "Antialiased 2D vector drawing library"
4-
version = "0.8.2"
4+
version = "0.9.0"
55
license = "MIT/Apache-2.0"
66
readme = "README.md"
77
authors = [
@@ -25,7 +25,7 @@ bitflags = "2.0.2"
2525
rustybuzz = "0.11.0"
2626
unicode-bidi = "0.3.4"
2727
unicode-segmentation = "1.6.0"
28-
generational-arena = "0.2.8"
28+
slotmap = "1.0.7"
2929
lru = { version = "0.12.0", default-features = false }
3030
image = { version = "0.24.0", optional = true, default-features = false }
3131
serde = { version = "1.0", optional = true, features = ["derive", "rc"] }

src/image.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use bitflags::bitflags;
2-
use generational_arena::{Arena, Index};
32
use imgref::*;
43
use rgb::alt::GRAY8;
54
use rgb::*;
5+
use slotmap::{DefaultKey, SlotMap};
66

77
#[cfg(feature = "image-loading")]
88
use ::image::DynamicImage;
@@ -14,7 +14,7 @@ use crate::{ErrorKind, Renderer};
1414

1515
/// An image handle.
1616
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
17-
pub struct ImageId(pub Index);
17+
pub struct ImageId(DefaultKey);
1818

1919
/// Image format: `Rgb8`, `Rgba8`, `Gray8`.
2020
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
@@ -182,7 +182,7 @@ impl ImageInfo {
182182
}
183183
}
184184

185-
pub struct ImageStore<T>(Arena<(ImageInfo, T)>);
185+
pub struct ImageStore<T>(SlotMap<DefaultKey, (ImageInfo, T)>);
186186

187187
impl<T> Default for ImageStore<T> {
188188
fn default() -> Self {
@@ -192,7 +192,7 @@ impl<T> Default for ImageStore<T> {
192192

193193
impl<T> ImageStore<T> {
194194
pub fn new() -> Self {
195-
Self(Arena::new())
195+
Self(SlotMap::new())
196196
}
197197

198198
pub fn alloc<R: Renderer<Image = T>>(&mut self, renderer: &mut R, info: ImageInfo) -> Result<ImageId, ErrorKind> {

src/text.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ use std::{
1111
};
1212

1313
use fnv::{FnvBuildHasher, FnvHashMap, FnvHasher};
14-
use generational_arena::{Arena, Index};
1514
use lru::LruCache;
1615
use rustybuzz::ttf_parser;
16+
use slotmap::{DefaultKey, SlotMap};
1717

1818
use unicode_bidi::BidiInfo;
1919
use unicode_segmentation::UnicodeSegmentation;
@@ -44,7 +44,7 @@ const DEFAULT_LRU_CACHE_CAPACITY: usize = 1000;
4444

4545
/// A font handle.
4646
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
47-
pub struct FontId(Index);
47+
pub struct FontId(DefaultKey);
4848

4949
/// Text baseline vertical alignment:
5050
/// `Top`, `Middle`, `Alphabetic` (default), `Bottom`.
@@ -293,7 +293,7 @@ impl TextContext {
293293
}
294294

295295
pub(crate) struct TextContextImpl {
296-
fonts: Arena<Font>,
296+
fonts: SlotMap<DefaultKey, Font>,
297297
shaping_run_cache: ShapingRunCache<FnvBuildHasher>,
298298
shaped_words_cache: ShapedWordsCache<FnvBuildHasher>,
299299
}

0 commit comments

Comments
 (0)