Skip to content

Commit 18910b7

Browse files
authored
Rollup merge of #150619 - cvengler:move-cow-impl, r=Mark-Simulacrum
alloc: Move Cow impl to existing ones Right now, the `borrow.rs` module starts with a `Cow` impl, although most of them can be found below. This hurts code readability because there is `ToOwned` alongside its impl directly below it. Moving it to the others down below makes sense here, given that the entire enum depends on `ToOwned` anyways.
2 parents 9dd3b23 + 9a675c0 commit 18910b7

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

library/alloc/src/borrow.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,6 @@ use crate::fmt;
1616
#[cfg(not(no_global_oom_handling))]
1717
use crate::string::String;
1818

19-
// FIXME(inference): const bounds removed due to inference regressions found by crater;
20-
// see https://github.com/rust-lang/rust/issues/147964
21-
// #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
22-
#[stable(feature = "rust1", since = "1.0.0")]
23-
impl<'a, B: ?Sized + ToOwned> Borrow<B> for Cow<'a, B>
24-
// where
25-
// B::Owned: [const] Borrow<B>,
26-
{
27-
fn borrow(&self) -> &B {
28-
&**self
29-
}
30-
}
31-
3219
/// A generalization of `Clone` to borrowed data.
3320
///
3421
/// Some types make it possible to go from borrowed to owned, usually by
@@ -192,6 +179,19 @@ where
192179
Owned(#[stable(feature = "rust1", since = "1.0.0")] <B as ToOwned>::Owned),
193180
}
194181

182+
// FIXME(inference): const bounds removed due to inference regressions found by crater;
183+
// see https://github.com/rust-lang/rust/issues/147964
184+
// #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
185+
#[stable(feature = "rust1", since = "1.0.0")]
186+
impl<'a, B: ?Sized + ToOwned> Borrow<B> for Cow<'a, B>
187+
// where
188+
// B::Owned: [const] Borrow<B>,
189+
{
190+
fn borrow(&self) -> &B {
191+
&**self
192+
}
193+
}
194+
195195
#[stable(feature = "rust1", since = "1.0.0")]
196196
impl<B: ?Sized + ToOwned> Clone for Cow<'_, B> {
197197
fn clone(&self) -> Self {

0 commit comments

Comments
 (0)