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 Mutex::with #61976

Open
wants to merge 2 commits into
base: master
from

Conversation

@jsgf
Copy link
Contributor

commented Jun 19, 2019

Helper which makes taking a Mutex for the duration of a single closure lower friction.

Issue #61974

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Jun 19, 2019

r? @sfackler

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Jun 19, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:13338fc0:start=1560983167396136177,finish=1560983168177490865,duration=781354688
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
travis_time:start:test_assembly
Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:07:11] 
[01:07:11] running 9 tests
[01:07:11] iiiiiiiii
[01:07:11] 
[01:07:11]  finished in 0.152
[01:07:11] travis_fold:end:test_assembly

---
travis_time:start:test_debuginfo
Check compiletest suite=debuginfo mode=debuginfo-gdb+lldb (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:07:27] 
[01:07:27] running 122 tests
[01:07:53] .iiiii...i.....i..i...i..i.i.i..i.ii..i.i.....i..i....i..........iiii..........i...ii...i.......ii.i 100/122
[01:07:58] .i.i......iii.i.....ii
[01:07:58] 
[01:07:58]  finished in 30.631
[01:07:58] travis_fold:end:test_debuginfo

---
[01:24:23] ..................................................i..i.......................................iiii... 400/927
[01:24:34] ....ii.............................................................................................. 500/927
[01:24:39] .................................................................................................... 600/927
[01:24:48] ..................................................iiii.............................................. 700/927
[01:25:03] .....................................................................F.............................. 800/927
[01:25:11] ...........................
[01:25:11] failures:
[01:25:11] 
[01:25:11] ---- sync/mutex.rs - sync::mutex::Mutex<T>::with (line 374) stdout ----
[01:25:11] ---- sync/mutex.rs - sync::mutex::Mutex<T>::with (line 374) stdout ----
[01:25:11] error[E0425]: cannot find value `old` in this scope
[01:25:11]  --> sync/mutex.rs:380:28
[01:25:11]   |
[01:25:11] 9 | let old = mutex.with(|v| { old = v; *v += 1; old }).unwrap();
[01:25:11] 
[01:25:11] error[E0425]: cannot find value `old` in this scope
[01:25:11]  --> sync/mutex.rs:380:46
[01:25:11]   |
[01:25:11]   |
[01:25:11] 9 | let old = mutex.with(|v| { old = v; *v += 1; old }).unwrap();
[01:25:11] 
[01:25:11] 
[01:25:11] error[E0658]: use of unstable library feature 'mutex_with'
[01:25:11]  --> sync/mutex.rs:380:17
[01:25:11]   |
[01:25:11] 9 | let old = mutex.with(|v| { old = v; *v += 1; old }).unwrap();
[01:25:11]   |
[01:25:11]   = note: for more information, see https://github.com/rust-lang/rust/issues/61974
[01:25:11]   = note: for more information, see https://github.com/rust-lang/rust/issues/61974
[01:25:11]   = help: add #![feature(mutex_with)] to the crate attributes to enable
[01:25:11] error: aborting due to 3 previous errors
[01:25:11] 
[01:25:11] Some errors have detailed explanations: E0425, E0658.
[01:25:11] For more information about an error, try `rustc --explain E0425`.
---
[01:25:11] 
[01:25:11] error: test failed, to rerun pass '--doc'
[01:25:11] 
[01:25:11] 
[01:25:11] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace compiler-builtins-c" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "-p" "std" "--" "--quiet"
[01:25:11] 
[01:25:11] 
[01:25:11] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:25:11] Build completed unsuccessfully in 1:20:16
---
travis_time:end:18564150:start=1560988291969317982,finish=1560988291974093087,duration=4775105
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:014f6fae
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:12d1e080
travis_time:start:12d1e080
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:295635e4
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@jsgf jsgf force-pushed the jsgf:mutex-with branch from bf29362 to ba5514c Jun 19, 2019

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Jun 20, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:0f3d16ce:start=1560988541798627538,finish=1560988542542871746,duration=744244208
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
travis_time:start:test_assembly
Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:05:19] 
[01:05:19] running 9 tests
[01:05:19] iiiiiiiii
[01:05:19] 
[01:05:19]  finished in 0.155
[01:05:19] travis_fold:end:test_assembly

---
travis_time:start:test_debuginfo
Check compiletest suite=debuginfo mode=debuginfo-gdb+lldb (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:05:35] 
[01:05:35] running 122 tests
[01:06:00] .iiiii...i.....i..i...i..i.i.i..i.ii..i.i.....i..i....i..........iiii..........i...ii...i.......ii.i 100/122
[01:06:05] .i.i......iii.i.....ii
[01:06:05] 
[01:06:05]  finished in 29.934
[01:06:05] travis_fold:end:test_debuginfo

---
[01:22:13] ..................................................i..i.......................................iiii... 400/927
[01:22:23] ....ii.............................................................................................. 500/927
[01:22:27] .................................................................................................... 600/927
[01:22:36] ..................................................iiii.............................................. 700/927
[01:22:50] .....................................................................F.............................. 800/927
[01:22:59] ...........................
[01:22:59] failures:
[01:22:59] 
[01:22:59] ---- sync/mutex.rs - sync::mutex::Mutex<T>::with (line 374) stdout ----
[01:22:59] ---- sync/mutex.rs - sync::mutex::Mutex<T>::with (line 374) stdout ----
[01:22:59] error[E0658]: use of unstable library feature 'mutex_with'
[01:22:59]  --> sync/mutex.rs:380:17
[01:22:59]   |
[01:22:59] 9 | let old = mutex.with(|v| { let old = v; *v += 1; old }).unwrap();
[01:22:59]   |
[01:22:59]   = note: for more information, see https://github.com/rust-lang/rust/issues/61974
[01:22:59]   = note: for more information, see https://github.com/rust-lang/rust/issues/61974
[01:22:59]   = help: add #![feature(mutex_with)] to the crate attributes to enable
[01:22:59] 
[01:22:59] error[E0277]: can't compare `&mut {integer}` with `{integer}`
[01:22:59]   --> sync/mutex.rs:382:1
[01:22:59] 11 | assert_eq!(old, 0);
[01:22:59] 11 | assert_eq!(old, 0);
[01:22:59]    | ^^^^^^^^^^^^^^^^^^^ no implementation for `&mut {integer} == {integer}`
[01:22:59]    |
[01:22:59]    = help: the trait `std::cmp::PartialEq<{integer}>` is not implemented for `&mut {integer}`
[01:22:59] 
[01:22:59] error: aborting due to 2 previous errors
[01:22:59] 
[01:22:59] Some errors have detailed explanations: E0277, E0658.
---
[01:22:59] 
[01:22:59] error: test failed, to rerun pass '--doc'
[01:22:59] 
[01:22:59] 
[01:22:59] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace compiler-builtins-c" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "-p" "std" "--" "--quiet"
[01:22:59] 
[01:22:59] 
[01:22:59] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:22:59] Build completed unsuccessfully in 1:18:14
---
travis_time:end:148c203c:start=1560993534474586616,finish=1560993534479135248,duration=4548632
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:27c2d3ec
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:1056ce70
travis_time:start:1056ce70
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:1f903f0a
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

pub fn with<U>(
&self,
func: impl FnOnce(&mut T) -> U,
) -> Result<U, PoisonError<MutexGuard<'_, T>>> {

This comment has been minimized.

Copy link
@sfackler

sfackler Jun 20, 2019

Member

Why would the PoisonError contain the guard in this case?

This comment has been minimized.

Copy link
@jsgf

jsgf Jun 20, 2019

Author Contributor

I was making it as similar to LockResult as possible, with the same error type. I guess the rationale is that if you have a poisoned lock, and you can actually recover from that, then having the guard would allow you to do so. On the other hand, that's at odds with point of this API, which is to be simple and low fuss.

I think the alternatives are:

  1. Use PoisonError<()>
  2. Don't return Result at all, and just panic on a poisoned lock

Since I think poisoned locks are unrecoverable in practice, 2. is possibly justifiable, but it seems a bit rude for a libstd function to do that. And as far as 1. goes, if we're going to return an error anyway, it may as well have the guard in it, even if its never used in practice.

This comment has been minimized.

Copy link
@Centril

Centril Jun 20, 2019

Member

We could add a try_with variant for the non-panicing version.

This comment has been minimized.

Copy link
@jsgf

jsgf Jun 20, 2019

Author Contributor

So with panics, try_with returns a Result?

This comment has been minimized.

Copy link
@Centril

Centril Jun 20, 2019

Member

Yeah that's the idea.

This comment has been minimized.

Copy link
@jsgf

jsgf Jun 21, 2019

Author Contributor

I updated to include try_with, but TBH I think it is overkill. I don't think this

match mx.with(|v| *v += 1234) {
Ok(()) => (),
Err(err) => ... handle err ...,

is any improvement over this:

match mx.lock() {
Ok(lk) => *lk += 1234,
Err(err) => ... handle err ...,
}

@jsgf jsgf force-pushed the jsgf:mutex-with branch from ba5514c to a90edb9 Jun 20, 2019

Show resolved Hide resolved src/libstd/sync/mutex.rs Outdated
/// assert_eq!(*mutex.lock().unwrap(), 1);
/// ```
#[unstable(feature = "mutex_with", issue = "61974")]
pub fn with<U>(

This comment has been minimized.

Copy link
@Centril

Centril Jun 20, 2019

Member
Suggested change
pub fn with<U>(
pub fn with<U, F: FnOnce(&mut T) -> U>(
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Jun 20, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:1bdb10b2:start=1561010002223205726,finish=1561010091696714849,duration=89473509123
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
travis_time:start:test_assembly
Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:03:26] 
[01:03:26] running 9 tests
[01:03:26] iiiiiiiii
[01:03:26] 
[01:03:26]  finished in 0.145
[01:03:26] travis_fold:end:test_assembly

---
travis_time:start:test_debuginfo
Check compiletest suite=debuginfo mode=debuginfo-gdb+lldb (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:03:42] 
[01:03:42] running 122 tests
[01:04:06] .iiiii...i.....i..i...i..i.i.i..i.ii..i.i.....i..i....i..........iiii..........i...ii...i.......ii.i 100/122
[01:04:11] .i.i......iii.i.....ii
[01:04:11] 
[01:04:11]  finished in 28.916
[01:04:11] travis_fold:end:test_debuginfo

---
[01:19:49] ..................................................i..i.......................................iiii... 400/927
[01:19:59] ....ii.............................................................................................. 500/927
[01:20:03] .................................................................................................... 600/927
[01:20:12] ..................................................iiii.............................................. 700/927
[01:20:27] ......................................................................F............................. 800/927
[01:20:35] ...........................
[01:20:35] failures:
[01:20:35] 
[01:20:35] ---- sync/mutex.rs - sync::mutex::Mutex<T>::with (line 374) stdout ----
[01:20:35] ---- sync/mutex.rs - sync::mutex::Mutex<T>::with (line 374) stdout ----
[01:20:35] error[E0658]: use of unstable library feature 'mutex_with'
[01:20:35]  --> sync/mutex.rs:380:17
[01:20:35]   |
[01:20:35] 9 | let old = mutex.with(|v| { let old = *v; *v += 1; old }).unwrap();
[01:20:35]   |
[01:20:35]   = note: for more information, see https://github.com/rust-lang/rust/issues/61974
[01:20:35]   = note: for more information, see https://github.com/rust-lang/rust/issues/61974
[01:20:35]   = help: add #![feature(mutex_with)] to the crate attributes to enable
[01:20:35] error: aborting due to previous error
[01:20:35] 
[01:20:35] For more information about this error, try `rustc --explain E0658`.
[01:20:35] Couldn't compile the test.
---
[01:20:35] 
[01:20:35] error: test failed, to rerun pass '--doc'
[01:20:35] 
[01:20:35] 
[01:20:35] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace compiler-builtins-c" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "-p" "std" "--" "--quiet"
[01:20:35] 
[01:20:35] 
[01:20:35] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:20:35] Build completed unsuccessfully in 1:16:37
---
travis_time:end:2c39fef8:start=1561014937184572312,finish=1561014937189228075,duration=4655763
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:10af183d
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:152cc5ce
travis_time:start:152cc5ce
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:03269352
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@jsgf

This comment has been minimized.

Copy link
Contributor Author

commented Jun 20, 2019

@Centril @sfackler What's the story for doc tests for unstable features? Do they have a #![feature(...)] line in the test?

@Centril

This comment has been minimized.

Copy link
Member

commented Jun 20, 2019

@jsgf Yep.

@jsgf jsgf force-pushed the jsgf:mutex-with branch from a90edb9 to 38d144d Jun 21, 2019

@jsgf

This comment has been minimized.

Copy link
Contributor Author

commented Jun 21, 2019

I added Mutex::try_with which returns Result and Mutex::with which panics on poisoned locks.

I also added RwLock::with_read, with_write, try_with_read, try_with_write for consistency.

@jsgf

This comment has been minimized.

Copy link
Contributor Author

commented Jun 21, 2019

Tho I'm inclined to drop the try variants - we can add them later if they turn out to be useful.

@edmilsonefs

This comment has been minimized.

Copy link

commented Jul 11, 2019

Hey! This is a ping from triage, we would like to know if you @sfackler could give us a few more minutes to update us from last changes made by @jsgf .

Thanks.

@jsgf

This comment has been minimized.

Copy link
Contributor Author

commented Jul 12, 2019

I would definitely like feedback about whether to include the Result-returning try_ variants, or just go with panic-on-poison with. I'm biased towards the latter, but happy to go the other way if that's the consensus.

@JohnCSimon

This comment has been minimized.

Copy link

commented Jul 27, 2019

@rust-lang/core Hello from triage, can this PR have another reviewer? Thanks.

@Manishearth

This comment has been minimized.

Copy link
Member

commented Jul 27, 2019

Please don't ping core from triage.

@rust-lang/libs is who you want

(Shouldn't this PR come with an RFC? I guess it's fine if it's unstable but we usually RFC those)

@Centril

This comment has been minimized.

Copy link
Member

commented Jul 27, 2019

@Manishearth As I understand it, standard practice for most libs features is to do it by PR if 2-3 people agree its a good idea and maybe a libs team reviewer for a larger change or if there are design questions. (unless it has lang implications...)

@Amanieu

This comment has been minimized.

Copy link
Contributor

commented Jul 27, 2019

try_with feels very misleading here since I would intuitively expect it to perform a try_lock rather than lock. IMO it should just be dropped since with is just a convenience wrapper around lock.

@alexcrichton

This comment has been minimized.

Copy link
Member

commented Jul 29, 2019

Reading the current state of the PR, I'd agree with @Amanieu and add that I found the implementations of the functions added here to be pretty surprising in terms of how they handled poisoning and such. The functions seem very small and not really adding much benefit over calling .lock().map(...) anyway, so I'm not certain myself that these implementations (as-is) should be going into the standard library.

@jsgf

This comment has been minimized.

Copy link
Contributor Author

commented Jul 31, 2019

I agree with the criticism of try_with - try is ambiguous in this context, and the functionality it provides isn't useful.

I proposed plain with because I've encountered several local implementations of it in our codebase (both as a free function and as part of a MutexExt trait), and it seemed like a useful extension to basic Mutex. .lock().map(...).unwrap() is not really equivalent because the map is getting the guard rather than the underlying locked object; the convenience of with is that it completely removes the guard from the equation.

And sure its just a deref away, but its a lot of extra noise. Something like:

let res = mutex.with(|inner| undulate(inner));

is a lot cleaner than

let res = mutex.map(|guard| undulate(&mut *guard).unwrap();

jsgf added some commits Jun 19, 2019

Add Mutex::with
Helper which makes taking a `Mutex` for the duration of a single closure lower friction.

Issue #61974

@jsgf jsgf force-pushed the jsgf:mutex-with branch from 38d144d to f750d12 Aug 3, 2019

@jsgf

This comment has been minimized.

Copy link
Contributor Author

commented Aug 3, 2019

Rebased; removed confusing try_ variants, just leaving basic with/with_read/with_write.

@alexcrichton

This comment has been minimized.

Copy link
Member

commented Aug 5, 2019

That's a good point about dereferencing the guards returned. I feel like this API as-is would be reasonable if we didn't have poisioning, but with mutexes that support poisoning it seems out of place as one of the only APIs that doesn't operate with a result.

If you do indeed return a result then the comparison between the two APIs I think is much less compelling:

let res = mutex.with(|inner| undulate(inner)).unwrap();
// ... vs ...
let res = mutex.map(|inner| undulate(&mut *inner).unwrap();

I don't think anyone will argue that the latter is more ergonomic, but I'm not sure it's more ergonomic enough to warrant a new API.

@jsgf

This comment has been minimized.

Copy link
Contributor Author

commented Aug 5, 2019

Yeah. I was trying to find any examples of anyone using poison for anything other than unwrap/expect, but couldn't find any. This diff is basically treating poison as legacy API cruft.

@alexcrichton

This comment has been minimized.

Copy link
Member

commented Aug 6, 2019

If that's the case I don't think that can really happen on this PR. I don't think we should add a one-off API that takes poisoning as API cruft, but we can of course have a discussion about poisoning in general and how to handle it.

@JohnCSimon

This comment has been minimized.

Copy link

commented Aug 17, 2019

Hello from triage
@alexcrichton @jsgf @sfackler I'm unsure what should be done with this PR itself.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
10 participants
You can’t perform that action at this time.