Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
63396b3
Allow binary files to go through the `FileLoader`
thomcc Mar 6, 2023
8ac7d0e
Add suggestion to diagnostic when user has array but trait wants slice.
BGR360 Nov 28, 2021
29b0bef
bootstrap: document tidy
Teapot4195 Mar 10, 2023
b7a7077
Give proper error message when tcx wasn't passed to decoder
Noratrieb Mar 11, 2023
898d2c1
remove duplicated calls to sort_string
klensy Mar 11, 2023
9a24e2f
Expand on the allocator comment in `rustc-main`
jyn514 Mar 11, 2023
e89bd94
fix link
jyn514 Mar 11, 2023
cde0b16
tidy: allow direct format args capture in macro
est31 Mar 4, 2023
7a686bf
tidy: enforce comment blocks to have even number of backticks
est31 Mar 3, 2023
7f4cc17
Address the new odd backticks tidy lint in compiler/
est31 Mar 4, 2023
9475717
Add a fixme and address a more non trivial case
est31 Mar 4, 2023
3a20d52
Extend the tidy lint to ftl files
est31 Mar 4, 2023
b2aeb07
Use trimmed instead of line for performance
est31 Mar 4, 2023
856c9bb
Add eslint checks for rustdoc-js tester
GuillaumeGomez Mar 11, 2023
904d9c5
Improve rustdoc-js tester code clarity a bit
GuillaumeGomez Mar 11, 2023
ca9b618
Add rustdoc-js eslint check into CI
GuillaumeGomez Mar 11, 2023
a2341fb
Introduce `Rc::into_inner`, as a parallel to `Arc::into_inner`
joshtriplett Mar 11, 2023
1c4603e
Commit some tests for the new solver + lazy norm
compiler-errors Mar 11, 2023
cecb680
Rollup merge of #108726 - est31:backticks_matchmaking_tidy, r=Nilstrieb
matthiaskrgr Mar 12, 2023
de16b4b
Rollup merge of #108797 - thomcc:sourcemap_include_binary_file, r=com…
matthiaskrgr Mar 12, 2023
9d26cb3
Rollup merge of #108841 - jackh726:issue-90528, r=compiler-errors
matthiaskrgr Mar 12, 2023
05ef0bd
Rollup merge of #108984 - Teapot4195:issue-106803-fix, r=ozkanonur
matthiaskrgr Mar 12, 2023
76f239a
Rollup merge of #109013 - Nilstrieb:obscurity-is-not-a-necessity, r=f…
matthiaskrgr Mar 12, 2023
16f6344
Rollup merge of #109017 - klensy:dupe, r=cjgillot
matthiaskrgr Mar 12, 2023
ab03c10
Rollup merge of #109018 - jyn514:global-allocator-comment, r=lqd
matthiaskrgr Mar 12, 2023
4065bb4
Rollup merge of #109026 - joshtriplett:rc-into-inner, r=dtolnay
matthiaskrgr Mar 12, 2023
daa70fc
Rollup merge of #109028 - GuillaumeGomez:rustdoc-js-tester-eslint, r=…
matthiaskrgr Mar 12, 2023
3aa332e
Rollup merge of #109034 - compiler-errors:lazy-norm-tests, r=jackh726
matthiaskrgr Mar 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Introduce Rc::into_inner, as a parallel to Arc::into_inner
Unlike `Arc`, `Rc` doesn't have the same race condition to avoid, but
maintaining an equivalent API still makes it easier to work with both
`Rc` and `Arc`.
  • Loading branch information
joshtriplett committed Mar 11, 2023
commit a2341fbbc2f9b35292473f139d17316a55d9e3d0
18 changes: 18 additions & 0 deletions library/alloc/src/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,24 @@ impl<T> Rc<T> {
Err(this)
}
}

/// Returns the inner value, if the `Rc` has exactly one strong reference.
///
/// Otherwise, [`None`] is returned and the `Rc` is dropped.
///
/// This will succeed even if there are outstanding weak references.
///
/// If `Rc::into_inner` is called on every clone of this `Rc`,
/// it is guaranteed that exactly one of the calls returns the inner value.
/// This means in particular that the inner value is not dropped.
///
/// This is equivalent to `Rc::try_unwrap(...).ok()`. (Note that these are not equivalent for
/// `Arc`, due to race conditions that do not apply to `Rc`.)
#[inline]
#[unstable(feature = "rc_into_inner", issue = "106894")]
pub fn into_inner(this: Self) -> Option<T> {
Rc::try_unwrap(this).ok()
}
}

impl<T> Rc<[T]> {
Expand Down
16 changes: 16 additions & 0 deletions library/alloc/src/rc/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,22 @@ fn try_unwrap() {
assert_eq!(Rc::try_unwrap(x), Ok(5));
}

#[test]
fn into_inner() {
let x = Rc::new(3);
assert_eq!(Rc::into_inner(x), Some(3));

let x = Rc::new(4);
let y = Rc::clone(&x);
assert_eq!(Rc::into_inner(x), None);
assert_eq!(Rc::into_inner(y), Some(4));

let x = Rc::new(5);
let _w = Rc::downgrade(&x);
assert_eq!(Rc::into_inner(x), Some(5));
}


#[test]
fn into_from_raw() {
let x = Rc::new(Box::new("hello"));
Expand Down