Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![allow(unused_variables)]
- use std::io;
- use std::io::BufRead;
- use failure::*;
- use failure::Error;
- use failure::err_msg;
- fn my_function() -> Result<(), Error> {
- let stdin = io::stdin();
- for line in stdin.lock().lines() {
- let line = line?;
- if line.chars().all(|c| c.is_whitespace()) {
- break
- }
- if !line.starts_with("$") {
- return Err(format_err!("Input did not begin with `$`"));
- }
- println!("{}", &line[1..]);
- }
- Ok(())
- }
- fn main() -> Result<(), Error> {
- my_function()?
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement