summary refs log tree commit diff
path: root/src/libcore/any.rs
AgeCommit message (Collapse)AuthorLines
2018-07-25Enforce #![deny(bare_trait_objects)] in src/libcoreljedrz-8/+8
2018-07-03Any docs preposition changeEthan McCue-1/+1
This changes the docs referring to where a user should be wary of depending on "Any" trait impls from warning about relying on them "outside" of their code to warning about relying on them "inside" of their code.
2018-05-31Fix up Any doc examplesJeremy Fitzhardinge-3/+3
Make the Any+Send+Sync examples use the right trait bounds, and fix a small whitespace issue.
2018-05-31Add implementations for Any + Send + SyncJeremy Fitzhardinge-0/+90
Implement `is`, `downcast_ref`, `downcast_mut` and `Debug` for `Any + Send + Sync`.
2018-02-20stage0 cfg cleanupMark Simulacrum-26/+0
2018-02-01Turn `type_id` into a constant intrinsicBadel2-0/+27
Add rustc_const_unstable attribute for `any::TypeId::of` Add test for `const fn TypeId::of`
2017-03-22Various fixes to wording consistency in the docsStjepan Glavina-1/+1
2017-02-14Auto merge of #38981 - sdleffler:patch-1, r=alexcrichtonbors-1/+5
Add PartialOrd, Ord derivations to TypeId I want to be able to sort a `Vec` of types which contain `TypeId`s, so an `Ord` derivation would be very useful to me. `Hash` and `PartialEq`/`Eq` already exist, so the missing `PartialOrd` and `Ord` derivations feel like an oversight to me.
2017-01-17Add warning about varying hashes/orderingsSean Leffler-0/+4
2017-01-13Change `to_owned` to `to_string` in docsStjepan Glavina-8/+8
We should teach conversion from `str` to `String` using `to_string` rather than the legacy `to_owned`.
2017-01-10Add PartialOrd, Ord derivations to TypeIdSean Leffler-1/+1
I want to be able to sort a `Vec` of types which contain `TypeId`s, so an `Ord` derivation would be very useful to me. `Hash` already exists, so the missing `PartialOrd` and `Ord` derivations feel like an oversight to me.
2016-10-17Add stable example to TypeIdJethro Beekman-4/+2
2016-10-12Deprecate `Reflect`Nick Cameron-4/+3
[tracking issue](https://github.com/rust-lang/rust/issues/27749)
2016-08-26Replace unnecessary uses of `TraitObject` with castsAndrew Paseltiner-12/+2
2016-08-24Use `#[prelude_import]` in `libcore`.Jeffrey Seyfried-3/+1
2016-07-10Improve std::any module docGuillaume Gomez-2/+158
2016-06-07docs: simplify wordingAleksey Kladov-1/+1
2016-03-08doc: Fix a bunch of broken linksAlex Crichton-1/+1
A few categories: * Links into compiler docs were just all removed as we're not generating compiler docs. * Move up one more level to forcibly go to std docs to fix inlined documentation across the facade crates.
2016-01-14Implement Any for unsized typesSteven Fackler-1/+1
This is a bit weird since unsized types can't be used in trait objects, but Any is *also* used as pure marker trait since Reflect isn't stable. There are many cases (e.g. TypeMap) where all you need is a TypeId.
2015-12-11Correct reference to `Box<Any>` in `Any` docsJake Goulding-3/+4
2015-11-18Add missing annotations and some testsVadim Petrochenkov-0/+1
2015-08-26Any docs: as_ref doesn't exist anymoreSteve Klabnik-5/+6
Fixes #27958
2015-08-15core: Fill out issues for unstable featuresAlex Crichton-1/+2
2015-08-09Replace many uses of `mem::transmute` with more specific functionsTobias Bucher-2/+2
The replacements are functions that usually use a single `mem::transmute` in their body and restrict input and output via more concrete types than `T` and `U`. Worth noting are the `transmute` functions for slices and the `from_utf8*` family for mutable slices. Additionally, `mem::transmute` was often used for casting raw pointers, when you can already cast raw pointers just fine with `as`.
2015-07-02Auto merge of #26725 - tshepang:patch-2, r=blussbors-1/+1
2015-07-01doc: add missing spaceTshepang Lekhonkhobe-1/+1
2015-07-01doc: there is just one trait in hereTshepang Lekhonkhobe-2/+0
Also, the info is repeated in the following paragraph
2015-06-17core: Split apart the global `core` featureAlex Crichton-1/+1
This commit shards the broad `core` feature of the libcore library into finer grained features. This split groups together similar APIs and enables tracking each API separately, giving a better sense of where each feature is within the stabilization process. A few minor APIs were deprecated along the way: * Iterator::reverse_in_place * marker::NoCopy
2015-04-30Add downcasting to std::error::ErrorAaron Turon-4/+2
This commit brings the `Error` trait in line with the [Error interoperation RFC](https://github.com/rust-lang/rfcs/pull/201) by adding downcasting, which has long been intended. This change means that for any `Error` trait objects that are `'static`, you can downcast to concrete error types. To make this work, it is necessary for `Error` to inherit from `Reflect` (which is currently used to mark concrete types as "permitted for reflection, aka downcasting"). This is a breaking change: it means that impls like ```rust impl<T> Error for MyErrorType<T> { ... } ``` must change to something like ```rust impl<T: Reflect> Error for MyErrorType<T> { ... } ``` except that `Reflect` is currently unstable (and should remain so for the time being). For now, code can instead bound by `Any`: ```rust impl<T: Any> Error for MyErrorType<T> { ... } ``` which *is* stable and has `Reflect` as a super trait. The downside is that this imposes a `'static` constraint, but that only constrains *when* `Error` is implemented -- it does not actually constrain the types that can implement `Error`. [breaking-change]
2015-04-13pluralize doc comment verbs and add missing periodsAndrew Paseltiner-1/+1
2015-04-09Ensure that .join().unwrap() worksAaron Turon-0/+10
Makes `Any + Send` implement `Debug`. Fixes #21291
2015-04-06Fix broken link and markup in `trait Any` docs.Matt Brubeck-2/+3
2015-04-01Fallout in libstd: remove impls now considered to conflict.Niko Matsakis-0/+8
2015-03-30std: Stabilize the rest of Any/BoxAnyAlex Crichton-2/+1
This commit stabilizes the following APIs: * `TypeId::of` - now that it has an `Any` bound it's ready to be stable. * `Box<Any>::downcast` - now that an inherent impl on `Box<Any>` as well as `Box<Any+Send>` is allowed the `BoxAny` trait is removed in favor of these inherent methods. This is a breaking change due to the removal of the `BoxAny` trait, but consumers can simply remove imports to fix crates. [breaking-change]
2015-03-26Implement `Reflect` trait with a variant on the standard OIBITNiko Matsakis-11/+13
semantics that tests the *interface* of trait objects, rather than what they close over.
2015-03-24Clean up Any's title lineSteve Klabnik-4/+4
http://www.reddit.com/r/rust/comments/304q00/type_information_in_rust/cpp43lu
2015-03-18Register new snapshotsAlex Crichton-1/+0
2015-03-17Remove subtyping for object types and replace with an *upcast* coercion.Niko Matsakis-0/+26
This upcast coercion currently preserves the vtable for the object, but eventually it can be used to create a derived vtable. The upcast coercion is not introduced into method dispatch; see comment on #18737 for information about why. Fixes #18737.
2015-02-08Rename Show to Debug, String to DisplayAlexander Korolkov-1/+1
Update reference.md: - derive() no longer supports Zero trait - derive() now supports Copy trait
2015-01-29s/Show/Debug/gJorge Aparicio-1/+1
2015-01-29register snaphotsJorge Aparicio-1/+0
2015-01-25Merge remote-tracking branch 'rust-lang/master'Brian Anderson-12/+5
Conflicts: mk/tests.mk src/liballoc/arc.rs src/liballoc/boxed.rs src/liballoc/rc.rs src/libcollections/bit.rs src/libcollections/btree/map.rs src/libcollections/btree/set.rs src/libcollections/dlist.rs src/libcollections/ring_buf.rs src/libcollections/slice.rs src/libcollections/str.rs src/libcollections/string.rs src/libcollections/vec.rs src/libcollections/vec_map.rs src/libcore/any.rs src/libcore/array.rs src/libcore/borrow.rs src/libcore/error.rs src/libcore/fmt/mod.rs src/libcore/iter.rs src/libcore/marker.rs src/libcore/ops.rs src/libcore/result.rs src/libcore/slice.rs src/libcore/str/mod.rs src/libregex/lib.rs src/libregex/re.rs src/librustc/lint/builtin.rs src/libstd/collections/hash/map.rs src/libstd/collections/hash/set.rs src/libstd/sync/mpsc/mod.rs src/libstd/sync/mutex.rs src/libstd/sync/poison.rs src/libstd/sync/rwlock.rs src/libsyntax/feature_gate.rs src/libsyntax/test.rs
2015-01-23grandfathered -> rust1Brian Anderson-6/+6
2015-01-23Set unstable feature names appropriatelyBrian Anderson-2/+2
* `core` - for the core crate * `hash` - hashing * `io` - io * `path` - path * `alloc` - alloc crate * `rand` - rand crate * `collections` - collections crate * `std_misc` - other parts of std * `test` - test crate * `rustc_private` - everything else
2015-01-21Remove 'since' from unstable attributesBrian Anderson-2/+2
2015-01-21Add 'feature' and 'since' to stability attributesBrian Anderson-8/+10
2015-01-21Test fixes and rebase conflictsAlex Crichton-8/+1
2015-01-20std: Rename Show/String to Debug/DisplayAlex Crichton-4/+4
This commit is an implementation of [RFC 565][rfc] which is a stabilization of the `std::fmt` module and the implementations of various formatting traits. Specifically, the following changes were performed: [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0565-show-string-guidelines.md * The `Show` trait is now deprecated, it was renamed to `Debug` * The `String` trait is now deprecated, it was renamed to `Display` * Many `Debug` and `Display` implementations were audited in accordance with the RFC and audited implementations now have the `#[stable]` attribute * Integers and floats no longer print a suffix * Smart pointers no longer print details that they are a smart pointer * Paths with `Debug` are now quoted and escape characters * The `unwrap` methods on `Result` now require `Display` instead of `Debug` * The `Error` trait no longer has a `detail` method and now requires that `Display` must be implemented. With the loss of `String`, this has moved into libcore. * `impl<E: Error> FromError<E> for Box<Error>` now exists * `derive(Show)` has been renamed to `derive(Debug)`. This is not currently warned about due to warnings being emitted on stage1+ While backwards compatibility is attempted to be maintained with a blanket implementation of `Display` for the old `String` trait (and the same for `Show`/`Debug`) this is still a breaking change due to primitives no longer implementing `String` as well as modifications such as `unwrap` and the `Error` trait. Most code is fairly straightforward to update with a rename or tweaks of method calls. [breaking-change] Closes #21436
2015-01-18std: Stabilize TypeId and tweak BoxAnyAlex Crichton-9/+45
This commit aims to stabilize the `TypeId` abstraction by moving it out of the `intrinsics` module into the `any` module of the standard library. Specifically, * `TypeId` is now defined at `std::any::TypeId` * `TypeId::hash` has been removed in favor of an implementation of `Hash`. This commit also performs a final pass over the `any` module, confirming the following: * `Any::get_type_id` remains unstable as *usage* of the `Any` trait will likely never require this, and the `Any` trait does not need to be implemented for any other types. As a result, this implementation detail can remain unstable until associated statics are implemented. * `Any::downcast_ref` is now stable * `Any::downcast_mut` is now stable * `BoxAny` remains unstable. While a direct impl on `Box<Any>` is allowed today it does not allow downcasting of trait objects like `Box<Any + Send>` (those returned from `Thread::join`). This is covered by #18737. * `BoxAny::downcast` is now stable.
2015-01-08Improvements to feature stagingBrian Anderson-1/+1
This gets rid of the 'experimental' level, removes the non-staged_api case (i.e. stability levels for out-of-tree crates), and lets the staged_api attributes use 'unstable' and 'deprecated' lints. This makes the transition period to the full feature staging design a bit nicer.