Skip to content

Commit 582e1ec

Browse files
authored
Merge pull request #45 from h-mikisato/feature/surpress_warning
surpress warnings when specifying `--loop` and `--loop --count`
2 parents 6c358af + 2a53928 commit 582e1ec

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/consts.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ Regarding the loop templates: what I *want* is for the result of the closure to
5656

5757
/// The template used for `--loop` input, assuming no `--count` flag is also given.
5858
pub const LOOP_TEMPLATE: &str = r#"
59+
#![allow(unused_imports)]
60+
#![allow(unused_braces)]
5961
#{prelude}
6062
use std::any::Any;
6163
use std::io::prelude::*;
@@ -65,15 +67,15 @@ fn main() {
6567
{#{script}}
6668
);
6769
let mut line_buffer = String::new();
68-
let mut stdin = std::io::stdin();
70+
let stdin = std::io::stdin();
6971
loop {
7072
line_buffer.clear();
7173
let read_res = stdin.read_line(&mut line_buffer).unwrap_or(0);
7274
if read_res == 0 { break }
7375
let output = closure(&line_buffer);
7476
7577
let display = {
76-
let output_any: &Any = &output;
78+
let output_any: &dyn Any = &output;
7779
!output_any.is::<()>()
7880
};
7981
@@ -91,6 +93,8 @@ where F: FnMut(&str) -> T, T: 'static {
9193

9294
/// The template used for `--count --loop` input.
9395
pub const LOOP_COUNT_TEMPLATE: &str = r#"
96+
#![allow(unused_imports)]
97+
#![allow(unused_braces)]
9498
use std::any::Any;
9599
use std::io::prelude::*;
96100
@@ -99,7 +103,7 @@ fn main() {
99103
{#{script}}
100104
);
101105
let mut line_buffer = String::new();
102-
let mut stdin = std::io::stdin();
106+
let stdin = std::io::stdin();
103107
let mut count = 0;
104108
loop {
105109
line_buffer.clear();
@@ -109,7 +113,7 @@ fn main() {
109113
let output = closure(&line_buffer, count);
110114
111115
let display = {
112-
let output_any: &Any = &output;
116+
let output_any: &dyn Any = &output;
113117
!output_any.is::<()>()
114118
};
115119

0 commit comments

Comments
 (0)