about summary refs log tree commit diff
path: root/src/liballoc/rc.rs
AgeCommit message (Collapse)AuthorLines
2015-01-05Remove i suffix in docsSteve Klabnik-27/+27
2015-01-05Stabilization of impls and fallout from stabilizationAaron Turon-3/+3
2015-01-03sed -i -s 's/\bmod,/self,/g' **/*.rsJorge Aparicio-4/+4
2015-01-02core: use assoc types in `Deref[Mut]`Jorge Aparicio-1/+3
2015-01-01Reviewer changeNick Cameron-5/+1
2015-01-01Add some impls of Show (RefCell, Weak, some resolve types)Nick Cameron-0/+11
2014-12-30Stabilize cmpAaron Turon-4/+4
This patch marks `PartialEq`, `Eq`, `PartialOrd`, and `Ord` as `#[stable]`, as well as the majorify of manual implementaitons of these traits. The traits match the [reform RFC](https://github.com/rust-lang/rfcs/pull/439). Along the way, two changes are made: * The recently-added type parameters for `Ord` and `Eq` are removed. These were mistakenly added while adding them to `PartialOrd` and `PartialEq`, but they don't make sense given the laws that are required for (and use cases for) `Ord` and `Eq`. * More explicit laws are added for `PartialEq` and `PartialOrd`, connecting them to their associated mathematical concepts. In the future, many of the impls should be generalized; see since generalizing later is not a breaking change. [breaking-change]
2014-12-29rollup merge of #20248: steveklabnik/gh20038Alex Crichton-1/+1
A part of #20038 This is just the beginning of what needs to be done, but it's some of it. /cc @aturon
2014-12-29std: Second pass stabilization for `ptr`Alex Crichton-1/+1
This commit performs a second pass for stabilization over the `std::ptr` module. The specific actions taken were: * The `RawPtr` trait was renamed to `PtrExt` * The `RawMutPtr` trait was renamed to `MutPtrExt` * The module name `ptr` is now stable. * These functions were all marked `#[stable]` with no modification: * `null` * `null_mut` * `swap` * `replace` * `read` * `write` * `PtrExt::is_null` * `PtrExt::offset` * These functions remain unstable: * `as_ref`, `as_mut` - the return value of an `Option` is not fully expressive as null isn't the only bad value, and it's unclear whether we want to commit to these functions at this time. The reference/lifetime semantics as written are also problematic in how they encourage arbitrary lifetimes. * `zero_memory` - This function is currently not used at all in the distribution, and in general it plays a broader role in the "working with unsafe pointers" story. This story is not yet fully developed, so at this time the function remains unstable for now. * `read_and_zero` - This function remains unstable for largely the same reasons as `zero_memory`. * These functions are now all deprecated: * `PtrExt::null` - call `ptr::null` or `ptr::null_mut` instead. * `PtrExt::to_uint` - use an `as` expression instead. * `PtrExt::is_not_null` - use `!p.is_null()` instead.
2014-12-28Don't expose NonZero through libstd.Luqman Aden-1/+2
2014-12-28libcore: Make it unsafe to create NonZero and impl Deref.Luqman Aden-21/+8
2014-12-28liballoc: Use NonZero in Rc.Luqman Aden-15/+29
2014-12-26s/task/thread/gSteve Klabnik-1/+1
A part of #20038
2014-12-21rollup merge of #20070: aturon/stab-2-cloneAlex Crichton-1/+1
This patch marks `clone` stable, as well as the `Clone` trait, but leaves `clone_from` unstable. The latter will be decided by the beta. The patch also marks most manual implementations of `Clone` as stable, except where the APIs are otherwise deprecated or where there is uncertainty about providing `Clone`. r? @alexcrichton
2014-12-21rollup merge of #19944: steveklabnik/doc_sync_arcAlex Crichton-17/+14
Take the docs from Rc<T>, apply them to Arc<T>, and fix some line lengths.
2014-12-20Stabilize cloneAaron Turon-1/+1
This patch marks `clone` stable, as well as the `Clone` trait, but leaves `clone_from` unstable. The latter will be decided by the beta. The patch also marks most manual implementations of `Clone` as stable, except where the APIs are otherwise deprecated or where there is uncertainty about providing `Clone`.
2014-12-17rollup merge of #19902: alexcrichton/second-pass-memAlex Crichton-0/+1
This commit stabilizes the `mem` and `default` modules of std.
2014-12-16Improve Arc<T> documentation, and Rc<T> docs a bitSteve Klabnik-17/+14
Take the docs from Rc<T>, apply them to Arc<T>, and fix some line lengths.
2014-12-15Move hash module from collections to coreSteven Fackler-0/+9
2014-12-15std: Second pass stabilization of `default`Alex Crichton-0/+1
This commit performs a second pass stabilization of the `std::default` module. The module was already marked `#[stable]`, and the inheritance of `#[stable]` was removed since this attribute was applied. This commit adds the `#[stable]` attribute to the trait definition and one method name, along with all implementations found in the standard distribution.
2014-12-08Implemented BorrowFrom<Rc<T>> for T.Aaron Weiss-0/+7
2014-12-05Utilize fewer reexportsCorey Farwell-4/+7
In regards to: https://github.com/rust-lang/rust/issues/19253#issuecomment-64836729 This commit: * Changes the #deriving code so that it generates code that utilizes fewer reexports (in particur Option::* and Result::*), which is necessary to remove those reexports in the future * Changes other areas of the codebase so that fewer reexports are utilized
2014-11-25Document liballoc::rcSteve Klabnik-57/+296
This commit introduces a bunch of documentation, fixes some consistency issues, and just basically brings Rc<T> and Weak<T> up to snuff.
2014-11-21Shuffle locations for DerefAlexander Light-41/+27
Remove both `strong_count` and `weak_count` from `Weak`s and make the methods bare functions so as not to cause trouble with `deref`.
2014-11-21Add `weak_count` and `strong_count` to Rc and ArcAlexander Light-2/+59
These functions allow you to see how many weak and strong references there are to an `Arc`, `Rc`, or an `rc::Weak`. Due to the design of `Arc` it is not possible to get the number of weak references of an arbitrary `arc::Weak`. Look in `arc.rs` for a more in-depth explanation. On `arc::Arc` and `arc::Weak` these operations are wait-free and atomic.
2014-11-14libs: fix #[stable] inheritance falloutAaron Turon-3/+1
A recent change turned off inheritance for the #[stable] by default, but failed to catch all the cases where this was being used in std. This patch fixes that problem.
2014-10-02tests: remove uses of Gc.Eduard Burtescu-8/+0
2014-08-19A few minor documentation fixesP1start-148/+148
2014-08-07Rename `Share` to `Sync`Alex Crichton-7/+7
This leaves the `Share` trait at `std::kinds` via a `#[deprecated]` `pub use` statement, but the `NoShare` struct is no longer part of `std::kinds::marker` due to #12660 (the build cannot bootstrap otherwise). All code referencing the `Share` trait should now reference the `Sync` trait, and all code referencing the `NoShare` type should now reference the `NoSync` type. The functionality and meaning of this trait have not changed, only the naming. Closes #16281 [breaking-change]
2014-08-01Add is_unique(), try_unwrap(), get_mut() to alloc::rcKevin Ballard-9/+116
Add a few new free functions to alloc::rc for manipulating uniquely-owned Rc values. is_unique() can be used to test if the Rc is uniquely-owned, try_unwrap() can remove the value from a uniquely-owned Rc, and get_mut() can return a &mut for a uniquely-owned Rc. These are all free functions, because smart pointers should avoid having methods when possible. They can't be static methods because UFCS will remove that distinction. I think we should probably change downgrade() and make_unique() into free functions as well, but that's out of scope.
2014-07-31alloc, arena, test, url, uuid: Elide lifetimes.OGINO Masanori-5/+5
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-07-26std: Stabilize unit, bool, ty, tuple, arc, anyAlex Crichton-1/+0
This commit applies stability attributes to the contents of these modules, summarized here: * The `unit` and `bool` modules have become #[unstable] as they are purely meant for documentation purposes and are candidates for removal. * The `ty` module has been deprecated, and the inner `Unsafe` type has been renamed to `UnsafeCell` and moved to the `cell` module. The `marker1` field has been removed as the compiler now always infers `UnsafeCell` to be invariant. The `new` method i stable, but the `value` field, `get` and `unwrap` methods are all unstable. * The `tuple` module has its name as stable, the naming of the `TupleN` traits as stable while the methods are all #[unstable]. The other impls in the module have appropriate stability for the corresponding trait. * The `arc` module has received the exact same treatment as the `rc` module previously did. * The `any` module has its name as stable. The `Any` trait is also stable, with a new private supertrait which now contains the `get_type_id` method. This is to make the method a private implementation detail rather than a public-facing detail. The two extension traits in the module are marked #[unstable] as they will not be necessary with DST. The `is` method is #[stable], the as_{mut,ref} methods have been renamed to downcast_{mut,ref} and are #[unstable]. The extension trait `BoxAny` has been clarified as to why it is unstable as it will not be necessary with DST. This is a breaking change because the `marker1` field was removed from the `UnsafeCell` type. To deal with this change, you can simply delete the field and only specify the value of the `data` field in static initializers. [breaking-change]
2014-07-18alloc: Stabilize rc module.Brian Anderson-1/+18
Weak pointers experimental. Most everything else stable.
2014-07-01Improve rustdocs for Rc, add examplesAlisdair Owens-9/+134
2014-06-30auto merge of #15030 : sfackler/rust/partial-cmp, r=huonwbors-0/+5
I ended up altering the semantics of Json's PartialOrd implementation. It used to be the case that Null < Null, but I can't think of any reason for an ordering other than the default one so I just switched it over to using the derived implementation. This also fixes broken `PartialOrd` implementations for `Vec` and `TreeMap`. # Note This isn't ready to merge yet since libcore tests are broken as you end up with 2 versions of `Option`. The rest should be reviewable though. RFC: 0028-partial-cmp
2014-06-29Implement RFC#28: Add PartialOrd::partial_cmpSteven Fackler-0/+5
I ended up altering the semantics of Json's PartialOrd implementation. It used to be the case that Null < Null, but I can't think of any reason for an ordering other than the default one so I just switched it over to using the derived implementation. This also fixes broken `PartialOrd` implementations for `Vec` and `TreeMap`. RFC: 0028-partial-cmp
2014-06-29alloc: impl Default for RcErick Tryzelaar-0/+8
2014-06-24core: Add stability attributes to CloneBrian Anderson-0/+2
The following are tagged 'unstable' - core::clone - Clone - Clone::clone - impl Clone for Arc - impl Clone for arc::Weak - impl Clone for Rc - impl Clone for rc::Weak - impl Clone for Vec - impl Clone for Cell - impl Clone for RefCell - impl Clone for small tuples The following are tagged 'experimental' - Clone::clone_from - may not provide enough utility - impls for various extern "Rust" fns - may not handle lifetimes correctly See https://github.com/rust-lang/rust/wiki/Meeting-API-review-2014-06-23#clone
2014-06-24librustc: Remove the fallback to `int` from typechecking.Niko Matsakis-7/+7
This breaks a fair amount of code. The typical patterns are: * `for _ in range(0, 10)`: change to `for _ in range(0u, 10)`; * `println!("{}", 3)`: change to `println!("{}", 3i)`; * `[1, 2, 3].len()`: change to `[1i, 2, 3].len()`. RFC #30. Closes #6023. [breaking-change]
2014-06-11rustc: Move the AST from @T to Gc<T>Alex Crichton-1/+1
2014-06-11rustc: Update how Gc<T> is recognizedAlex Crichton-2/+2
This commit uses the same trick as ~/Box to map Gc<T> to @T internally inside the compiler. This moves a number of implementations of traits to the `gc` module in the standard library. This removes functions such as `Gc::new`, `Gc::borrow`, and `Gc::ptr_eq` in favor of the more modern equivalents, `box(GC)`, `Deref`, and pointer equality. The Gc pointer itself should be much more useful now, and subsequent commits will move the compiler away from @T towards Gc<T> [breaking-change]
2014-06-02Adding show impl for Rcfort-0/+7
2014-06-01std: Drop Total from Total{Eq,Ord}Alex Crichton-3/+3
This completes the last stage of the renaming of the comparison hierarchy of traits. This change renames TotalEq to Eq and TotalOrd to Ord. In the future the new Eq/Ord will be filled out with their appropriate methods, but for now this change is purely a renaming change. [breaking-change]
2014-05-30std: Rename {Eq,Ord} to Partial{Eq,Ord}Alex Crichton-3/+3
This is part of the ongoing renaming of the equality traits. See #12517 for more details. All code using Eq/Ord will temporarily need to move to Partial{Eq,Ord} or the Total{Eq,Ord} traits. The Total traits will soon be renamed to {Eq,Ord}. cc #12517 [breaking-change]
2014-05-29Make Arc::make_unique check weak refs; add make_unique to RcAaron Turon-0/+88
This patch makes `Arc::make_unique` examine the number of weak references as well as strong references, which is required for safety. It also adds a `make_unique` method to the `Rc` type for consistency. Closes #14521.
2014-05-25Paper over privacy issues with Deref by changing field names.Huon Wilson-21/+25
Types that implement Deref can cause weird error messages due to their private fields conflicting with a field of the type they deref to, e.g., previously struct Foo { x: int } let a: Arc<Foo> = ...; println!("{}", a.x); would complain the the `x` field of `Arc` was private (since Arc has a private field called `x`) rather than just ignoring it. This patch doesn't fix that issue, but does mean one would have to write `a._ptr` to hit the same error message, which seems far less common. (This patch `_`-prefixes all private fields of `Deref`-implementing types.) cc #12808
2014-05-17std: Refactor liballoc out of lib{std,sync}Alex Crichton-0/+303
This commit is part of the libstd facade RFC, issue #13851. This creates a new library, liballoc, which is intended to be the core allocation library for all of Rust. It is pinned on the basic assumption that an allocation failure is an abort or failure. This module has inherited the heap/libc_heap modules from std::rt, the owned/rc modules from std, and the arc module from libsync. These three pointers are currently the three most core pointer implementations in Rust. The UnsafeArc type in std::sync should be considered deprecated and replaced by Arc<Unsafe<T>>. This commit does not currently migrate to this type, but future commits will continue this refactoring.