title: How to implement Borrow<T> when T wraps borrowed data?
body: <p>Given the following definitions from <a href="https://stackoverflow.com/questions/52733047/how-to-borrow-a-field-for-serialization-but-create-it-during-deserialization">How to borrow a field for serialization but create it during deserialization?</a>:</p>
  <pre><code>#[derive(Serialize)]
  struct SerializeThing&lt;'a&gt; {
      small_header: (u64, u64, u64),
      big_body: &amp;'a str,
  }
  
  #[derive(Deserialize)]
  struct DeserializeThing {
      small_header: (u64, u64, u64),
      big_body: String,
  }
  </code></pre>
  <p>How do I implement the <code>Borrow</code> trait so as to store the owned data naturally in (e.g.) HashMaps and query them by either them or by their borrowed counterparts? The closest thing that appears possible is as follows:</p>
  <pre><code>impl DeserializeThing {
      fn as_serialize(&amp;self) -&gt; SerializeThing&lt;'_&gt; {
          let DeserializeThing { small_header, big_body } = self;
          let small_header = *small_header;
          let big_body = big_body.as_str();
          SerializeThing { small_header, big_body }
      }
  }
  </code></pre>
  <p>which is not quite sufficient.</p>