Skip to content
Snippets Groups Projects
  1. Dec 16, 2021
  2. Apr 30, 2021
  3. Mar 08, 2021
  4. Mar 04, 2021
  5. Feb 08, 2021
    • Simon Sapin's avatar
    • Simon Sapin's avatar
      Added tag 0.2.0 for changeset 97f9e3197c68 · ed6db4d2
      Simon Sapin authored
      ed6db4d2
    • Simon Sapin's avatar
      Require `&mut _` output stream type for the write_bytes! macro · 97f9e319
      Simon Sapin authored
      # Background
      
      Because it’s a macro that can expand to multiple "write" calls,
      `write_bytes!` assigns the output stream parameter expression to an internal
      binding in order to avoid evaluating multiple times an expression that could
      have side-effects.
      
      To avoid taking ownership of the stream away from the caller,
      before this change it took a `&mut $expression` borrow and assigned that.
      However when the expression is another local binding, that required
      the binding to be `mut` even if it already had a `&mut _` type
      as is typically the case inside implementations of the `DisplayBytes` trait.
      
      This caused signatures that look redundant, using the `mut` keyword twice:
      `mut out: &mut dyn Write`.
      
      # Change
      
      `write_bytes!` now requires the output stream expression to already be a
      `&mut _` borrow, and assigns that to an internal binding.
      
      This is less flexible for callers (and therefore a breaking change) but
      matches how functions and methods work (auto-ref applies to recievers of
      method calls but not other arguments), and allows `DisplayBytes` impls
      to have the less redundant `out: &mut dyn Write` signature.
    • Simon Sapin's avatar
      Add a doctest with an impl of DisplayBytes that uses write_bytes! · 73817b61
      Simon Sapin authored
      write_bytes currently requires the local binding for the output stream
      to be `mut`, even if it has type `&mut _`
      73817b61
  6. Feb 06, 2021
  7. Feb 05, 2021
  8. Feb 04, 2021
  9. Nov 26, 2020
  10. Jan 19, 2021
    • Simon Sapin's avatar
      Generalize the format_bytes! macro and add write_bytes! · 5710ae1a
      Simon Sapin authored
      `format_bytes!` now accepts any argument that implements `DisplayBytes`,
      not just byte strings.
      
      `write_bytes!` is to `format_bytes!` what the standard library’s
      `write!` is to `format!`: it can write to any stream
      given as an additional first argument.
      5710ae1a
  11. Jan 20, 2021
  12. Jan 19, 2021
  13. Nov 19, 2020
  14. Jun 23, 2020
Loading