Skip to content

Commit

Permalink
Add more inlines
Browse files Browse the repository at this point in the history
  • Loading branch information
Jules-Bertholet committed Jul 23, 2021
1 parent e4273b9 commit 09fae07
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crates/js-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,7 @@ impl Default for BigInt {
impl FromStr for BigInt {
type Err = Infallible;

#[inline]
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(BigInt::new(&s.into()))
}
Expand Down Expand Up @@ -1090,6 +1091,7 @@ impl Default for Boolean {
impl Not for &Boolean {
type Output = Boolean;

#[inline]
fn not(self) -> Self::Output {
(!JsValue::as_ref(self)).into()
}
Expand Down Expand Up @@ -2247,6 +2249,7 @@ impl Number {
/// Applies the binary `**` JS operator on the two `Number`s.
///
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Exponentiation)
#[inline]
pub fn pow(&self, rhs: &Self) -> Self {
JsValue::as_ref(self)
.pow(JsValue::as_ref(rhs))
Expand All @@ -2256,6 +2259,7 @@ impl Number {
/// Applies the binary `>>>` JS operator on the two `Number`s.
///
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Unsigned_right_shift)
#[inline]
pub fn unsigned_shr(&self, rhs: &Self) -> Self {
Number::from(JsValue::as_ref(self).unsigned_shr(JsValue::as_ref(rhs)))
}
Expand Down Expand Up @@ -2323,6 +2327,7 @@ impl PartialEq<BigInt> for Number {
impl Not for &Number {
type Output = BigInt;

#[inline]
fn not(self) -> Self::Output {
JsValue::as_ref(self).bit_not().unchecked_into()
}
Expand All @@ -2342,6 +2347,7 @@ forward_js_binop!(impl Mul, mul for Number);
forward_js_binop!(impl Rem, rem for Number);

impl PartialOrd for Number {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
if Number::is_nan(self) || Number::is_nan(other) {
None
Expand All @@ -2354,18 +2360,22 @@ impl PartialOrd for Number {
}
}

#[inline]
fn lt(&self, other: &Self) -> bool {
JsValue::as_ref(self).lt(JsValue::as_ref(other))
}

#[inline]
fn le(&self, other: &Self) -> bool {
JsValue::as_ref(self).le(JsValue::as_ref(other))
}

#[inline]
fn ge(&self, other: &Self) -> bool {
JsValue::as_ref(self).ge(JsValue::as_ref(other))
}

#[inline]
fn gt(&self, other: &Self) -> bool {
JsValue::as_ref(self).gt(JsValue::as_ref(other))
}
Expand All @@ -2375,6 +2385,7 @@ impl FromStr for Number {
type Err = Infallible;

#[allow(deprecated)]
#[inline]
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(Number::new_from_str(s))
}
Expand Down

0 comments on commit 09fae07

Please sign in to comment.