about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2020-05-14Rollup merge of #71909 - Dolpheyn:doc-from-trait-for-option, r=steveklabnikRalf Jung-0/+45
Document From trait for Option implementations Add documentation for ```From``` trait for ```std::option::Option``` implementations This PR solves a part of #51430 ( CC @skade ) This is my first PR ever in contributing for OSS. I'm happy to learn and make any changes if necessary :)
2020-05-14Rollup merge of #71870 - ltratt:more_specific_type_name_doc, r=kennytmRalf Jung-7/+9
Be slightly more precise about any::type_name()'s guarantees. The first commit in this PR rephrases the current documentation for `any::type_name()` to be a little more specific about the guarantees (or lack thereof) that this function makes. The second commit explicitly documents that lifetimes are currently not included in the output (since this bit me particularly hard recently).
2020-05-13Update src/libcore/option.rsFaris Sufyan-0/+2
Co-authored-by: Steve Klabnik <steve@steveklabnik.com>
2020-05-13Update src/libcore/option.rsFaris Sufyan-0/+1
Co-authored-by: Steve Klabnik <steve@steveklabnik.com>
2020-05-13Update src/libcore/option.rsFaris Sufyan-1/+1
Co-authored-by: Steve Klabnik <steve@steveklabnik.com>
2020-05-13Update src/libcore/option.rsFaris Sufyan-0/+1
Co-authored-by: Steve Klabnik <steve@steveklabnik.com>
2020-05-13Update src/libcore/option.rsFaris Sufyan-0/+1
Co-authored-by: Steve Klabnik <steve@steveklabnik.com>
2020-05-13Update src/libcore/option.rsFaris Sufyan-1/+1
Co-authored-by: Steve Klabnik <steve@steveklabnik.com>
2020-05-13Update src/libcore/option.rsFaris Sufyan-0/+1
Co-authored-by: Steve Klabnik <steve@steveklabnik.com>
2020-05-13Update src/libcore/option.rsFaris Sufyan-1/+1
Co-authored-by: Steve Klabnik <steve@steveklabnik.com>
2020-05-12Map to -> return.Laurence Tratt-1/+1
2020-05-10Fix link to `map` documentation in exampleFaris Sufyan-1/+1
Co-authored-by: Timo <timorcb@gmail.com>
2020-05-10doc: minus (U+2212) instead of dash (U+002D) for negative infinityTrevor Spiteri-2/+2
2020-05-09Rollup merge of #70834 - yoshuawuyts:future-pending-ready, r=sfacklerDylan DPC-0/+110
Add core::future::{pending,ready} Adds two future constructors to `core`: `future::ready` and `future::pending`. These functions enable constructing futures of any type that either immediately resolve, or never resolve which is an incredible useful tool when writing documentation. These functions have prior art in both the `futures` and `async-std` crates. This implementation has been adapted from the `futures` crate. ## Examples In https://github.com/rust-lang/rust/pull/70817 we propose adding the `ready!` macro. In the example we use an `async fn` which does not return a future that implements `Unpin`, which leads to the use of `unsafe`. Instead had we had `future::ready` available, we could've written the same example without using `unsafe`: ```rust use core::task::{Context, Poll}; use core::future::{self, Future}; use core::pin::Pin; pub fn do_poll(cx: &mut Context<'_>) -> Poll<()> { let mut fut = future::ready(42_u8); let num = ready!(Pin::new(fut).poll(cx)); // ... use num Poll::Ready(()) } ``` ## Why future::ready? Arguably `future::ready` and `async {}` can be considered equivalent. The main differences are that `future::ready` returns a future that implements `Unpin`, and the returned future is a concrete type. This is useful for traits that require a future as an associated type that can sometimes be a no-op ([example](https://docs.rs/http-service/0.4.0/http_service/trait.HttpService.html#associatedtype.ConnectionFuture)). The final, minor argument is that `future::ready` and `future::pending` form a counterpart to the enum members of `Poll`: `Ready` and `Pending`. These functions form a conceptual bridge between `Poll` and `Future`, and can be used as a useful teaching device. ## References - [`futures::future::ready`](https://docs.rs/futures/0.3.4/futures/future/fn.ready.html) - [`futures::future::pending`](https://docs.rs/futures/0.3.4/futures/future/fn.pending.html) - [`async_std::future::pending`](https://docs.rs/async-std/1.5.0/async_std/future/fn.pending.html) - [`async_std::future::ready`](https://docs.rs/async-std/1.5.0/async_std/future/fn.ready.html)
2020-05-07Add core::future::{pending,ready}Yoshua Wuyts-0/+110
2020-05-07rewrite Drop documentationBastian Kauschke-44/+98
2020-05-06Rollup merge of #71944 - ldm0:arrordhint, r=sfacklerDylan DPC-0/+1
Add comment for `Ord` implementation for array Corresponding to `Ord` implementation for slice. It hints new comer the rule of comparing two arrays.
2020-05-06Add comment for `Ord` implementation for arrayDonough Liu-0/+1
2020-05-05Fix exampleDolpheyn-1/+1
2020-05-05Fix comment positionDolpheyn-1/+1
2020-05-05Rollup merge of #71845 - steveklabnik:add-const-examples, r=dtolnayDylan DPC-2/+318
Add const examples I only added them to `std::f32` to get feedback on this approach before adding the other constants. When looking at https://github.com/rust-lang/rust/pull/68952, I found the docs a little confusing. Unless you're intimately aware of what's going on here, I don't think it's super clear what is deprecated and what you're supposed to do instead. I think short examples really clarify what's meant here, so that's what I did.
2020-05-05Document From trait for Option implementationsDolpheyn-0/+39
2020-05-04Rollup merge of #71877 - steveklabnik:small-example-fix, r=Mark-SimulacrumDylan DPC-2/+2
Use f64 in f64 examples I believe that this is a copy/paste error; this example was using f32, but it's the docs for f64.
2020-05-04Fix typo.Laurence Tratt-2/+2
2020-05-04Use f64 in f64 examplesSteve Klabnik-2/+2
I believe that this is a copy/paste error; this example was using f32, but it's the docs for f64.
2020-05-04Add examples to int macrosSteve Klabnik-2/+24
2020-05-04f64 examplesSteve Klabnik-0/+147
2020-05-04correct -> intendedSteve Klabnik-14/+14
2020-05-04add some whitespaceSteve Klabnik-0/+7
2020-05-04Add examples for std::f32 constants.Steve Klabnik-0/+140
And also point people to use the associated constants of f32 instead.
2020-05-04Document that lifetimes do not currently appear in any::type_name()'s output.Laurence Tratt-1/+3
2020-05-04Rephrase the any::type_name docs a bit.Laurence Tratt-7/+7
This attempts to be a little clearer (including in terminology) about the lack of guarantees that any::type_name provides.
2020-05-03Rollup merge of #71398 - ThinkChaos:feat_refcell_take, r=LukasKalbertodtDylan DPC-0/+25
Add `RefCell::take` Add `RefCell::take` to match `Cell` and `Option`. I also changed a couple of calls to `.replace` to `.take`. Tracking issue is #71395. This is my first contribution, please tell me if there's anything I could improve, thanks!
2020-05-03Mention `RefCell::take` can panic in docsThinkChaos-0/+4
2020-05-02slice::fill: take T by value.Bastian Kauschke-6/+7
2020-05-01Document unsafety for `*const T` and `*mut T`LeSeulArtichaut-4/+8
2020-04-30Rollup merge of #71597 - CohenArthur:refactor-unique-empty, r=shepmasterDylan DPC-2/+1
Rename Unique::empty() -> Unique::dangling() A `FIXME` comment in `src/libcore/ptr/unique.rs` suggested refactoring `Unique::empty()` to `Unique::dangling()` which this PR does.
2020-04-30Rollup merge of #71692 - dfreese:cfgdocs, r=kennytmDylan DPC-0/+4
Add clarification on std::cfg macro docs v. #[cfg] attribute The wording was discussed, to a limited degree in #71679. This tries to address some confusion I as well as someone else had independently when looking at this macro. Fixes #71679
2020-04-30Rollup merge of #71672 - lcnr:instrinsics-wow, r=Dylan-DPCDylan DPC-12/+86
document missing stable counterparts of intrinsics Notes the stable counterpart of each intrinsic in case one exists. Implements #34338 r? @Dylan-DPC
2020-04-30rename-unique: Rename Unique::empty() to Unique::dangling()cohenarthur-2/+1
rename-unique: Change calls and doc in raw_vec.rs rename-unique: Change empty() -> dangling() in const-ptr-unique-rpass.rs
2020-04-29Update src/libcore/macros/mod.rsDavid Freese-1/+1
Co-Authored-By: kennytm <kennytm@gmail.com>
2020-04-29Add clarification on std::cfg macro docs v. #[cfg] attributeDavid Freese-0/+4
The wording was discussed, to a limited degree in #71679. This tries to address some confusion I as well as someone else had independently when looking at this macro. Fixes #71679
2020-04-29Rollup merge of #71680 - nicholasbishop:bishop-fix-eq-link, r=Mark-SimulacrumDylan DPC-0/+1
Fix doc link to Eq trait from PartialEq trait The `Eq` link was incorrectly going to the `eq` method of `PartialEq` instead of to the `Eq` trait.
2020-04-29Rollup merge of #71507 - CohenArthur:document-unsafe-libcore-ptr, ↵Dylan DPC-7/+45
r=Mark-Simulacrum Document unsafety in core::ptr Contributes to #66219 I have yet to document all the `unsafe` blocks in the lib and would like to know if I'm headed in the right direction r? @steveklabnik
2020-04-29Fix doc link to Eq trait from PartialEq traitNicholas Bishop-0/+1
The `Eq` link was incorrectly going to the `eq` method of `PartialEq` instead of to the `Eq` trait.
2020-04-29document stable counterparts of intrinsicsBastian Kauschke-12/+86
2020-04-29safety-ptr: Add SAFETY on some unsafe blocks from libcore/ptrcohenarthur-3/+43
Add documentation example to slice_from_raw_parts_mut() Add SAFETY explanations to some unsafe blocks in libcore/ptr * libcore/ptr/mod.rs * libcore/ptr/unique.rs * libcore/ptr/non_null.rs safety-mod.rs: Add SAFETY to slice_from_raw_parts(), slice_from_raw_parts_mut() slice_from_raw_parts_mut: Add documentation example safety-ptr-unique.rs: Add SAFETY to new() and cast() safety-ptr-non_null.rs: Add SAFETY to new() safety-ptr-non_null.rs: Add SAFETY to cast() safety-ptr-non_null.rs: Add SAFETY to from() impls safety-ptr-unique.rs: Add SAFETY to from() impls safety-ptr-non_null.rs: Add SAFETY to new() safety-ptr-unique.rs: Add SAFETY to new() safety-ptr-mod.rs: Fix safety explanation https://github.com/rust-lang/rust/pull/71507#discussion_r414488884 safety-prt-non_null.rs: Fix SAFETY comment syntax safety-ptr-unique.rs: Fix syntax for empty() safety-ptr-non_null.rs: Fix misuse of non-null for align_of() safety-ptr-non_null.rs: Remove incorrect SAFETY comment safety-ptr-unique.rs: Remove unsound SAFETY comment safety-ptr-mod.rs: Add std comment on slice_from_raw_parts guarantee safety-ptr-unique.rs: Remove incorrect safety comment Creating a Unique from a NonNull has strict guarantees that the current implementation does not guarantee https://github.com/rust-lang/rust/pull/71507#discussion_r415035952 safety-ptr: Re-adding ignore-tidy directive
2020-04-27Update link to unstable book for llvm_asm macroZach Reizner-1/+1
2020-04-27Rollup merge of #71589 - RalfJung:unique-no-shr, r=SimonSapinDylan DPC-17/+0
remove Unique::from for shared pointer types r? @SimonSapin
2020-04-26remove Unique::from for shared pointer typesRalf Jung-17/+0