about summary refs log tree commit diff
path: root/src/test
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 /src/test
parent4f276202f52ca6cfd122cc88ea304b197ab06a02 (diff)
parentd591829ed0c9c589c0b05e9cabf1b90d30ed19a9 (diff)
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 'src/test')
-rw-r--r--src/test/ui/consts/cow-is-borrowed.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/test/ui/consts/cow-is-borrowed.rs b/src/test/ui/consts/cow-is-borrowed.rs
new file mode 100644
index 00000000000..adebe20f5a2
--- /dev/null
+++ b/src/test/ui/consts/cow-is-borrowed.rs
@@ -0,0 +1,15 @@
+// run-pass
+
+#![feature(cow_is_borrowed)]
+
+use std::borrow::Cow;
+
+fn main() {
+    const COW: Cow<str> = Cow::Borrowed("moo");
+
+    const IS_BORROWED: bool = COW.is_borrowed();
+    assert!(IS_BORROWED);
+
+    const IS_OWNED: bool = COW.is_owned();
+    assert!(!IS_OWNED);
+}