UnaryOp

Enum UnaryOp 

Source
pub enum UnaryOp {
    IncrementPost,
    IncrementPre,
    DecrementPost,
    DecrementPre,
    Minus,
    Plus,
    Not,
    Tilde,
    TypeOf,
    Delete,
    Void,
}
Expand description

A unary operator is one that takes a single operand/argument and performs an operation.

A unary operation is an operation with only one operand. This operand comes either before or after the operator. Unary operators are more efficient than standard JavaScript function calls.

More information:

Variants§

§

IncrementPost

The increment operator increments (adds one to) its operand and returns a value.

Syntax: ++x

This operator increments and returns the value after incrementing.

More information:

§

IncrementPre

The increment operator increments (adds one to) its operand and returns a value.

Syntax: x++

This operator increments and returns the value before incrementing.

More information:

§

DecrementPost

The decrement operator decrements (subtracts one from) its operand and returns a value.

Syntax: --x

This operator decrements and returns the value before decrementing.

More information:

§

DecrementPre

The decrement operator decrements (subtracts one from) its operand and returns a value.

Syntax: x--

This operator decrements the operand and returns the value after decrementing.

More information:

§

Minus

The unary negation operator precedes its operand and negates it.

Syntax: -x

Converts non-numbers data types to numbers like unary plus, however, it performs an additional operation, negation.

More information:

§

Plus

The unary plus operator attempts to convert the operand into a number, if it isn’t already.

Syntax: +x

Although unary negation (-) also can convert non-numbers, unary plus is the fastest and preferred way of converting something into a number, because it does not perform any other operations on the number. It can convert string representations of integers and floats, as well as the non-string values true, false, and null.

More information:

§

Not

Returns false if its single operand can be converted to true; otherwise, returns true.

Syntax: !x

Boolean values simply get inverted: !true === false and !false === true. Non-boolean values get converted to boolean values first, then are negated. This means that it is possible to use a couple of NOT operators in series to explicitly force the conversion of any value to the corresponding boolean primitive.

More information:

§

Tilde

Performs the NOT operator on each bit.

Syntax: ~x

NOT a yields the inverted value (or one’s complement) of a. Bitwise NOTing any number x yields -(x + 1). For example, ~-5 yields 4.

More information:

§

TypeOf

The typeof operator returns a string indicating the type of the unevaluated operand.

Syntax: typeof x or typeof(x)

The typeof is a JavaScript keyword that will return the type of a variable when you call it. You can use this to validate function parameters or check if variables are defined. There are other uses as well.

More information:

§

Delete

The JavaScript delete operator removes a property from an object.

Syntax: delete x

Unlike what common belief suggests, the delete operator has nothing to do with directly freeing memory. Memory management is done indirectly via breaking references. If no more references to the same property are held, it is eventually released automatically.

The delete operator returns true for all cases except when the property is an own non-configurable property, in which case, false is returned in non-strict mode.

More information:

§

Void

The void operator evaluates the given expression and then returns undefined.

Syntax: void x

This operator allows evaluating expressions that produce a value into places where an expression that evaluates to undefined is desired. The void operator is often used merely to obtain the undefined primitive value, usually using void(0) (which is equivalent to void 0). In these cases, the global variable undefined can be used.

When using an immediately-invoked function expression, void can be used to force the function keyword to be treated as an expression instead of a declaration.

More information:

Trait Implementations§

Source§

impl Clone for UnaryOp

Source§

fn clone(&self) -> UnaryOp

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UnaryOp

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for UnaryOp

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Finalize for UnaryOp

Source§

impl PartialEq for UnaryOp

Source§

fn eq(&self, other: &UnaryOp) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Trace for UnaryOp

Source§

unsafe fn trace(&self)

Marks all contained Gcs.
Source§

unsafe fn root(&self)

Increments the root-count of all contained Gcs.
Source§

unsafe fn unroot(&self)

Decrements the root-count of all contained Gcs.
Source§

fn finalize_glue(&self)

Runs Finalize::finalize() on this object and all contained subobjects
Source§

impl Copy for UnaryOp

Source§

impl StructuralPartialEq for UnaryOp

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> NativeObject for T
where T: Any + Debug + Trace,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert the Rust type which implements NativeObject to a &dyn Any.
Source§

fn as_mut_any(&mut self) -> &mut (dyn Any + 'static)

Convert the Rust type which implements NativeObject to a &mut dyn Any.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DynCopy for T
where T: Copy,