diff options
| author | CDirkx <christiaan@dirkx.com> | 2020-08-31 03:43:47 +0200 |
|---|---|---|
| committer | CDirkx <christiaan@dirkx.com> | 2020-08-31 03:43:47 +0200 |
| commit | af24bdbd96120d34f36595127376a3bf2800a7b6 (patch) | |
| tree | 119ba06f77a0f2822787dc2057be7601fd488a7f /library/alloc/src | |
| parent | 36b0d7e25769e88fec85e1d073196065a7f2d7c4 (diff) | |
| download | rust-af24bdbd96120d34f36595127376a3bf2800a7b6.tar.gz rust-af24bdbd96120d34f36595127376a3bf2800a7b6.zip | |
Make `cow_is_borrowed` methods const
Constify the following methods of `alloc::borrow::Cow`: - `is_borrowed` - `is_owned` These methods are still unstable under `cow_is_borrowed`. Possible because of #49146 (Allow if and match in constants). Tracking issue: #65143
Diffstat (limited to 'library/alloc/src')
| -rw-r--r-- | library/alloc/src/borrow.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/alloc/src/borrow.rs b/library/alloc/src/borrow.rs index 51c233a21f1..e7260f3956c 100644 --- a/library/alloc/src/borrow.rs +++ b/library/alloc/src/borrow.rs @@ -217,7 +217,7 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> { /// assert!(!bull.is_borrowed()); /// ``` #[unstable(feature = "cow_is_borrowed", issue = "65143")] - pub fn is_borrowed(&self) -> bool { + pub const fn is_borrowed(&self) -> bool { match *self { Borrowed(_) => true, Owned(_) => false, @@ -239,7 +239,7 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> { /// assert!(!bull.is_owned()); /// ``` #[unstable(feature = "cow_is_borrowed", issue = "65143")] - pub fn is_owned(&self) -> bool { + pub const fn is_owned(&self) -> bool { !self.is_borrowed() } |
