Skip to content

Commit

Permalink
Merge pull request #45 from h-mikisato/feature/surpress_warning
Browse files Browse the repository at this point in the history
surpress warnings when specifying `--loop` and `--loop --count`
  • Loading branch information
fornwall authored Feb 12, 2022
2 parents 6c358af + 2a53928 commit 582e1ec
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ Regarding the loop templates: what I *want* is for the result of the closure to

/// The template used for `--loop` input, assuming no `--count` flag is also given.
pub const LOOP_TEMPLATE: &str = r#"
#![allow(unused_imports)]
#![allow(unused_braces)]
#{prelude}
use std::any::Any;
use std::io::prelude::*;
Expand All @@ -65,15 +67,15 @@ fn main() {
{#{script}}
);
let mut line_buffer = String::new();
let mut stdin = std::io::stdin();
let stdin = std::io::stdin();
loop {
line_buffer.clear();
let read_res = stdin.read_line(&mut line_buffer).unwrap_or(0);
if read_res == 0 { break }
let output = closure(&line_buffer);
let display = {
let output_any: &Any = &output;
let output_any: &dyn Any = &output;
!output_any.is::<()>()
};
Expand All @@ -91,6 +93,8 @@ where F: FnMut(&str) -> T, T: 'static {

/// The template used for `--count --loop` input.
pub const LOOP_COUNT_TEMPLATE: &str = r#"
#![allow(unused_imports)]
#![allow(unused_braces)]
use std::any::Any;
use std::io::prelude::*;
Expand All @@ -99,7 +103,7 @@ fn main() {
{#{script}}
);
let mut line_buffer = String::new();
let mut stdin = std::io::stdin();
let stdin = std::io::stdin();
let mut count = 0;
loop {
line_buffer.clear();
Expand All @@ -109,7 +113,7 @@ fn main() {
let output = closure(&line_buffer, count);
let display = {
let output_any: &Any = &output;
let output_any: &dyn Any = &output;
!output_any.is::<()>()
};
Expand Down

0 comments on commit 582e1ec

Please sign in to comment.