Skip to content

Commit af24bdb

Browse files
author
CDirkx
committed
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 rust-lang#49146 (Allow if and match in constants). Tracking issue: rust-lang#65143
1 parent 36b0d7e commit af24bdb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/alloc/src/borrow.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
217217
/// assert!(!bull.is_borrowed());
218218
/// ```
219219
#[unstable(feature = "cow_is_borrowed", issue = "65143")]
220-
pub fn is_borrowed(&self) -> bool {
220+
pub const fn is_borrowed(&self) -> bool {
221221
match *self {
222222
Borrowed(_) => true,
223223
Owned(_) => false,
@@ -239,7 +239,7 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
239239
/// assert!(!bull.is_owned());
240240
/// ```
241241
#[unstable(feature = "cow_is_borrowed", issue = "65143")]
242-
pub fn is_owned(&self) -> bool {
242+
pub const fn is_owned(&self) -> bool {
243243
!self.is_borrowed()
244244
}
245245

0 commit comments

Comments
 (0)