File tree Expand file tree Collapse file tree 1 file changed +29
-4
lines changed Expand file tree Collapse file tree 1 file changed +29
-4
lines changed Original file line number Diff line number Diff line change 11import std::Error::ValueError as ValueError;
22
3+ ffi "c++" import "source_location";
4+
35interface BasicI {
46 fn op==(self, other: i32) -> bool;
57}
68
9+ /* we need to add the following to every function def const loc: libcxx::source_location = libcxx::source_location::current() along with */
10+ fn other_foo() -> i32 {
11+ panic std::Error::NullValueError("This is a value error");
12+ return 42;
13+ }
14+
715struct Basic {
816 var count: i32 = 109;
917
1018 fn op == (self, other: i32) -> bool {
19+
20+ var val = other_foo();
21+ std::print(f"Value: {val}");
22+
1123 return self.count == other;
1224 }
1325}
1426
1527
16- fn <T> new_function() -> T? requires T impl BasicI {
17- panic ValueError::ValueError("This is a test error message");
28+ fn <T impl BasicI, U impl BasicI> new_function() -> T? {
29+
30+ panic ValueError::ValueError("This is a value error");
31+
1832 return T();
1933}
2034
2135
36+ class Foo {
37+ fn something() -> i32 {
38+ return 42;
39+ }
40+
41+ }
42+
2243
2344fn main() -> i32 {
24- var call = new_function::<Basic>();
45+ var call = new_function::<Basic, Basic >();
2546
2647 std::print(f"Count: {(*call).count}");
2748
28-
49+ var obj = Foo();
50+ obj.something();
51+
52+ var eq = (*call) == 109;
53+ std::print(f"Equal: {eq}");
2954
3055 return 0;
3156}
You can’t perform that action at this time.
0 commit comments