Блог пользователя yllo

Автор yllo, история, 11 месяцев назад, По-английски

Hi everyone!

I have a question about the language Rust.

Suppose, I've created some struct:

struct A {
  x: T,
  y: P,
  ....
}

When it goes out of the scope, Drop is called, memory is cleaned by recursive calls Drop? for all fields.

But what if I implement trait Drop for it:

impl Drop for A {
   fn drop(&mut self) -> () {
      // nothing
   }
}

will the memory be also cleaned when i create an object of type A and it goes out of scope? Or i need to clean it in some other way?

Sorry for my bad English(.

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится