pub struct CustomOperation { /* private fields */ }
Expand description

A structure that stores a pointer to a custom operation.

A custom operation can be thought of as a polymorphic function, i.e., where the number of inputs and their types can vary.

Any struct can be a custom operation if it implements the CustomOperationBody trait. Then any such struct can be used to create a CustomOperation object that can be addded to a computation graph with Graph::custom_op.

Clone trait duplicates the pointer, not the underlying custom operation.

PartialEq trait compares the related custom operations, not just pointer.

Example

let c = create_context().unwrap();
let g = c.create_graph().unwrap();
let t = array_type(vec![3, 2], BIT);
let n1 = g.input(t).unwrap();
let n2 = g.custom_op(CustomOperation::new(Not {}), vec![n1]).unwrap();

Implementations

Creates a new custom operation that can be added to a computation graph via Graph::custom_op.

Arguments

op - struct that implements the CustomOperationBody trait

Returns

New custom operation

Example
let c = create_context().unwrap();
let g = c.create_graph().unwrap();
let t = array_type(vec![3, 2], BIT);
let n1 = g.input(t).unwrap();
let n2 = g.custom_op(CustomOperation::new(Not {}), vec![n1]).unwrap();

Returns the name of the underlying custom operation by calling CustomOperationBody::get_name.

Returns

Name of this custom operation

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Hashes the custom operation pointer.

Arguments

state - state of a hash function that is changed after hashing the custom operation

Feeds a slice of this type into the given Hasher. Read more

Tests whether self and other custom operations are equal.

The underlying custom operation structs are compared via the Eq trait.

Arguments

other - another CustomOperation

Returns

true if the pointers in self and other point to equal custom operations, false otherwise

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.