macro_rules! proto_method {
($class:expr, $method:expr, $body:expr) => { ... };
}Expand description
Create a method assignment on a prototype with Vec
§Examples
ⓘ
let body_stmts = vec![
ts_quote!( const result = {}; as Stmt ),
ts_quote!( return result; as Stmt ),
];
// Simple: Class.prototype.method = function() { body }
let stmt = proto_method!(MyClass, "toJSON", body_stmts);
// With dynamic class name:
let class_ident = ident!("User");
let stmt = proto_method!(class_ident, "toString", body_stmts);