Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add [A]RcBorrow -> Weak conversion without strong clone #59

Merged
merged 1 commit into from
May 26, 2020
Merged

Conversation

CAD97
Copy link
Owner

@CAD97 CAD97 commented May 24, 2020

pub fn $RcBorrow<'_, T>::to_weak(Self) -> $rc::Weak<T>;

Also includes a cargo update and adjusts removes unneccessary use of autocfg.


Closes #58, cc @yvt: do you have any other suggestions for what this method should be called?

If I could go back in time, it would be $RcBorrow::upgrade(Self) -> $Rc, $RcBorrow::downgrade(Self) -> $Weak, and $RcBorrow::extend(Self) -> &'a T, but that ship has sailed.

It might still be worth it to deprecate downgrade and replace it with extend or some other better name, as downgrade does not match context, where the point is to get a longer-lived reference.

@CAD97
Copy link
Owner Author

CAD97 commented May 26, 2020

This PR just adds to_weak, and I'll consider renaming downgrade in a later release.

bors: r+

@bors
Copy link
Contributor

bors bot commented May 26, 2020

Build succeeded:

@bors bors bot merged commit 4b286e1 into master May 26, 2020
@bors bors bot deleted the borrow-weak branch May 26, 2020 16:48
yvt added a commit to yvt/Stella2 that referenced this pull request May 27, 2020
This was made possible by a recent addition to `rc-borrow`:
<CAD97/pointer-utils#59>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Ability to construct Weak<T> from RcBorrow<T>
1 participant