From 27f4aeb92469660fdd78a89a7b2902c08a23ca4a Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Tue, 18 Aug 2020 18:30:13 +0200 Subject: Make Rc/Arc wrapper around State/GlobalState visible (#7104) --- cli/ops/random.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'cli/ops/random.rs') diff --git a/cli/ops/random.rs b/cli/ops/random.rs index b29c761b8..275f264f9 100644 --- a/cli/ops/random.rs +++ b/cli/ops/random.rs @@ -6,8 +6,9 @@ use deno_core::CoreIsolate; use deno_core::ZeroCopyBuf; use rand::thread_rng; use rand::Rng; +use std::rc::Rc; -pub fn init(i: &mut CoreIsolate, s: &State) { +pub fn init(i: &mut CoreIsolate, s: &Rc) { i.register_op( "op_get_random_values", s.stateful_json_op(op_get_random_values), @@ -15,14 +16,14 @@ pub fn init(i: &mut CoreIsolate, s: &State) { } fn op_get_random_values( - state: &State, + state: &Rc, _args: Value, zero_copy: &mut [ZeroCopyBuf], ) -> Result { assert_eq!(zero_copy.len(), 1); - if let Some(ref mut seeded_rng) = state.borrow_mut().seeded_rng { - seeded_rng.fill(&mut *zero_copy[0]); + if let Some(seeded_rng) = &state.seeded_rng { + seeded_rng.borrow_mut().fill(&mut *zero_copy[0]); } else { let mut rng = thread_rng(); rng.fill(&mut *zero_copy[0]); -- cgit v1.2.3