left_shift.carbon 483 B

123456789101112131415161718192021
  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. //
  5. // AUTOUPDATE
  6. package ExplorerTest api;
  7. class A { var n: i32; }
  8. impl A as LeftShiftWith(i32) where .Result = A {
  9. fn Op[self: Self](rhs: i32) -> A { return {.n = self.n << rhs}; }
  10. }
  11. fn Main() -> i32 {
  12. var a: A = {.n = 5};
  13. a = a << 1;
  14. return a.n;
  15. }
  16. // CHECK:STDOUT: result: 10