-
-
-
// We can export tags without exporting the variants to create a simple
// sort of ADT.
+
mod foo {
- tag t { t1; }
- fn f() -> t { ret t1; }
+ export t;
+ export f;
+
+ tag t {
+ t1;
+ }
+
+ fn f() -> t {
+ ret t1;
+ }
}
-fn main() { let foo::t v = foo::f(); }
\ No newline at end of file
+fn main() {
+ let foo::t v = foo::f();
+}
+mod foo {
+ export bar;
-mod foo {
- mod bar {
- fn y() { x(); }
+ mod bar {
+ fn y() {
+ x();
}
- fn x() { log "x"; }
+ }
+
+ fn x() {
+ log "x";
+ }
}
-fn main() { foo::bar::y(); }
\ No newline at end of file
+fn main() {
+ foo::bar::y();
+}
-
-
mod foo {
- fn x() { bar::x(); }
+ export x;
+
+ fn x() {
+ bar::x();
+ }
}
mod bar {
- fn x() { log "x"; }
+ export x;
+
+ fn x() {
+ log "x";
+ }
}
-fn main() { foo::x(); }
\ No newline at end of file
+fn main() {
+ foo::x();
+}
-
-
-
// Export the tag variants, without the tag
+
mod foo {
- tag t { t1; }
+ export t1;
+ tag t {
+ t1;
+ }
}
-fn main() { auto v = foo::t1; }
\ No newline at end of file
+fn main() {
+ auto v = foo::t1;
+}
-
-
-
// This tests that exports can have visible dependencies on things
// that are not exported, allowing for a sort of poor-man's ADT
+
mod foo {
+ export f;
+ export g;
+
+ // not exported
+ tag t {
+ t1;
+ }
+
+ fn f() -> t {
+ ret t1;
+ }
- // not exported
- tag t { t1; }
- fn f() -> t { ret t1; }
- fn g(t v) { assert (v == t1); }
+ fn g(t v) {
+ assert v == t1;
+ }
}
-fn main() { foo::g(foo::f()); }
\ No newline at end of file
+fn main() {
+ foo::g(foo::f());
+}
\ No newline at end of file