about summary refs log tree commit diff
path: root/src/libcore/cell.rs
AgeCommit message (Collapse)AuthorLines
2015-06-17Fallout in tests and docs from feature renamingsAlex Crichton-1/+1
2015-06-17core: Split apart the global `core` featureAlex Crichton-22/+28
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-06-04Doc-comment fix; trait names are capitalizedCorey Farwell-2/+2
2015-06-02Auto merge of #25867 - petrochenkov:ucellv, r=alexcrichtonbors-1/+8
Now when const functions are implemented and used, the `value` field of `UnsafeCell` can be made deprecated (and then private as intended).
2015-05-30Deprecate UnsafeCell::valuepetrochenkov-1/+8
2015-05-29Auto merge of #25747 - SimonSapin:map_ref, r=alexcrichtonbors-4/+152
For slightly complex data structures like `rustc_serialize::json::Json`, it is often convenient to have helper methods like `Json::as_string(&self) -> Option<&str>` that return a borrow of some component of `&self`. However, when `RefCell`s are involved, keeping a `Ref` around is required to hold a borrow to the insides of a `RefCell`. But `Ref` so far only references the entirety of the contents of a `RefCell`, not a component. But there is no reason it couldn’t: `Ref` internally contains just a data reference and a borrow count reference. The two can be dissociated. This adds a `map_ref` function that creates a new `Ref` for some other data, but borrowing the same `RefCell` as an existing `Ref`. Example: ```rust struct RefCellJson(RefCell<Json>); impl RefCellJson { fn as_string(&self) -> Option<Ref<str>> { map_ref(self.borrow(), |j| j.as_string()) } } ``` r? @alexcrichton
2015-05-29Add map and filter_map associated functions to std::cell::Ref and RefMutSimon Sapin-1/+132
See design discussion in https://github.com/rust-lang/rust/pull/25747
2015-05-28Auto merge of #25744 - SimonSapin:cell-eq, r=alexcrichtonbors-2/+8
`core::cell::Cell<T>` and `core::cell::RefCell<T>` currently implement `PartialEq` when `T` does, and just defer to comparing `T` values. There is no reason the same shouldn’t apply to `Eq`. This enables `#[derive(Eq, PartialEq)]` on e.g. structs that have a `RefCell` field. r? @alexcrichton I’m unsure what to do with `#[stable]` attributes on `impl`s. `impl`s generated by `#[derive]` don’t have them.
2015-05-28Move std::cell::clone_ref to a clone associated function on std::cell::RefSimon Sapin-3/+20
... and generalize the bounds on the value type.
2015-05-28Rollup merge of #25726 - nham:cell_docs, r=alexcrichtonManish Goregaokar-4/+4
Currently part of the description of the `into_inner` method of `UnsafeCell` seems backwards.
2015-05-27Use `const fn` to abstract away the contents of UnsafeCell & friends.Eduard Burtescu-3/+3
2015-05-24Implement Eq for Cell and RefCell.Simon Sapin-2/+8
`core::cell::Cell<T>` and `core::cell::RefCell<T>` currently implement `PartialEq` when `T` does, and just defer to comparing `T` values. There is no reason the same shouldn’t apply to `Eq`. This enables `#[derive(Eq, PartialEq)]` on e.g. structs that have a `RefCell` field.
2015-05-22docs: Improve descriptions for some methods in core::cell.Nick Hamann-4/+4
2015-05-13RebasingNick Cameron-1/+0
2015-05-09Convert #[lang="..."] to #[lang = "..."]Nick Hamann-1/+1
In my opinion this looks nicer, but also it matches the whitespace generally used for stability markers more closely.
2015-05-09Please the `make tidy`Barosl Lee-1/+2
2015-05-09Squeeze the last bits of `task`s in documentation in favor of `thread`Barosl Lee-2/+2
An automated script was run against the `.rs` and `.md` files, subsituting every occurrence of `task` with `thread`. In the `.rs` files, only the texts in the comment blocks were affected.
2015-05-02Make `UnsafeCell`, `RefCell`, `Mutex`, and `RwLock` accept DSTsP1start-27/+32
This + DST coercions (#24619) would allow code like `Rc<RefCell<Box<Trait>>>` to be simplified to `Rc<RefCell<Trait>>`.
2015-04-28Register new snapshotsTamir Duberstein-2/+0
2015-04-26IMO better borrow_mut() documentation on RefCellgareins-1/+1
Previous borrow() is enough to make borrow_mut() panic, no need to have borrow_mut() twice. [This](http://is.gd/woKKAW)
2015-04-13pluralize doc comment verbs and add missing periodsAndrew Paseltiner-5/+5
2015-04-01fallout from feature-gating unary negation on unsigned integers.Felix S. Klock II-1/+1
2015-03-31std: Clean out #[deprecated] APIsAlex Crichton-34/+0
This commit cleans out a large amount of deprecated APIs from the standard library and some of the facade crates as well, updating all users in the compiler and in tests as it goes along.
2015-03-25Change lint names to pluralsNick Cameron-1/+1
2015-03-25Add trivial cast lints.Nick Cameron-1/+5
This permits all coercions to be performed in casts, but adds lints to warn in those cases. Part of this patch moves cast checking to a later stage of type checking. We acquire obligations to check casts as part of type checking where we previously checked them. Once we have type checked a function or module, then we check any cast obligations which have been acquired. That means we have more type information available to check casts (this was crucial to making coercions work properly in place of some casts), but it means that casts cannot feed input into type inference. [breaking change] * Adds two new lints for trivial casts and trivial numeric casts, these are warn by default, but can cause errors if you build with warnings as errors. Previously, trivial numeric casts and casts to trait objects were allowed. * The unused casts lint has gone. * Interactions between casting and type inference have changed in subtle ways. Two ways this might manifest are: - You may need to 'direct' casts more with extra type information, for example, in some cases where `foo as _ as T` succeeded, you may now need to specify the type for `_` - Casts do not influence inference of integer types. E.g., the following used to type check: ``` let x = 42; let y = &x as *const u32; ``` Because the cast would inform inference that `x` must have type `u32`. This no longer applies and the compiler will fallback to `i32` for `x` and thus there will be a type error in the cast. The solution is to add more type information: ``` let x: u32 = 42; let y = &x as *const u32; ```
2015-03-23Add #![feature] attributes to doctestsBrian Anderson-0/+1
2015-03-19core: Inline most cell methods.Patrick Walton-0/+21
This is a significant performance problem in Servo.
2015-03-08Clean up references to opt-out traitsSteve Klabnik-3/+0
They're opt-in now. Fixes #22572
2015-02-22Add negative impls for SyncFlavio Percoco-1/+3
2015-02-17Register new snapshotsAlex Crichton-2/+1
2015-02-17rollup merge of #22435: aturon/final-stab-threadAlex Crichton-4/+4
Conflicts: src/test/bench/rt-messaging-ping-pong.rs src/test/bench/rt-parfib.rs src/test/bench/task-perf-spawnalot.rs
2015-02-17Fallout from stabilizationAaron Turon-4/+4
2015-02-16Update `core::cell` for `isize/usize` transition.Felix S. Klock II-7/+7
2015-02-13Rename the "unsafe" lang item to "unsafe_cell"Chris Wong-1/+2
2015-02-09Fix links to module-level documentation in `std::cell`Michael Budde-5/+5
Replace links to `../index.html` with `index.html` as they are linking to the `std` module and not `std::cell` as intended.
2015-02-02Test fixes and rebase conflictsAlex Crichton-1/+1
2015-02-01std: Deprecate RefCell::{try_borrow, try_borrow_mut}Alex Crichton-10/+45
The existence of these two functions is at odds with our current [error conventions][conventions] which recommend that panicking and `Result`-like variants should not be provided together. [conventions]: https://github.com/rust-lang/rfcs/blob/master/text/0236-error-conventions.md#do-not-provide-both-result-and-fail-variants This commit adds a new `borrow_state` function returning a `BorrowState` enum to `RefCell` which serves as a replacemnt for the `try_borrow` and `try_borrow_mut` functions.
2015-01-29Rollup merge of 21663 - tbu-:pr_doc_cell_static_safety, r=alexcrichtonManish Goregaokar-6/+0
2015-01-27Merge remote-tracking branch 'rust-lang/master'Brian Anderson-84/+209
Conflicts: src/libcore/cell.rs src/librustc_driver/test.rs src/libstd/old_io/net/tcp.rs src/libstd/old_io/process.rs
2015-01-27Auto merge of #21564 - steveklabnik:doc_cell, r=alexcrichtonbors-85/+209
2015-01-26Remove comment about `UnsafeCell`s and `static`Tobias Bucher-6/+0
It has actually been safe to put an `UnsafeCell` into a non-mutable `static` since the `const` change.
2015-01-25Merge remote-tracking branch 'rust-lang/master'Brian Anderson-4/+4
Conflicts: src/libcore/cmp.rs src/libcore/fmt/mod.rs src/libcore/iter.rs src/libcore/marker.rs src/libcore/num/f32.rs src/libcore/num/f64.rs src/libcore/result.rs src/libcore/str/mod.rs src/librustc/lint/builtin.rs src/librustc/lint/context.rs src/libstd/sync/mpsc/mod.rs src/libstd/sync/poison.rs
2015-01-25Merge remote-tracking branch 'rust-lang/master'Brian Anderson-0/+4
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-25Moving away from deprecated i/u suffixes in libcoreAlfie John-4/+4
2015-01-23grandfathered -> rust1Brian Anderson-29/+29
2015-01-23Set unstable feature names appropriatelyBrian Anderson-6/+6
* `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-23Improve libcore/cell.rs docsSteve Klabnik-85/+209
2015-01-21Remove 'since' from unstable attributesBrian Anderson-6/+6
2015-01-21Add 'feature' and 'since' to stability attributesBrian Anderson-35/+36
2015-01-21Explain that RefCell is single-threaded.Steve Klabnik-0/+4
Fixes #21469.