XO0510: use of a moved Buf, StrBuilder, or BytesBuilder
Buf[T], StrBuilder, and BytesBuilder are mutable in place and move only. freeze(), assigning, passing to a function, sending on a channel, or capturing in a spawned task moves the buffer, and the old name may not be used again (until it is reassigned). Finish all writes before moving, or start a new buffer. See core 5.3.
Example
fn f() -> List[Int] {
var b = Buf[Int].with_capacity(8)
b.push(1)
let xs = b.freeze()
b.push(2)
xs
}Fix
fn f() -> List[Int] {
var b = Buf[Int].with_capacity(8)
b.push(1)
b.push(2)
b.freeze()
}Run xo explain XO0510 for this text in a terminal, or see
section 10.6 of the specification.