SHARE
TWEET

Untitled

a guest Aug 20th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. struct Parsed<'a> {
  2.     parts: Vec<&'a str>,
  3. }
  4.  
  5. impl<'a> Parsed<'a> {
  6.     fn parse(s: &'a str) -> Self {
  7.         let parts = s.split_whitespace().collect();
  8.         Parsed { parts }
  9.     }
  10.  
  11.     fn len(&self) -> usize {
  12.         self.parts.len()
  13.     }
  14.  
  15.     fn parsed_len(s: &str) -> usize {
  16.         Self::parse(s).len()
  17.     }
  18. }
  19.  
  20. fn process<F: Fn(&str) -> usize>(f: F) {
  21.     //unimplemented!()
  22. }
  23.  
  24. fn main() {
  25.     process(Parsed::parsed_len)
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top