about summary refs log tree commit diff
path: root/library/core/src/char/convert.rs
AgeCommit message (Collapse)AuthorLines
2025-09-01Constify conversion traitsltdk-9/+19
2025-08-26remove deprecated Error::description in implsMarijn Schouten-11/+6
2025-07-21Constify Try, From, TryFromEvgenii Zheltonozhskii-5/+10
2025-05-21Add some track_caller info to precondition panicsBen Kimock-0/+1
2025-05-12update cfg(bootstrap)Pietro Albini-2/+2
2025-04-24Suggest {to,from}_ne_bytes for transmutations between arrays and integers, etcbendn-0/+2
2025-03-06library: Use size_of from the prelude instead of importedThalia Archibald-12/+4
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. These functions were added to all preludes in Rust 1.80.
2024-09-08add FIXME(const-hack)Ralf Jung-1/+1
2024-03-25Import the 2021 prelude in the core crateDaniel Paoliello-1/+0
2024-03-23move assert_unsafe_preconditions to its own fileRalf Jung-1/+1
These macros and functions are not intrinsics, after all.
2024-03-08Distinguish between library and lang UB in assert_unsafe_preconditionBen Kimock-0/+1
2024-02-08Rewrite assert_unsafe_precondition around the new intrinsicBen Kimock-1/+1
2023-12-15Use assert_unsafe_precondition for char::from_u32_uncheckedChris Denton-1/+8
Co-Authored-By: joboet <jonasboettiger@icloud.com>
2023-10-03Bump version placeholdersMark Rousskov-1/+1
2023-07-25`impl TryFrom<char> for u16`Lukas Markeffsky-2/+36
2023-04-16rm const traits in libcoreDeadbeef-8/+4
2023-02-10Remove a couple of `#[doc(hidden)] pub fn` and their `#[feature]` gatesTobias Bucher-15/+13
2022-09-29Split out from_u32_unchecked from const_char_convertest31-1/+0
It relies on the Option::unwrap function which is not const-stable (yet).
2022-07-05Fix links in std/core documentationGuillaume Gomez-2/+2
2022-04-01Avoid duplication of doc comments in `std::char` constants and functions.Eduardo Sánchez Muñoz-132/+7
For those consts and functions, only the summary is kept and a reference to the `char` associated const/method is included. Additionaly, re-exported functions have been converted to function definitions that call the previously re-exported function. This makes it easier to add a deprecated attribute to these functions in the future.
2022-03-07Add missing documentation for std::char typesGuillaume Gomez-1/+6
2022-02-17fixMario Carneiro-2/+0
2022-02-17Optimize char_try_from_u32Mario Carneiro-1/+14
The optimization was proposed by @falk-hueffner in https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Micro-optimizing.20char.3A.3Afrom_u32/near/272146171, and I simplified it a bit and added an explanation of why the optimization is correct.
2022-01-07Implement `TryFrom<char>` for `u8`Ian Douglas Scott-0/+15
Previously suggested in https://github.com/rust-lang/rfcs/issues/2854. It makes sense to have this since `char` implements `From<u8>`. Likewise `u32`, `u64`, and `u128` (since #79502) implement `From<char>`.
2021-11-19Rollup merge of #89258 - est31:const_char_convert, r=oli-obkYuki Okushi-10/+22
Make char conversion functions unstably const The char conversion functions like `char::from_u32` do trivial computations and can easily be converted into const fns. Only smaller tricks are needed to avoid non-const standard library functions like `Result::ok` or `bool::then_some`. Tracking issue: https://github.com/rust-lang/rust/issues/89259
2021-10-18Make more `From` impls `const`woppopo-4/+8
2021-10-16Make char conversion functions unstably constest31-10/+22
2021-10-10Add #[must_use] to from_value conversionsJohn Kugelman-0/+3
2021-01-10Rollup merge of #79502 - Julian-Wollersberger:from_char_for_u64, r=withoutboatsYuki Okushi-0/+42
Implement From<char> for u64 and u128. With this PR you can write ``` let u = u64::from('👤'); let u = u128::from('👤'); ``` Previously, you could already write `as` conversions ([Playground link](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=cee18febe28e69024357d099f07ca081)): ``` // Lossless conversions dbg!('👤' as u32); // Prints 128100 dbg!('👤' as u64); // Prints 128100 dbg!('👤' as u128); // Prints 128100 // truncates, thus no `From` impls. dbg!('👤' as u8); // Prints 100 dbg!('👤' as u16); // Prints 62564 // These `From` impls already exist. dbg!(u32::from('👤')); // Prints 128100 dbg!(u64::from(u32::from('👤'))); // Prints 128100 ``` The idea is from ``@gendx`` who opened [this Internals thread](https://internals.rust-lang.org/t/implement-from-char-for-u64/13454), and ``@withoutboats`` responded that someone should open a PR for it. Some people mentioned `From<char>` impls for `f32` and `f64`, but that doesn't seem correct to me, so I didn't include them here. I don't know what the feature should be named. Must it be registered somewhere, like unstable features? r? ``@withoutboats``
2021-01-09Update the stabilisation version.Julian Wollersberger-2/+2
2020-12-28Add "chr" as doc alias to char::from_u32Konrad Borowski-0/+1
2020-11-28Implement From<char> for u64 and u128.Julian Wollersberger-0/+42
2020-08-15Link to primitive instead of moduleDenis Vasilik-6/+0
2020-08-15Use intra-doc linksDenis Vasilik-8/+4
2020-07-27mv std libs to library/mark-0/+300