Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move hashbrown behind no_std feature #168

Merged
merged 3 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ unicode-linebreak = "0.1.4"
unicode-script = "0.5.5"
unicode-segmentation = "1.10.0"
rangemap = "1.2.0"
hashbrown = { version = "0.14.0", default-features = false }
hashbrown = { version = "0.14.0", optional = true, default-features = false }
rustc-hash = { version = "1.1.0", default-features = false }

[dependencies.unicode-bidi]
Expand All @@ -33,6 +33,7 @@ features = ["hardcoded-data"]
default = ["std", "swash"]
no_std = [
"rustybuzz/libm",
"hashbrown",
]
std = [
"fontdb/memmap",
Expand Down
16 changes: 8 additions & 8 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ cargo fmt --check
echo Build with default features
build

echo Build with no default features
build --no-default-features
echo Build with only no_std feature
build --no-default-features --features no_std

echo Build with only std feature
build --no-default-features --features std

echo Build with only swash feature
build --no-default-features --features swash
echo Build with only std and swash features
build --no-default-features --features std,swash

echo Build with only syntect feature
build --no-default-features --features syntect
echo Build with only std and syntect features
build --no-default-features --features std,syntect

echo Build with only vi feature
build --no-default-features --features vi
echo Build with only std and vi features
build --no-default-features --features std,vi

echo Build with all features
build --all-features
Expand Down
8 changes: 6 additions & 2 deletions src/font/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ use alloc::string::String;
use alloc::sync::Arc;
use alloc::vec::Vec;
use core::fmt;
use core::hash::BuildHasherDefault;
use core::ops::{Deref, DerefMut};

type HashMap<K, V> = hashbrown::HashMap<K, V, BuildHasherDefault<rustc_hash::FxHasher>>;
type BuildHasher = core::hash::BuildHasherDefault<rustc_hash::FxHasher>;

#[cfg(feature = "std")]
type HashMap<K, V> = std::collections::HashMap<K, V, BuildHasher>;
#[cfg(not(feature = "std"))]
type HashMap<K, V> = hashbrown::HashMap<K, V, BuildHasher>;

// re-export fontdb and rustybuzz
pub use fontdb;
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@
// Ensure numbers are readable
#![warn(clippy::unreadable_literal)]
#![cfg_attr(not(feature = "std"), no_std)]

extern crate alloc;

#[cfg(not(any(feature = "std", feature = "no_std")))]
compile_error!("Either the `std` or `no_std` feature must be enabled");

pub use self::attrs::*;
mod attrs;

Expand Down