Skip to content

Commit

Permalink
Allow testing/example with no features (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
bgermann authored Jun 28, 2024
1 parent 5cb58ce commit 9c9e138
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions examples/hash.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
extern crate bcrypt;

#[cfg(any(feature = "alloc", feature = "std"))]
use bcrypt::{hash, verify, DEFAULT_COST};

#[cfg(any(feature = "alloc", feature = "std"))]
fn main() {
let hashed = hash("hunter2", DEFAULT_COST).unwrap();
let valid = verify("hunter2", &hashed).unwrap();
println!("{:?}", valid);
}

#[cfg(not(any(feature = "alloc", feature = "std")))]
fn main() {}
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ pub fn verify<P: AsRef<[u8]>>(password: P, hash: &str) -> BcryptResult<bool> {
Ok(source_decoded.ct_eq(&generated_decoded).into())
}

#[cfg(test)]
#[cfg(all(test, any(feature = "alloc", feature = "std")))]
mod tests {
use super::{
_hash_password,
Expand Down

0 comments on commit 9c9e138

Please sign in to comment.