Skip to content
  • наб's avatar
    Accept an Into<Cow<str>> in parse_from_rfc2822_with_fallback() · 52ceaa38
    наб authored
    This means you'll always get the most optimal amount of allocations,
    since you won't re-allocate `s`.
    
    Let's look through a couple cases as an illustration:
      1. dt: &str   = valid date => no String allocations
      2. dt: String = valid date => no String allocations, dt moved out of
      3. dt: &str   = invalid date => 1 String allocation + the ones from
                                      sanitize_rfc822_like_date()
      4. dt: String = invalid date => 0 String allocations + the ones from
                                      sanitize_rfc822_like_date(),
                                      dt moved out of
    
    In short, we've reduced the required amount of allocations to the
    minimum
    
    Thanks, Shepmaster
      https://chat.stackoverflow.com/transcript/62927?m=39498746#39498746
    52ceaa38