Skip to content

Commit

Permalink
Add convenience trait impls for CName (#40)
Browse files Browse the repository at this point in the history
* Add convenience trait impls for CName

* Impl Display for CName

Co-authored-by: jac3km4 <[email protected]>

* Prevent from using Display impl in unit-tests

---------

Co-authored-by: jac3km4 <[email protected]>
  • Loading branch information
Roms1383 and jac3km4 authored Dec 15, 2023
1 parent 87ddfb4 commit 52ee3f3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions red4ext-sys/src/interop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ impl CName {
}
}

#[cfg(not(test))] // only available in-game
impl std::fmt::Display for CName {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", crate::ffi::resolve_cname(self))
}
}

pub const fn fnv1a64(str: &str) -> u64 {
const PRIME: u64 = 0x0100_0000_01b3;
const SEED: u64 = 0xCBF2_9CE4_8422_2325;
Expand Down

0 comments on commit 52ee3f3

Please sign in to comment.