Skip to content

Commit 8f0c141

Browse files
update pow functions
1 parent 7734661 commit 8f0c141

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

wasm/src/types/integer.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use crate::{
1919
to_bits_array_le,
2020
types::native::*,
2121
};
22+
// use crate::types::{U8, U16, U32};
2223
use js_sys::{Array, Uint8Array};
2324
use std::{ops::Deref, str::FromStr};
2425
use wasm_bindgen::prelude::*;
@@ -115,10 +116,22 @@ macro_rules! impl_integer {
115116
Self(self.0.div_wrapped(&other.0))
116117
}
117118

118-
/// Power.
119-
#[wasm_bindgen(js_name = "pow")]
120-
pub fn pow(&self, other: &$name) -> $name {
121-
Self(self.0.pow(&other.0))
119+
/// Power to a u8 exponent.
120+
#[wasm_bindgen(js_name = "powU8")]
121+
pub fn pow_u8(&self, exponent: &U8) -> $name {
122+
Self(self.0.pow(&exponent.0))
123+
}
124+
125+
/// Power to a u16 exponent.
126+
#[wasm_bindgen(js_name = "powU16")]
127+
pub fn pow_u16(&self, exponent: &U16) -> $name {
128+
Self(self.0.pow(&exponent.0))
129+
}
130+
131+
/// Power to a u32 exponent.
132+
#[wasm_bindgen(js_name = "powU32")]
133+
pub fn pow_u32(&self, exponent: &U32) -> $name {
134+
Self(self.0.pow(&exponent.0))
122135
}
123136

124137
/// Remainder.

0 commit comments

Comments
 (0)