Skip to content

Commit 1dc92d4

Browse files
ericktnikomatsakis
authored andcommitted
libcore: fix indention.
1 parent 5d56da1 commit 1dc92d4

File tree

1 file changed

+74
-74
lines changed

1 file changed

+74
-74
lines changed

src/libcore/str.rs

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1859,83 +1859,83 @@ mod unsafe {
18591859
/// Converts a byte to a string.
18601860
unsafe fn from_byte(u: u8) -> ~str { unsafe::from_bytes([u]) }
18611861

1862-
/**
1863-
* Takes a bytewise (not UTF-8) slice from a string.
1864-
*
1865-
* Returns the substring from [`begin`..`end`).
1866-
*
1867-
* # Failure
1868-
*
1869-
* If begin is greater than end.
1870-
* If end is greater than the length of the string.
1871-
*/
1872-
unsafe fn slice_bytes(s: &str, begin: uint, end: uint) -> ~str {
1873-
do as_buf(s) |sbuf, n| {
1874-
assert (begin <= end);
1875-
assert (end <= n);
1876-
1877-
let mut v = ~[];
1878-
vec::reserve(v, end - begin + 1u);
1879-
unsafe {
1880-
do vec::as_buf(v) |vbuf, _vlen| {
1881-
let src = ptr::offset(sbuf, begin);
1882-
ptr::memcpy(vbuf, src, end - begin);
1883-
}
1884-
vec::unsafe::set_len(v, end - begin);
1885-
vec::push(v, 0u8);
1886-
::unsafe::transmute(v)
1887-
}
1888-
}
1889-
}
1890-
1891-
/**
1892-
* Takes a bytewise (not UTF-8) view from a string.
1893-
*
1894-
* Returns the substring from [`begin`..`end`).
1895-
*
1896-
* # Failure
1897-
*
1898-
* If begin is greater than end.
1899-
* If end is greater than the length of the string.
1900-
*/
1901-
#[inline]
1902-
unsafe fn view_bytes(s: &str, begin: uint, end: uint) -> &str {
1903-
do as_buf(s) |sbuf, n| {
1862+
/**
1863+
* Takes a bytewise (not UTF-8) slice from a string.
1864+
*
1865+
* Returns the substring from [`begin`..`end`).
1866+
*
1867+
* # Failure
1868+
*
1869+
* If begin is greater than end.
1870+
* If end is greater than the length of the string.
1871+
*/
1872+
unsafe fn slice_bytes(s: &str, begin: uint, end: uint) -> ~str {
1873+
do as_buf(s) |sbuf, n| {
19041874
assert (begin <= end);
19051875
assert (end <= n);
19061876

1907-
let tuple = (ptr::offset(sbuf, begin), end - begin + 1);
1908-
::unsafe::reinterpret_cast(tuple)
1909-
}
1910-
}
1911-
1912-
/// Appends a byte to a string. (Not UTF-8 safe).
1913-
unsafe fn push_byte(&s: ~str, b: u8) {
1914-
rustrt::rust_str_push(s, b);
1915-
}
1916-
1917-
/// Appends a vector of bytes to a string. (Not UTF-8 safe).
1918-
unsafe fn push_bytes(&s: ~str, bytes: ~[u8]) {
1919-
for vec::each(bytes) |byte| { rustrt::rust_str_push(s, byte); }
1920-
}
1921-
1922-
/// Removes the last byte from a string and returns it. (Not UTF-8 safe).
1923-
unsafe fn pop_byte(&s: ~str) -> u8 {
1924-
let len = len(s);
1925-
assert (len > 0u);
1926-
let b = s[len - 1u];
1927-
unsafe { set_len(s, len - 1u) };
1928-
return b;
1929-
}
1930-
1931-
/// Removes the first byte from a string and returns it. (Not UTF-8 safe).
1932-
unsafe fn shift_byte(&s: ~str) -> u8 {
1933-
let len = len(s);
1934-
assert (len > 0u);
1935-
let b = s[0];
1936-
s = unsafe { unsafe::slice_bytes(s, 1u, len) };
1937-
return b;
1938-
}
1877+
let mut v = ~[];
1878+
vec::reserve(v, end - begin + 1u);
1879+
unsafe {
1880+
do vec::as_buf(v) |vbuf, _vlen| {
1881+
let src = ptr::offset(sbuf, begin);
1882+
ptr::memcpy(vbuf, src, end - begin);
1883+
}
1884+
vec::unsafe::set_len(v, end - begin);
1885+
vec::push(v, 0u8);
1886+
::unsafe::transmute(v)
1887+
}
1888+
}
1889+
}
1890+
1891+
/**
1892+
* Takes a bytewise (not UTF-8) view from a string.
1893+
*
1894+
* Returns the substring from [`begin`..`end`).
1895+
*
1896+
* # Failure
1897+
*
1898+
* If begin is greater than end.
1899+
* If end is greater than the length of the string.
1900+
*/
1901+
#[inline]
1902+
unsafe fn view_bytes(s: &str, begin: uint, end: uint) -> &str {
1903+
do as_buf(s) |sbuf, n| {
1904+
assert (begin <= end);
1905+
assert (end <= n);
1906+
1907+
let tuple = (ptr::offset(sbuf, begin), end - begin + 1);
1908+
::unsafe::reinterpret_cast(tuple)
1909+
}
1910+
}
1911+
1912+
/// Appends a byte to a string. (Not UTF-8 safe).
1913+
unsafe fn push_byte(&s: ~str, b: u8) {
1914+
rustrt::rust_str_push(s, b);
1915+
}
1916+
1917+
/// Appends a vector of bytes to a string. (Not UTF-8 safe).
1918+
unsafe fn push_bytes(&s: ~str, bytes: ~[u8]) {
1919+
for vec::each(bytes) |byte| { rustrt::rust_str_push(s, byte); }
1920+
}
1921+
1922+
/// Removes the last byte from a string and returns it. (Not UTF-8 safe).
1923+
unsafe fn pop_byte(&s: ~str) -> u8 {
1924+
let len = len(s);
1925+
assert (len > 0u);
1926+
let b = s[len - 1u];
1927+
unsafe { set_len(s, len - 1u) };
1928+
return b;
1929+
}
1930+
1931+
/// Removes the first byte from a string and returns it. (Not UTF-8 safe).
1932+
unsafe fn shift_byte(&s: ~str) -> u8 {
1933+
let len = len(s);
1934+
assert (len > 0u);
1935+
let b = s[0];
1936+
s = unsafe { unsafe::slice_bytes(s, 1u, len) };
1937+
return b;
1938+
}
19391939

19401940
/// Sets the length of the string and adds the null terminator
19411941
unsafe fn set_len(&v: ~str, new_len: uint) {

0 commit comments

Comments
 (0)