destroy.carbon 520 B

12345678910111213141516
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. package Core library "prelude/destroy";
  5. // Object destruction, including running `fn destroy()`. Note this is distinct
  6. // from memory deallocation.
  7. interface Destroy {
  8. fn Op[self: Self]();
  9. }
  10. // Provide a default blanket impl for trivial destruction.
  11. impl forall [T:! type] T as Destroy {
  12. fn Op[self: Self]() = "no_op";
  13. }