File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 2
2
refs/heads/master: 0e4d1fc8cae42e15e00f71d9f439b01bb25a86ae
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: 6c08cc2db4f98e9f07ae7d50338396c4123c2f0a
5
- refs/heads/try: 0bdc99d81f038fe0e480eeb87b380b11b8e72ba7
5
+ refs/heads/try: 2a9e7633043a79388fe3ed40c61a3961c2aedbcb
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8
8
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
Original file line number Diff line number Diff line change @@ -152,8 +152,7 @@ impl CString {
152
152
pub fn as_bytes < ' a > ( & ' a self ) -> & ' a [ u8 ] {
153
153
if self . buf . is_null ( ) { fail ! ( "CString is null!" ) ; }
154
154
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 ) )
157
156
}
158
157
}
159
158
@@ -187,6 +186,15 @@ impl Drop for CString {
187
186
}
188
187
}
189
188
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
+
190
198
/// A generic trait for converting a value to a CString.
191
199
pub trait ToCStr {
192
200
/// Copy the receiver into a CString.
You can’t perform that action at this time.
0 commit comments