this is my code:

use bio::io::bed;
use crossbeam_utils::thread::scope;
use std::io::{self, Read};
use std::sync::{mpsc, Arc, Mutex};

fn main() {
    let mut reader = bed::Reader::from_file(
        "/home/alejandro/Documents/unam/TOGA_old_versions/x/bed_tmp/100k.bed",
    )
    .unwrap();

    println!("{:?}", reader);

    // define the number of messages the channel can hold
    let num_threads = 2;

    // create a synchronous channel with a bounded capacity
    let (tx, rx) = mpsc::sync_channel(num_threads);
    let atomic_reader = Arc::new(Mutex::new(reader.records()));

    // spawn threads to send messages
    let _ = scope(|scope| {
        for _ in 0..num_threads {
            let tx = tx.clone();
            let reader = Arc::clone(&atomic_reader);

            scope.spawn(move |_| {
                loop {
                    match get_next_record(&reader) {
                        Some(rs) => {
                            let record = match rs {
                                Ok(record) => record,
                                Err(err) => panic!("Error reading record: {}", err),
                            };

                            println!("{:?}", record);

                            tx.send(Some(record)).expect("Could not send data");
                        }
                        None => {
                            tx.send(None).expect("Could not send data");
                            break;
                        }
                    } // end match
                } // end loop
            }); // end spawn
        } // end for
    }); // end scope

    // receive messages
    let mut death_txs = 0;
    let mut received = 0;
    println!("{:?}", rx);
    for rc in rx.iter() {
        match rc {
            Some(record) => {
                println!("{:?}", record);
                received += 1;
                eprint!("\rRecords received: {}", received);
            }
            None => {
                death_txs += 1;
                if death_txs == num_threads {
                    drop(tx);
                    break;
                }
            }
        }
    }
}

fn get_next_record<R: io::Read>(
    reader: &Arc<Mutex<bed::Records<R>>>,
) -> Option<Result<bed::Record, csv::Error>> {
    let mut lock = reader.lock().unwrap();
    lock.next()
}

I got this printed out:

Reader { inner: Reader { core: Reader { dfa: Dfa(N/A), dfa_state: DfaState(0), nfa_state: StartRecord, delimiter: 9, term: CRLF, quote: 34, escape: None, double_quote: true, comment: Some(35), quoting: true, use_nfa: false, line: 1, has_read: false, output_pos: 0 }, rdr: BufReader { reader: File { fd: 3, path: "/home/alejandro/Documents/unam/TOGA_old_versions/x/bed_tmp/100k.bed", read: true, write: false }, buffer: 0/8192 }, state: ReaderState { headers: None, has_headers: false, flexible: false, trim: None, first_field_count: None, cur_pos: Position { byte: 0, line: 1, record: 0 }, first: false, seeked: false, eof: NotEof } } }
Record { chrom: "chr8", start: 71780035, end: 71795956, aux: ["ENST00000557082.2", "1000", "-", "71780035", "71795956", "0,0,200", "4", "77,120,148,6,", "0,5046,13138,15915,"] }
Record { chrom: "chr8", start: 38174420, end: 38312141, aux: ["ENST00000555899.2", "1000", "-", "38174420", "38312141", "0,0,200", "13", "100,87,128,120,51,54,109,60,131,93,102,197,157,", "0,2936,5589,10016,12299,12452,13910,14932,15102,30621,37050,61630,137564,"] }
Record { chrom: "chr24", start: 48624484, end: 48626386, aux: ["ENST00000636176.24", "1000", "+", "48624484", "48626386", "0,0,200", "4", "3,276,153,135,", "0,1136,1493,1767,"] }
Record { chrom: "chr9", start: 58699301, end: 58722651, aux: ["ENST00000497580.69", "1000", "-", "58699301", "58722651", "0,0,200", "12", "6,92,141,174,126,130,161,190,135,87,844,185,", "0,512,1929,3815,4924,7282,11484,15828,16163,17671,20743,23165,"] }

but nothing else and the program does not finish