diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-12-15 20:19:53 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-15 20:19:53 +0100 |
| commit | ea6daca3cbe57459291f327ab14223202c0e65d9 (patch) | |
| tree | e32267b968d7084c2e21570565eba8bd2a6afd6f /tests/codegen/src-hash-algorithm/src-hash-algorithm-sha1.rs | |
| parent | 8ad8f29ae0cc512018249f93d2c3e40ea410f2ec (diff) | |
| parent | b225aab5ef00820375b29089d39aa283eaf90ef8 (diff) | |
| download | rust-ea6daca3cbe57459291f327ab14223202c0e65d9.tar.gz rust-ea6daca3cbe57459291f327ab14223202c0e65d9.zip | |
Rollup merge of #118234 - tgross35:type_name_of_value, r=dtolnay
Stabilize `type_name_of_val`
Make the following API stable:
```rust
// in core::any
pub fn type_name_of_val<T: ?Sized>(_val: &T) -> &'static str
```
This is a convenience method to get the type name of a value, as opposed to `type_name` that takes a type as a generic.
Const stability is not added because this relies on `type_name` which is also not const. That has a blocking issue https://github.com/rust-lang/rust/issues/97156.
Wording was also changed to direct most of the details to `type_name` so we don't have as much duplicated documentation.
Fixes tracking issue #66359.
There were two main concerns in the tracking issue:
1. Naming: `type_name_of` and `type_name_of_val` seem like the only mentioned options. Differences in opinion here come from `std::mem::{size_of, align_of, size_of_val, align_of_val}`. This PR leaves the name as `type_name_of_val`, but I can change if desired since it is pretty verbose.
2. What this displays for `&dyn`: I don't think that having `type_name_of_val` function resolve those is worth the headache it would be, see https://github.com/rust-lang/rust/issues/66359#issuecomment-1718480774 for some workarounds. I also amended the docs wording to leave it open-ended, in case we have means to change that behavior in the future.
``@rustbot`` label -T-libs +T-libs-api +needs-fcp
r? libs-api
Diffstat (limited to 'tests/codegen/src-hash-algorithm/src-hash-algorithm-sha1.rs')
0 files changed, 0 insertions, 0 deletions
