Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #![allow(unused_variables)]
  2.  
  3. use std::io;
  4. use std::io::BufRead;
  5.  
  6. use failure::*;
  7. use failure::Error;
  8. use failure::err_msg;
  9.  
  10. fn my_function() -> Result<(), Error> {
  11. let stdin = io::stdin();
  12.  
  13. for line in stdin.lock().lines() {
  14. let line = line?;
  15.  
  16. if line.chars().all(|c| c.is_whitespace()) {
  17. break
  18. }
  19.  
  20. if !line.starts_with("$") {
  21. return Err(format_err!("Input did not begin with `$`"));
  22. }
  23.  
  24. println!("{}", &line[1..]);
  25. }
  26.  
  27. Ok(())
  28. }
  29.  
  30. fn main() -> Result<(), Error> {
  31. my_function()?
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement