about summary refs log tree commit diff
path: root/library/core
AgeCommit message (Collapse)AuthorLines
2023-09-28fixup! isqrt: fix stabilityFederico Stra-6/+6
2023-09-28isqrt: cite source and rename variables to match original C codeFederico Stra-11/+16
2023-09-28isqrt: fix stabilityFederico Stra-6/+11
2023-09-28fixup! isqrt: initial implementationFederico Stra-4/+4
Fix C-ism and type inference.
2023-09-28Rollup merge of #115888 - RalfJung:assert_receiver_is_total_eq, r=dtolnayMatthias Krüger-3/+3
fix a comment about assert_receiver_is_total_eq "a type implements #[deriving]" doesn't make any sense, so I assume they meant "implement `Eq`"? Also the attribute is called `derive`.
2023-09-28Rollup merge of #112959 - tbu-:pr_fmt_error_wording, r=dtolnayMatthias Krüger-2/+2
Change the wording in `std::fmt::Write::write_str` Refer to the error instead of expanding its name.
2023-09-28stabilize `Option::as_`(`mut_`)`slice`Andre Bogus-12/+2
2023-09-28changed 'rotate' to 'rotating'Anshul-1/+1
2023-09-27Fix "unresolved link to std::fmt::Error" David Tolnay-1/+1
error: unresolved link to `std::fmt::Error` --> library/core/src/fmt/mod.rs:115:52 | 115 | /// This function will return an instance of [`std::fmt::Error`] on error. | | = note: `-D rustdoc::broken-intra-doc-links` implied by `-D warnings`
2023-09-26take more clarifying text from Gankra's PRRalf Jung-0/+14
original source: https://github.com/rust-lang/rust/pull/95851
2023-09-26isqrt: add more testsFederico Stra-0/+32
2023-09-26isqrt: remove duplication by delegating to unsigned integersFederico Stra-40/+12
2023-09-26Auto merge of #116125 - RalfJung:const-param-ty-eq, r=compiler-errorsbors-1/+6
ConstParamTy: require Eq as supertrait As discussed with `@BoxyUwu` [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/.60ConstParamTy.60.20and.20.60Eq.60). We want to say that valtree equality on const generic params agrees with `==`, but that only makes sense if `==` actually exists, hence we should have an appropriate bound. Valtree equality is an equivalence relation, so such a type can always be `Eq` and not just `PartialEq`.
2023-09-25Auto merge of #116074 - fzs111:clarify-pin-docs, r=Mark-Simulacrumbors-1/+4
Clarify example in `Pin::new_unchecked` docs This example in the docs of `Pin::new_unchecked` puzzled me for a relatively long time. Now I understand that it comes down to the difference between dropping the `Pin` vs dropping the pinned value. I have extended the explanation to highlight this difference. In my opinion it is clearer now, and I hope it helps others understand `Pin` better.
2023-09-24ConstParamTy: require EqRalf Jung-1/+6
2023-09-24Auto merge of #116075 - Colonial-Dev:issue-116063-fix, r=Mark-Simulacrumbors-0/+16
Document panics on unsigned wrapping_div/rem calls (#116063) Add missing `# Panics` sections to the `uint_impl!` macro, documenting that the `wrapping_rem/div` calls will panic if passed zero.
2023-09-23Add the `cfg_match!` macroCaio-0/+245
2023-09-23Clarify example in `Pin::new_unchecked` docsFZs-1/+4
2023-09-22Extend fix to wrapping_div, wrapping_div_euclid and wrapping_rem_euclidJames Haywood-0/+12
2023-09-22Resolve rust-lang/rust#116063James Haywood-0/+4
2023-09-22isqrt: add testsFederico Stra-0/+21
2023-09-22isqrt: initial implementationFederico Stra-0/+115
2023-09-22checked_ilog: remove duplication by delegating to unsigned integersFederico Stra-22/+3
2023-09-22checked_ilog: add benchmarksFederico Stra-6/+73
2023-09-22checked_ilog: add comments explaining the correctness of the 128 bit ↵Federico Stra-0/+16
optimization
2023-09-22checked_ilog: set `n` and `r` directly avoiding arithmetic operationsFederico Stra-6/+4
2023-09-22checked_ilog: improve performanceFederico Stra-8/+8
2023-09-22Auto merge of #114776 - fee1-dead-contrib:enable-effects-in-libcore, r=oli-obkbors-4/+5
Enable effects for libcore ~~r? `@oli-obk~~` forgot you are on vacation, oops
2023-09-21Rollup merge of #116007 - m-ou-se:const-panic-fmt-panic-display, r=oli-obkGuillaume Gomez-1/+2
Call panic_display directly in const_panic_fmt. `panic_str` just directly calls `panic_display`. The only reason `panic_str` exists, is for a lint to detect an expansion of `panic_2015!(expr)` (which expands to `panic_str`). It is `panic_display` that is hooked by const-eval, which is the reason we call it here. Part of https://github.com/rust-lang/rust/issues/116005 r? ``@oli-obk``
2023-09-21avoid talking about inversesRalf Jung-10/+14
2023-09-21consistent wordingRalf Jung-4/+4
2023-09-21documentation tweaksRalf Jung-12/+12
2023-09-21offset_from: docs improvementsRalf Jung-4/+20
2023-09-21Rollup merge of #116008 - m-ou-se:boxmeup, r=oli-obkMatthias Krüger-2/+2
Rename BoxMeUp to PanicPayload. "BoxMeUp" is not very clear. Let's rename that to a description of what it actually represents: a panic payload. This PR also renames the structs that implement this trait to have more descriptive names. Part of https://github.com/rust-lang/rust/issues/116005 r? `@oli-obk`
2023-09-20Fix typo.Mara Bos-1/+1
2023-09-20Rename BoxMeUp to PanicPayload.Mara Bos-2/+2
2023-09-20Call panic_display directly in const_panic_fmt.Mara Bos-1/+2
2023-09-20fix rustdoc testsDeadbeef-1/+1
2023-09-20Enable effects for libcoreDeadbeef-5/+6
2023-09-20Auto merge of #114443 - tgross35:cstr-len, r=dtolnaybors-34/+72
Implement `cstr_count_bytes` This has not yet been approved via ACP, but it's simple enough to get started on. - ACP: https://github.com/rust-lang/libs-team/issues/256 - Tracking issue: https://github.com/rust-lang/rust/issues/114441 `@rustbot` label +T-libs-api
2023-09-19explain mysterious addition in float minimum/maximumRalf Jung-0/+2
2023-09-18Stabilize `{IpAddr, Ipv6Addr}::to_canonical`Trevor Gross-10/+13
Make `IpAddr::to_canonical` and `IpV6Addr::to_canonical` stable, as well as const stabilize `Ipv6Addr::to_ipv4_mapped`. Newly stable API: impl IpAddr { // Now stable under `ip_to_canonical` const fn to_canonical(&self) -> IpAddr; } impl Ipv6Addr { // Now stable under `ip_to_canonical` const fn to_canonical(&self) -> IpAddr; // Already stable, this makes it const stable under // `const_ipv6_to_ipv4_mapped` const fn to_ipv4_mapped(&self) -> Option<Ipv4Addr> } These stabilize a subset of the following tracking issues: - https://github.com/rust-lang/rust/issues/27709 - https://github.com/rust-lang/rust/issues/76205
2023-09-18Rollup merge of #115494 - RalfJung:primitive_docs, r=Mark-SimulacrumMatthias Krüger-23/+11
get rid of duplicate primitive_docs Having this duplicate makes editing that file very annoying. And at least locally the generated docs still look perfectly fine...
2023-09-18Rollup merge of #109409 - WaffleLapkin:progamer, r=dtolnayMatthias Krüger-0/+85
Add `minmax{,_by,_by_key}` functions to `core::cmp` This PR adds the following functions: ```rust // mod core::cmp #![unstable(feature = "cmp_minmax")] pub fn minmax<T>(v1: T, v2: T) -> [T; 2] where T: Ord; pub fn minmax_by<T, F>(v1: T, v2: T, compare: F) -> [T; 2] where F: FnOnce(&T, &T) -> Ordering; pub fn minmax_by_key<T, F, K>(v1: T, v2: T, mut f: F) -> [T; 2] where F: FnMut(&T) -> K, K: Ord; ``` (they are also `const` under `#[feature(const_cmp)]`, I've omitted `const` stuff for simplicity/readability) ---- Semantically these functions are equivalent to `{ let mut arr = [v1, v2]; arr.sort(); arr }`, but since they operate on 2 elements only, they are implemented as a single comparison. Even though that's basically a sort, I think "sort 2 elements" operation is useful on it's own in many cases. Namely, it's a common pattern when you have 2 things, and need to know which one is smaller/bigger to operate on them differently. I've wanted such functions countless times, most recently in #109402, so I thought I'd propose them. ---- r? libs-api
2023-09-18Fill-in tracking issue for `feature(cmp_minmax)`Maybe Waffle-3/+3
2023-09-18Add `minmax*` functions to `core::cmp`Maybe Waffle-0/+85
2023-09-18get rid of duplicate primitive_docsRalf Jung-23/+11
2023-09-18Auto merge of #108043 - a1phyr:string_write_fmt, r=workingjubileebors-2/+22
Small wins for formatting-related code This PR does two small wins in fmt code: - Override `write_char` for `PadAdapter` to use inner buffer's `write_char` - Override some `write_fmt` implementations to avoid avoid the additional indirection and vtable generated by the default impl.
2023-09-18Auto merge of #115547 - WaffleLapkin:spin_looping, r=Mark-Simulacrumbors-24/+17
Simplify `core::hint::spin_loop` The grouping was inconsistent and not really helpful. r? t-libs
2023-09-17Specialize `fmt::Write::write_fmt` for `Sized` typesBenoît du Garreau-2/+22