Skip to content

Instantly share code, notes, and snippets.

@bsnacks000
Created June 20, 2024 11:03
Show Gist options
  • Select an option

  • Save bsnacks000/45985a1ceb1aed740920767c5e93d3ab to your computer and use it in GitHub Desktop.

Select an option

Save bsnacks000/45985a1ceb1aed740920767c5e93d3ab to your computer and use it in GitHub Desktop.
// use std::fs::File;
use itertools::Itertools;
use std::io::{self, BufRead, BufReader, BufWriter, Write};
use serde::{Deserialize, Serialize};
// use std::path::Path;
#[derive(Serialize, Deserialize)]
struct Item<'a> {
id: i64,
val: &'a str,
}
fn main() -> io::Result<()> {
let reader = BufReader::new(io::stdin());
let mut writer = BufWriter::new(io::stdout());
for lines in reader.lines().chunks(6).into_iter() {
for (i, line) in lines.enumerate() {
let l_ = format!("\tLine {}\n", i);
writer.write(l_.as_bytes()).unwrap();
if let Ok(mut line) = line {
line.push('\n');
writer.write(line.as_bytes()).unwrap();
}
}
}
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment