From b3ae41763ac3992bb2af513eba99ada79a4dd2e8 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Sat, 3 Aug 2024 14:22:59 -0400 Subject: [PATCH] Fix logs example --- cursive/examples/logs.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cursive/examples/logs.rs b/cursive/examples/logs.rs index bfc6f8e9..cff99c0f 100644 --- a/cursive/examples/logs.rs +++ b/cursive/examples/logs.rs @@ -1,8 +1,8 @@ +use crossbeam_channel::{unbounded, Receiver, Sender}; use cursive::traits::*; use cursive::Vec2; use cursive::{Cursive, Printer}; use std::collections::VecDeque; -use std::sync::mpsc; use std::thread; use std::time::Duration; @@ -20,7 +20,7 @@ fn main() { siv.add_global_callback('q', |s| s.quit()); // A channel will communicate data from our running task to the UI. - let (tx, rx) = mpsc::channel(); + let (tx, rx) = unbounded(); // Generate data in a separate thread. thread::spawn(move || { @@ -35,7 +35,7 @@ fn main() { // We will only simulate log generation here. // In real life, this may come from a running task, a separate process, ... -fn generate_logs(tx: &mpsc::Sender, cb_sink: cursive::CbSink) { +fn generate_logs(tx: &Sender, cb_sink: cursive::CbSink) { let mut i = 1; loop { let line = format!("Interesting log line {i}"); @@ -55,12 +55,12 @@ struct BufferView { // We'll use a ring buffer buffer: VecDeque, // Receiving end of the stream - rx: mpsc::Receiver, + rx: Receiver, } impl BufferView { // Creates a new view with the given buffer size - fn new(size: usize, rx: mpsc::Receiver) -> Self { + fn new(size: usize, rx: Receiver) -> Self { let mut buffer = VecDeque::new(); buffer.resize(size, String::new()); BufferView { buffer, rx }