summaryrefslogtreecommitdiff
path: root/cli/ops/random.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/ops/random.rs')
-rw-r--r--cli/ops/random.rs9
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]);