We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 93432a2 commit 147c4fdCopy full SHA for 147c4fd
src/libstd/str.rs
@@ -878,7 +878,7 @@ pub mod raw {
878
let new_len = s.len() + 1;
879
s.reserve_at_least(new_len);
880
do s.as_mut_buf |buf, len| {
881
- *ptr::mut_offset(buf, len as int) = b;
+ *ptr::mut_offset(buf, (len-1) as int) = b;
882
}
883
set_len(&mut *s, new_len);
884
@@ -2801,6 +2801,13 @@ mod tests {
2801
assert!(!" _ ".is_whitespace());
2802
2803
2804
+ #[test]
2805
+ fn test_push_byte() {
2806
+ let mut s = ~"ABC";
2807
+ unsafe{raw::push_byte(&mut s, 'D' as u8)};
2808
+ assert_eq!(s, ~"ABCD");
2809
+ }
2810
+
2811
#[test]
2812
fn test_shift_byte() {
2813
let mut s = ~"ABC";
0 commit comments