File tree Expand file tree Collapse file tree 2 files changed +9
-10
lines changed Expand file tree Collapse file tree 2 files changed +9
-10
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: d0d68c6036275c0a190ad100d6eb36a537b76d80
2
+ refs/heads/master: e3f5403052e53b557998315fae780b5431a8ce0b
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
5
5
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be
Original file line number Diff line number Diff line change @@ -1967,10 +1967,10 @@ mod raw {
1967
1967
export
1968
1968
from_buf,
1969
1969
from_buf_len,
1970
- from_buf_len_nocopy,
1971
1970
from_c_str,
1972
1971
from_c_str_len,
1973
1972
from_bytes,
1973
+ form_slice,
1974
1974
slice_bytes,
1975
1975
view_bytes,
1976
1976
push_byte,
@@ -2003,14 +2003,6 @@ mod raw {
2003
2003
return :: unsafe:: transmute ( move v) ;
2004
2004
}
2005
2005
2006
- /// Create a Rust string from a *u8 buffer of the given length
2007
- /// without copying
2008
- unsafe fn from_buf_len_nocopy ( buf : & a / * u8 , len : uint ) -> & a / str {
2009
- let v = ( * buf, len + 1 ) ;
2010
- assert is_utf8( :: unsafe:: reinterpret_cast ( & v) ) ;
2011
- return :: unsafe:: transmute ( move v) ;
2012
- }
2013
-
2014
2006
/// Create a Rust string from a null-terminated C string
2015
2007
unsafe fn from_c_str ( c_str : * libc:: c_char ) -> ~str {
2016
2008
from_buf ( :: unsafe:: reinterpret_cast ( & c_str) )
@@ -2031,6 +2023,13 @@ mod raw {
2031
2023
/// Converts a byte to a string.
2032
2024
unsafe fn from_byte ( u : u8 ) -> ~str { raw:: from_bytes ( [ u] ) }
2033
2025
2026
+ /// Form a slice from a *u8 buffer of the given length without copying.
2027
+ unsafe fn buf_as_slice < T > ( buf : * u8 , len : uint , f : fn ( & & & str ) -> T ) -> T {
2028
+ let v = ( * buf, len + 1 ) ;
2029
+ assert is_utf8( :: unsafe:: reinterpret_cast ( & v) ) ;
2030
+ f ( :: unsafe:: transmute ( move v) )
2031
+ }
2032
+
2034
2033
/**
2035
2034
* Takes a bytewise (not UTF-8) slice from a string.
2036
2035
*
You can’t perform that action at this time.
0 commit comments