mirror of
https://github.com/denoland/deno.git
synced 2024-12-12 10:37:52 -05:00
17 lines
304 B
Markdown
17 lines
304 B
Markdown
|
# deno_ops
|
||
|
|
||
|
`proc_macro` for generating highly optimized V8 functions from Deno ops.
|
||
|
|
||
|
```rust
|
||
|
// Declare an op.
|
||
|
#[op]
|
||
|
pub fn op_add(_: &mut OpState, a: i32, b: i32) -> Result<i32, AnyError> {
|
||
|
Ok(a + b)
|
||
|
}
|
||
|
|
||
|
// Register with an extension.
|
||
|
Extension::builder()
|
||
|
.ops(vec![op_add::decl()])
|
||
|
.build();
|
||
|
```
|