Skip to content

Commit

Permalink
is_true
Browse files Browse the repository at this point in the history
  • Loading branch information
jupyterkat committed Nov 13, 2023
1 parent 7cb5739 commit 1880f8d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/byondapi-rs/src/typecheck_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ pub trait ByondTypeCheck {
fn is_list(&self) -> bool;
/// Check if this is a pointer.
fn is_ptr(&self) -> bool;
/// Check if this is true-ish.
fn is_true(&self) -> bool;
}
5 changes: 5 additions & 0 deletions crates/byondapi-rs/src/value/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,9 @@ impl ByondTypeCheck for ByondValue {
fn is_ptr(&self) -> bool {
is_pointer_shim(self)
}

fn is_true(&self) -> bool {
// Safety: This operation only fails if our CByondValue is invalid, which cannot happen.
unsafe { byond().ByondValue_IsTrue(&self.0) }
}
}

0 comments on commit 1880f8d

Please sign in to comment.