Skip to content

Commit

Permalink
refactor: Rename JanetArgs::get_panic to JanetArgs::get_or_panic
Browse files Browse the repository at this point in the history
Breaking change
  • Loading branch information
GrayJack committed Apr 22, 2024
1 parent bb0e280 commit 31978b7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1846,13 +1846,13 @@ pub trait JanetArgs {
///
/// #[janet_fn(arity(fix(1)))]
/// fn my_func(args: &mut [Janet]) -> Janet {
/// let my_str: JanetString = args.get_panic(0);
/// let my_str: JanetString = args.get_or_panic(0);
///
/// // Rest of the function
/// todo!()
/// }
/// ```
fn get_panic<T: TryFrom<Janet> + JanetTypeName>(&self, index: usize) -> T;
fn get_or_panic<T: TryFrom<Janet> + JanetTypeName>(&self, index: usize) -> T;
}

impl JanetArgs for [Janet] {
Expand Down Expand Up @@ -1883,7 +1883,7 @@ impl JanetArgs for [Janet] {
}
}

fn get_panic<T: TryFrom<Janet> + JanetTypeName>(&self, index: usize) -> T {
fn get_or_panic<T: TryFrom<Janet> + JanetTypeName>(&self, index: usize) -> T {
match self.get(index) {
Some(&val) => T::try_from(val).unwrap_or_else(|_| {
crate::jpanic!(
Expand Down

0 comments on commit 31978b7

Please sign in to comment.