(no title)
ynik | 1 year ago
// set self.vec length's to start, to be safe in case Drain is leaked
self.set_len(start);
You cannot rely on Drop alone for safety, you need a fallback strategy in case of a leak (mem::forget or Rc cycle).
Rust lifetimes only ensure that there is no use after free; there is no guarantee that Drop is called before the end of the lifetime. It's possible to mutably access the original Vec after leaking a Drain.
chriskrycho|1 year ago
nextaccountic|1 year ago