summary refs log tree commit diff
path: root/library/alloc/src
diff options
context:
space:
mode:
authorTyler Mandry <tmandry@gmail.com>2020-08-31 19:18:21 -0700
committerGitHub <noreply@github.com>2020-08-31 19:18:21 -0700
commitc307e90daaaba8b66e3335a82d343f7a62361c02 (patch)
tree1f6e7c947c63cfe2f04214e39c6c9d7519289572 /library/alloc/src
parent4f276202f52ca6cfd122cc88ea304b197ab06a02 (diff)
parentd591829ed0c9c589c0b05e9cabf1b90d30ed19a9 (diff)
downloadrust-c307e90daaaba8b66e3335a82d343f7a62361c02.tar.gz
rust-c307e90daaaba8b66e3335a82d343f7a62361c02.zip
Rollup merge of #76139 - CDirkx:cow-is-borrowed, r=ecstatic-morse
Make `cow_is_borrowed` methods const

Constify the following methods of `alloc::borrow::Cow`:
 - `is_borrowed`
 - `is_owned`

Analogous to the const methods `is_some` and `is_none` for Option, and `is_ok` and `is_err` for Result.

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.rs4
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()
     }