summary refs log tree commit diff
path: root/src/libstd/any.rs
AgeCommit message (Collapse)AuthorLines
2014-03-04Cleaned up `std::any`Marvin Löbel-117/+39
- Added `TraitObject` representation to `std::raw`. - Added doc to `std::raw`. - Removed `Any::as_void_ptr()` and `Any::as_mut_void_ptr()` methods as they are uneccessary now after the removal of headers on owned boxes. This reduces the number of virtual calls needed. - Made the `..Ext` implementations work directly with the repr of a trait object. - Removed `Any`-related traits from the prelude. - Added bench for `Any`
2014-02-28std: Change assert_eq!() to use {} instead of {:?}Alex Crichton-1/+1
Formatting via reflection has been a little questionable for some time now, and it's a little unfortunate that one of the standard macros will silently use reflection when you weren't expecting it. This adds small bits of code bloat to libraries, as well as not always being necessary. In light of this information, this commit switches assert_eq!() to using {} in the error message instead of {:?}. In updating existing code, there were a few error cases that I encountered: * It's impossible to define Show for [T, ..N]. I think DST will alleviate this because we can define Show for [T]. * A few types here and there just needed a #[deriving(Show)] * Type parameters needed a Show bound, I often moved this to `assert!(a == b)` * `Path` doesn't implement `Show`, so assert_eq!() cannot be used on two paths. I don't think this is much of a regression though because {:?} on paths looks awful (it's a byte array). Concretely speaking, this shaved 10K off a 656K binary. Not a lot, but sometime significant for smaller binaries.
2014-02-23Remove all ToStr impls, add Show implsAlex Crichton-9/+0
This commit changes the ToStr trait to: impl<T: fmt::Show> ToStr for T { fn to_str(&self) -> ~str { format!("{}", *self) } } The ToStr trait has been on the chopping block for quite awhile now, and this is the final nail in its coffin. The trait and the corresponding method are not being removed as part of this commit, but rather any implementations of the `ToStr` trait are being forbidden because of the generic impl. The new way to get the `to_str()` method to work is to implement `fmt::Show`. Formatting into a `&mut Writer` (as `format!` does) is much more efficient than `ToStr` when building up large strings. The `ToStr` trait forces many intermediate allocations to be made while the `fmt::Show` trait allows incremental buildup in the same heap allocated buffer. Additionally, the `fmt::Show` trait is much more extensible in terms of interoperation with other `Writer` instances and in more situations. By design the `ToStr` trait requires at least one allocation whereas the `fmt::Show` trait does not require any allocations. Closes #8242 Closes #9806
2014-02-23std: Move intrinsics to std::intrinsics.Brian Anderson-2/+2
Issue #1457
2014-02-13Add some missing Show implementations in libstdBrendan Zabarauskas-0/+26
2014-02-11Move replace and swap to std::mem. Get rid of std::utilEdward Wang-1/+3
Also move Void to std::any, move drop to std::mem and reexport in prelude.
2014-02-07Removed @self and @Trait.Eduard Burtescu-26/+0
2014-01-31Fix minor doc typosVirgile Andreani-2/+2
2013-12-27std: uniform modules titles for docLuca Bruno-0/+2
This commit uniforms the short title of modules provided by libstd, in order to make their roles more explicit when glancing at the index. Signed-off-by: Luca Bruno <lucab@debian.org>
2013-12-24std: Get stdtest all passing againAlex Crichton-5/+10
This commit brings the library up-to-date in order to get all tests passing again
2013-12-24std: Change Any::move to never consume the objectAlex Crichton-9/+10
If the dynamic cast fails, this now returns the ~Any instance back to the caller.
2013-12-11Make 'self lifetime illegal.Erik Price-9/+9
Also remove all instances of 'self within the codebase. This fixes #10889.
2013-12-09auto merge of #10840 : cmr/rust/any_docs2, r=huonwbors-1/+8
2013-12-09Add some Any docs.Corey Richardson-1/+8
2013-12-06Made Results API more composableMarvin Löbel-1/+0
2013-12-03Register new snapshotsAlex Crichton-39/+0
2013-11-30Wrap the return value of the type_id intrinsic in an opaque boxCorey Richardson-23/+8
Closes #10594
2013-11-11Fix path parsingSeo Sanghyeon-1/+1
2013-11-08Implement IterBytes for TypeIdTomas Sedovic-0/+15
2013-11-06Register new snapshotsAlex Crichton-15/+0
2013-11-01Remove unnecessary unwind messagesAlex Crichton-3/+4
Now that the type_id intrinsic is working across crates, all of these unnecessary messages can be removed to have the failure type for a task truly be ~Any and only ~Any
2013-11-01Add a type_id intrinsicAlex Crichton-17/+42
Closes #9913
2013-10-28Allow fail messages to be caught, and introduce the Any traitMarvin Löbel-0/+418
Some code cleanup, sorting of import blocks Removed std::unstable::UnsafeArc's use of Either Added run-fail tests for the new FailWithCause impls Changed future_result and try to return Result<(), ~Any>. - Internally, there is an enum of possible fail messages passend around. - In case of linked failure or a string message, the ~Any gets lazyly allocated in future_results recv method. - For that, future result now returns a wrapper around a Port. - Moved and renamed task::TaskResult into rt::task::UnwindResult and made it an internal enum. - Introduced a replacement typedef `type TaskResult = Result<(), ~Any>`.