Skip to content

Commit 867cf6b

Browse files
committed
Fix Windows build
1 parent 3e0efe4 commit 867cf6b

File tree

2 files changed

+59
-6
lines changed

2 files changed

+59
-6
lines changed

src/libstd/sys/windows/os_str.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,33 @@
1+
use crate::alloc::{AllocRef, Global};
12
/// The underlying OsString/OsStr implementation on Windows is a
23
/// wrapper around the "WTF-8" encoding; see the `wtf8` module for more.
34
use crate::borrow::Cow;
45
use crate::fmt;
6+
use crate::hash;
57
use crate::mem;
68
use crate::rc::Rc;
79
use crate::sync::Arc;
810
use crate::sys_common::wtf8::{Wtf8, Wtf8Buf};
911
use crate::sys_common::{AsInner, FromInner, IntoInner};
1012

11-
#[derive(Clone, Hash)]
12-
pub struct Buf {
13-
pub inner: Wtf8Buf,
13+
pub struct Buf<A: AllocRef = Global> {
14+
pub inner: Wtf8Buf<A>,
15+
}
16+
17+
#[stable(feature = "rust1", since = "1.0.0")]
18+
impl hash::Hash for Buf {
19+
#[inline]
20+
fn hash<H: hash::Hasher>(&self, state: &mut H) {
21+
self.inner.hash(state)
22+
}
23+
}
24+
25+
#[stable(feature = "rust1", since = "1.0.0")]
26+
impl Clone for Buf {
27+
#[inline]
28+
fn clone(&self) -> Self {
29+
Self { inner: self.inner.clone() }
30+
}
1431
}
1532

1633
impl IntoInner<Wtf8Buf> for Buf {

src/libstd/sys_common/wtf8.rs

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717

1818
use core::str::next_code_point;
1919

20+
use crate::alloc::{AllocRef, Global};
2021
use crate::borrow::Cow;
2122
use crate::char;
23+
use crate::cmp::Ordering;
2224
use crate::fmt;
2325
use crate::hash::{Hash, Hasher};
2426
use crate::iter::FromIterator;
@@ -110,9 +112,43 @@ impl CodePoint {
110112
///
111113
/// Similar to `String`, but can additionally contain surrogate code points
112114
/// if they’re not in a surrogate pair.
113-
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone)]
114-
pub struct Wtf8Buf {
115-
bytes: Vec<u8>,
115+
pub struct Wtf8Buf<A: AllocRef = Global> {
116+
bytes: Vec<u8, A>,
117+
}
118+
119+
#[stable(feature = "rust1", since = "1.0.0")]
120+
impl PartialEq for Wtf8Buf {
121+
#[inline]
122+
fn eq(&self, other: &Self) -> bool {
123+
self.bytes.eq(&other.bytes)
124+
}
125+
}
126+
127+
#[stable(feature = "rust1", since = "1.0.0")]
128+
impl Eq for Wtf8Buf {}
129+
130+
#[stable(feature = "rust1", since = "1.0.0")]
131+
impl PartialOrd for Wtf8Buf {
132+
#[inline]
133+
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
134+
self.bytes.partial_cmp(&other.bytes)
135+
}
136+
}
137+
138+
#[stable(feature = "rust1", since = "1.0.0")]
139+
impl Ord for Wtf8Buf {
140+
#[inline]
141+
fn cmp(&self, other: &Self) -> Ordering {
142+
self.bytes.cmp(&other.bytes)
143+
}
144+
}
145+
146+
#[stable(feature = "rust1", since = "1.0.0")]
147+
impl Clone for Wtf8Buf {
148+
#[inline]
149+
fn clone(&self) -> Self {
150+
Self { bytes: self.bytes.clone() }
151+
}
116152
}
117153

118154
impl ops::Deref for Wtf8Buf {

0 commit comments

Comments
 (0)