Skip to content

Commit

Permalink
Fix logs example
Browse files Browse the repository at this point in the history
  • Loading branch information
gyscos committed Aug 3, 2024
1 parent 64540d6 commit b3ae417
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cursive/examples/logs.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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 || {
Expand All @@ -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<String>, cb_sink: cursive::CbSink) {
fn generate_logs(tx: &Sender<String>, cb_sink: cursive::CbSink) {
let mut i = 1;
loop {
let line = format!("Interesting log line {i}");
Expand All @@ -55,12 +55,12 @@ struct BufferView {
// We'll use a ring buffer
buffer: VecDeque<String>,
// Receiving end of the stream
rx: mpsc::Receiver<String>,
rx: Receiver<String>,
}

impl BufferView {
// Creates a new view with the given buffer size
fn new(size: usize, rx: mpsc::Receiver<String>) -> Self {
fn new(size: usize, rx: Receiver<String>) -> Self {
let mut buffer = VecDeque::new();
buffer.resize(size, String::new());
BufferView { buffer, rx }
Expand Down

0 comments on commit b3ae417

Please sign in to comment.