diff options
author | Bert Belder <bertbelder@gmail.com> | 2020-08-18 18:30:13 +0200 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2020-08-19 02:01:48 +0200 |
commit | 27f4aeb92469660fdd78a89a7b2902c08a23ca4a (patch) | |
tree | e2076aaf31f0708e5037f46d3750f93b0d637417 /cli/ops/random.rs | |
parent | de1007fc6a2a6c2909732dcb87a5af6c1e370b09 (diff) |
Make Rc/Arc wrapper around State/GlobalState visible (#7104)
Diffstat (limited to 'cli/ops/random.rs')
-rw-r--r-- | cli/ops/random.rs | 9 |
1 files changed, 5 insertions, 4 deletions
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<State>) { 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<State>, _args: Value, zero_copy: &mut [ZeroCopyBuf], ) -> Result<JsonOp, OpError> { 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]); |