Skip to content
Open
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
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ edition = "2018"

version = "0.3.1"
authors = ["wycats", "rustasync"]

[features]
default = ["std"]
std = []

[dependencies]
cfg-if = "1.0.0"
22 changes: 19 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,20 @@
#![doc(test(attr(allow(unused_extern_crates, unused_variables))))]
#![doc(html_favicon_url = "https://yoshuawuyts.com/assets/http-rs/favicon.ico")]
#![doc(html_logo_url = "https://yoshuawuyts.com/assets/http-rs/logo-rounded.png")]
#![cfg_attr(not(feature = "std"), no_std)]

use std::cmp::Ordering;
use std::collections::{btree_map, BTreeMap};
use std::ops::Index;
#![cfg_attr(not(feature = "std"), macro_use)]
extern crate alloc;

use core::cmp::Ordering;
use alloc::collections::{btree_map, BTreeMap};
use core::ops::Index;

#[cfg(not(feature = "std"))]
use alloc::{
vec::Vec, vec,
string::{String, ToString}
};

use crate::nfa::{CharacterClass, NFA};

Expand Down Expand Up @@ -348,6 +358,12 @@ fn process_star_state<T>(nfa: &mut NFA<T>, mut state: usize) -> usize {

#[cfg(test)]
mod tests {
#[cfg(not(feature = "std"))]
use alloc::{
vec::Vec,
string::{String, ToString}
};

use super::{Params, Router};

#[test]
Expand Down
15 changes: 12 additions & 3 deletions src/nfa.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
use std::collections::HashSet;
use alloc::collections::BTreeSet;

#[cfg(not(feature = "std"))]
use alloc::{
vec::Vec, vec, format,
string::{String, ToString}
};

use self::CharacterClass::{Ascii, InvalidChars, ValidChars};

#[derive(PartialEq, Eq, Clone, Default, Debug)]
pub struct CharSet {
low_mask: u64,
high_mask: u64,
non_ascii: HashSet<char>,
non_ascii: BTreeSet<char>,
}

impl CharSet {
pub fn new() -> Self {
Self {
low_mask: 0,
high_mask: 0,
non_ascii: HashSet::new(),
non_ascii: BTreeSet::new(),
}
}

Expand Down Expand Up @@ -401,6 +407,9 @@ fn capture<T>(

#[cfg(test)]
mod tests {
#[cfg(not(feature = "std"))]
use alloc::vec;

use super::{CharSet, CharacterClass, NFA};

#[test]
Expand Down