From b8bb816d72217c1afdb18858481db737e52a4e7f Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Sun, 7 Mar 2021 10:47:42 -0700 Subject: don't waste time blocking for no reason --- src/basic_actors.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/basic_actors.rs') diff --git a/src/basic_actors.rs b/src/basic_actors.rs index 130c1e2..6418694 100644 --- a/src/basic_actors.rs +++ b/src/basic_actors.rs @@ -26,7 +26,7 @@ impl Actorful for Constant { let value = self.value.clone(); Box::new(move || { loop { - output_channels["Value"].send(value.clone()).unwrap() + let _ = output_channels["Value"].try_send(value.clone()); } }) } @@ -58,7 +58,7 @@ impl Actorful for Add { Box::new(move || { for (n1, n2) in n1.iter().zip(n2.iter()) { if let (Value::Number(n1), Value::Number(n2)) = (n1, n2) { - output_channels["Result"].send(Value::Number(n1 + n2)).unwrap(); + let _ = output_channels["Result"].try_send(Value::Number(n1 + n2)); } } }) @@ -97,11 +97,9 @@ impl Actorful for RepeatValue { Box::new(move || { for (value, count) in value.iter().zip(count.iter()) { if let Value::Number(count) = count { - // TODO figure out what a smart thing to do would be here instead - // this API design is deliberately suboptimal because i'd like to not do it let count: usize = count.try_into().unwrap(); let vec = vec![value; count]; - output_channels["List"].send(Value::List(vec)).unwrap(); + let _ = output_channels["List"].try_send(Value::List(vec)); } } }) @@ -137,7 +135,7 @@ impl Actorful for DeconstructRecord { for record in record.iter() { if let Value::Record(fields) = record { for (label, value) in fields { - output_channels[&label].send(value).unwrap(); + let _ = output_channels[&label].try_send(value); } } } -- cgit v1.2.3