Skip to content

Commit

Permalink
Do not lock stdin() in fzf example
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrutar committed Jan 3, 2025
1 parent a9a7ce4 commit a2fd96b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ cat myfile.txt | ./target/release/examples/fzf
```
The code to create the binary:
```rust
use std::{
io::{self, BufRead},
process::exit,
thread::spawn,
};
use std::{io, process::exit, thread::spawn};

use nucleo_picker::{render::StrRenderer, Picker};

Expand All @@ -56,7 +52,7 @@ fn main() -> io::Result<()> {

let injector = picker.injector();
spawn(move || {
for line in io::stdin().lock().lines() {
for line in io::stdin().lines() {
if let Ok(s) = line {
injector.push(s);
}
Expand Down
8 changes: 2 additions & 6 deletions examples/fzf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
//!
//! Read lines from `stdin` in a streaming fashion and populate the picker, imitating the basic
//! functionality of [fzf](https://github.com/junegunn/fzf).
use std::{
io::{self, BufRead},
process::exit,
thread::spawn,
};
use std::{io, process::exit, thread::spawn};

use nucleo_picker::{render::StrRenderer, Picker};

Expand All @@ -15,7 +11,7 @@ fn main() -> io::Result<()> {

let injector = picker.injector();
spawn(move || {
for line in io::stdin().lock().lines() {
for line in io::stdin().lines() {
// silently drop IO errors!
if let Ok(s) = line {
injector.push(s);
Expand Down

0 comments on commit a2fd96b

Please sign in to comment.