@@ -212,43 +212,51 @@ impl<B: ?Sized + ToOwned> Clone for Cow<'_, B> {
212
212
impl < B : ?Sized + ToOwned > Cow < ' _ , B > {
213
213
/// Returns true if the data is borrowed, i.e. if `to_mut` would require additional work.
214
214
///
215
+ /// Note: this is an associated function, which means that you have to call
216
+ /// it as `Cow::is_borrowed(&c)` instead of `c.is_borrowed()`. This is so
217
+ /// that there is no conflict with a method on the inner type.
218
+ ///
215
219
/// # Examples
216
220
///
217
221
/// ```
218
222
/// #![feature(cow_is_borrowed)]
219
223
/// use std::borrow::Cow;
220
224
///
221
225
/// let cow = Cow::Borrowed("moo");
222
- /// assert!(cow. is_borrowed());
226
+ /// assert!(Cow:: is_borrowed(&cow ));
223
227
///
224
228
/// let bull: Cow<'_, str> = Cow::Owned("...moo?".to_string());
225
- /// assert!(!bull. is_borrowed());
229
+ /// assert!(!Cow:: is_borrowed(&bull ));
226
230
/// ```
227
231
#[ unstable( feature = "cow_is_borrowed" , issue = "65143" ) ]
228
- pub const fn is_borrowed ( & self ) -> bool {
229
- match * self {
232
+ pub const fn is_borrowed ( c : & Self ) -> bool {
233
+ match * c {
230
234
Borrowed ( _) => true ,
231
235
Owned ( _) => false ,
232
236
}
233
237
}
234
238
235
239
/// Returns true if the data is owned, i.e. if `to_mut` would be a no-op.
236
240
///
241
+ /// Note: this is an associated function, which means that you have to call
242
+ /// it as `Cow::is_owned(&c)` instead of `c.is_owned()`. This is so that
243
+ /// there is no conflict with a method on the inner type.
244
+ ///
237
245
/// # Examples
238
246
///
239
247
/// ```
240
248
/// #![feature(cow_is_borrowed)]
241
249
/// use std::borrow::Cow;
242
250
///
243
251
/// let cow: Cow<'_, str> = Cow::Owned("moo".to_string());
244
- /// assert!(cow. is_owned());
252
+ /// assert!(Cow:: is_owned(&cow ));
245
253
///
246
254
/// let bull = Cow::Borrowed("...moo?");
247
- /// assert!(!bull. is_owned());
255
+ /// assert!(!Cow:: is_owned(&bull ));
248
256
/// ```
249
257
#[ unstable( feature = "cow_is_borrowed" , issue = "65143" ) ]
250
- pub const fn is_owned ( & self ) -> bool {
251
- !self . is_borrowed ( )
258
+ pub const fn is_owned ( c : & Self ) -> bool {
259
+ !Cow :: is_borrowed ( c )
252
260
}
253
261
254
262
/// Acquires a mutable reference to the owned form of the data.
0 commit comments