message: Reduce allocations in `Headers::try_from`
diff: @@ -162,9 +162,11 @@ impl TryFrom<&[u8]> for Headers {
  };
  while let Some(line) = lines.next() {
  - let splits = line.splitn(2, ':').map(str::trim).collect::<Vec<_>>();
  - match splits[..] {
  - [k, v] => {
  + if line.is_empty() {
  + continue;
  + }
  +
  + if let Some((k, v)) = line.split_once(':') {
  let entry = inner.entry(k.to_string()).or_insert_with(HashSet::default);
  let mut s = String::from(v.trim());
  @@ -174,11 +176,8 @@ impl TryFrom<&[u8]> for Headers {
  }
  entry.insert(s);
  - }
  - [""] => continue,
  - _ => {
  - return parse_error("malformed header input");
  - }
  + } else {
  + return parse_error("malformed header line");
  }
  }
  @@ -264,6 +263,35 @@ mod try_from {
  );
  }
  + #[test]
  + fn malformed_line() {
  + let error = Headers::try_from("NATS/1.0 200\r\n\nX-Test-A a\r\n".as_bytes()).unwrap_err();
  + assert_eq!(error.kind(), std::io::ErrorKind::InvalidInput);
  + }
  +
  + #[test]
  + fn empty_lines() {
  + let headers = Headers::try_from(
  + "NATS/1.0 200\r\n\nX-Test-A: a\r\n\nX-Test-B: b\r\n\nX-Test-C: c\r\n\n".as_bytes(),
  + )
  + .unwrap();
  +
  + assert_eq!(
  + headers.inner.get(&"X-Test-A".to_string()),
  + Some(&HashSet::from_iter(vec!["a".to_string()]))
  + );
  +
  + assert_eq!(
  + headers.inner.get(&"X-Test-B".to_string()),
  + Some(&HashSet::from_iter(vec!["b".to_string()]))
  + );
  +
  + assert_eq!(
  + headers.inner.get(&"X-Test-C".to_string()),
  + Some(&HashSet::from_iter(vec!["c".to_string()]))
  + );
  + }
  +
  #[test]
  fn single_line() {
  let headers = Headers::try_from(
  