Skip to content

Commit 7d95702

Browse files
committed
---
yaml --- r: 83504 b: refs/heads/try c: 2a9e763 h: refs/heads/master v: v3
1 parent 57527a7 commit 7d95702

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 0e4d1fc8cae42e15e00f71d9f439b01bb25a86ae
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6c08cc2db4f98e9f07ae7d50338396c4123c2f0a
5-
refs/heads/try: 0bdc99d81f038fe0e480eeb87b380b11b8e72ba7
5+
refs/heads/try: 2a9e7633043a79388fe3ed40c61a3961c2aedbcb
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libstd/c_str.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ impl CString {
152152
pub fn as_bytes<'a>(&'a self) -> &'a [u8] {
153153
if self.buf.is_null() { fail!("CString is null!"); }
154154
unsafe {
155-
let len = ptr::position(self.buf, |c| *c == 0);
156-
cast::transmute((self.buf, len + 1))
155+
cast::transmute((self.buf, self.len() + 1))
157156
}
158157
}
159158

@@ -187,6 +186,15 @@ impl Drop for CString {
187186
}
188187
}
189188

189+
impl Container for CString {
190+
#[inline]
191+
fn len(&self) -> uint {
192+
unsafe {
193+
ptr::position(self.buf, |c| *c == 0)
194+
}
195+
}
196+
}
197+
190198
/// A generic trait for converting a value to a CString.
191199
pub trait ToCStr {
192200
/// Copy the receiver into a CString.

0 commit comments

Comments
 (0)