Skip to content

Commit

Permalink
Fix vector_map layout, bump version to 0.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MrElectrify committed Mar 11, 2024
1 parent d5a6d13 commit b94372b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "eastl-rs"
authors = ["Andrew Buck"]
description = "EASTL binary-compatible Rust implementations"
documentation = "https://docs.rs/crate/eastl-rs"
version = "0.12.0"
version = "0.13.0"
edition = "2021"
license-file = "LICENSE"
readme = "README.md"
Expand Down
13 changes: 6 additions & 7 deletions src/vector_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crate::compare::{Compare, Less};
use crate::vector::Vector;
use std::cmp::Ordering;
use std::fmt::{Debug, Formatter};
use std::marker::PhantomData;
use std::ops::Deref;
use superslice::Ext;

Expand All @@ -14,15 +13,15 @@ pub type DefaultVectorMap<K, V, C = Less<K>> = VectorMap<K, V, DefaultAllocator,
#[repr(C)]
pub struct VectorMap<K: Eq, V, A: Allocator, C: Compare<K> = Less<K>> {
base: Vector<(K, V), A>,
_phantom: PhantomData<C>,
_compare: C,
}

impl<K: Eq + PartialOrd, V, A: Allocator + Default> VectorMap<K, V, A, Less<K>> {
/// Creates a new empty vector map
pub fn new() -> Self {
Self {
base: Vector::new(),
_phantom: PhantomData,
_compare: Less::default(),
}
}

Expand All @@ -34,12 +33,12 @@ impl<K: Eq + PartialOrd, V, A: Allocator + Default> VectorMap<K, V, A, Less<K>>
pub fn with_capacity(capacity: usize) -> Self {
Self {
base: Vector::with_capacity(capacity),
_phantom: Default::default(),
_compare: Less::default(),
}
}
}

impl<K: Eq, V, A: Allocator, C: Compare<K>> VectorMap<K, V, A, C> {
impl<K: Eq, V, A: Allocator, C: Compare<K> + Default> VectorMap<K, V, A, C> {
/// Returns the capacity of the vector map
pub fn capacity(&self) -> usize {
self.base.capacity()
Expand Down Expand Up @@ -149,7 +148,7 @@ impl<K: Eq, V, A: Allocator, C: Compare<K>> VectorMap<K, V, A, C> {
pub unsafe fn new_in(allocator: A) -> Self {
Self {
base: Vector::new_in(allocator),
_phantom: PhantomData,
_compare: C::default(),
}
}

Expand Down Expand Up @@ -290,7 +289,7 @@ mod test {
fn layout() {
assert_eq!(
std::mem::size_of::<DefaultVectorMap<u32, u32>>(),
std::mem::size_of::<usize>() * 4
std::mem::size_of::<usize>() * 5
);
}

Expand Down

0 comments on commit b94372b

Please sign in to comment.