Skip to content

Commit

Permalink
Fix wrong size_of info in the docs (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
Veetaha authored Sep 10, 2024
1 parent 3bf514a commit 3217b4b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion website/guide/patterns/into-conversions-in-depth.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ Before we enabled `Into` conversions the signature provided a hint for the compi

However, after we enabled `Into` conversions, the signature no longer provides a single concrete type. It says that it accepts an `Option` of any type that implements `Into<String>`.

It means that the `None` literal could be of types `Option<&str>` or `Option<String>`, for example, so the compiler can't decide which one you meant. And this matters, because `Option<&str>` and `Option<String>` are totally different types. Simplified, `Option<&str>` is 8 bytes in size and `Option<String>` is 24 bytes, even when they are `None`.
It means that the `None` literal could be of types `Option<&str>` or `Option<String>`, for example, so the compiler can't decide which one you meant. And this matters, because `Option<&str>` and `Option<String>` are totally different types. Simplified, `Option<&str>` is 16 bytes in size and `Option<String>` is 24 bytes, even when they are `None`.

To work around this problem the caller would need to explicitly specify the generic parameter for the `Option` type when passing the `None` literal:

Expand Down

0 comments on commit 3217b4b

Please sign in to comment.