strings: builder: add clear (#14328)
parent
b04d46770b
commit
aef95721a4
|
@ -50,11 +50,9 @@ pub fn (mut b Builder) write_runes(runes []rune) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// write_b appends a single `data` byte to the accumulated buffer
|
// clear clears the buffer contents
|
||||||
[deprecated: 'Use write_u8() instead']
|
pub fn (mut b Builder) clear() {
|
||||||
[deprecated_after: '2022-02-11']
|
b = []u8{cap: b.cap}
|
||||||
pub fn (mut b Builder) write_b(data u8) {
|
|
||||||
b << data
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// write_u8 appends a single `data` byte to the accumulated buffer
|
// write_u8 appends a single `data` byte to the accumulated buffer
|
||||||
|
|
|
@ -18,13 +18,12 @@ pub fn new_builder(initial_size int) Builder {
|
||||||
return []u8{cap: initial_size}
|
return []u8{cap: initial_size}
|
||||||
}
|
}
|
||||||
|
|
||||||
[deprecated: 'Use write_u8() instead']
|
pub fn (mut b Builder) write_byte(data byte) {
|
||||||
pub fn (mut b Builder) write_b(data u8) {
|
|
||||||
b << data
|
b << data
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut b Builder) write_byte(data byte) {
|
pub fn (mut b Builder) clear() {
|
||||||
b << data
|
b = []u8{cap: b.cap}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut b Builder) write_u8(data u8) {
|
pub fn (mut b Builder) write_u8(data u8) {
|
||||||
|
|
|
@ -39,6 +39,9 @@ fn test_sb() {
|
||||||
assert last_2 == '56'
|
assert last_2 == '56'
|
||||||
final_sb := sb.str()
|
final_sb := sb.str()
|
||||||
assert final_sb == '1234'
|
assert final_sb == '1234'
|
||||||
|
|
||||||
|
sb.clear()
|
||||||
|
assert sb.str() == ''
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,8 @@ fn test_sb() {
|
||||||
final_sb := sb.str()
|
final_sb := sb.str()
|
||||||
assert final_sb == '1234'
|
assert final_sb == '1234'
|
||||||
//}
|
//}
|
||||||
|
sb.clear()
|
||||||
|
assert sb.str() == ''
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_big_sb() {
|
fn test_big_sb() {
|
||||||
|
|
Loading…
Reference in New Issue