From 058579da562989ed15c86598053644bbc86c6747 Mon Sep 17 00:00:00 2001 From: Aaron O'Mullan Date: Fri, 2 Apr 2021 15:47:57 +0200 Subject: refactor(ops): remove variadic buffers (#9944) --- test_plugin/src/lib.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'test_plugin') diff --git a/test_plugin/src/lib.rs b/test_plugin/src/lib.rs index c4b0916a4..b84dcef48 100644 --- a/test_plugin/src/lib.rs +++ b/test_plugin/src/lib.rs @@ -14,15 +14,14 @@ pub fn deno_plugin_init(interface: &mut dyn Interface) { fn op_test_sync( _interface: &mut dyn Interface, - zero_copy: &mut [ZeroCopyBuf], + zero_copy: Option, ) -> Op { - if !zero_copy.is_empty() { + if zero_copy.is_some() { println!("Hello from plugin."); } - let zero_copy = zero_copy.to_vec(); - for (idx, buf) in zero_copy.iter().enumerate() { + if let Some(buf) = zero_copy { let buf_str = std::str::from_utf8(&buf[..]).unwrap(); - println!("zero_copy[{}]: {}", idx, buf_str); + println!("zero_copy: {}", buf_str); } let result = b"test"; let result_box: Box<[u8]> = Box::new(*result); @@ -31,16 +30,15 @@ fn op_test_sync( fn op_test_async( _interface: &mut dyn Interface, - zero_copy: &mut [ZeroCopyBuf], + zero_copy: Option, ) -> Op { - if !zero_copy.is_empty() { + if zero_copy.is_some() { println!("Hello from plugin."); } - let zero_copy = zero_copy.to_vec(); let fut = async move { - for (idx, buf) in zero_copy.iter().enumerate() { + if let Some(buf) = zero_copy { let buf_str = std::str::from_utf8(&buf[..]).unwrap(); - println!("zero_copy[{}]: {}", idx, buf_str); + println!("zero_copy: {}", buf_str); } let (tx, rx) = futures::channel::oneshot::channel::>(); std::thread::spawn(move || { -- cgit v1.2.3