Reexport static methods on structs & enums.

This commit is contained in:
Tom Lee 2013-06-01 02:54:39 -07:00
parent 2bf053c0a3
commit f6fa5b91e2
5 changed files with 122 additions and 34 deletions

View file

@ -10,6 +10,8 @@
pub use sub_foo::Foo;
pub use Baz = self::Bar;
pub use sub_foo::Boz;
pub use sub_foo::Bort;
pub trait Bar {
pub fn bar() -> Self;
@ -28,4 +30,24 @@ pub mod sub_foo {
pub fn foo() -> int { 42 }
}
pub struct Boz {
unused_str: ~str
}
pub impl Boz {
pub fn boz(i: int) -> bool {
i > 0
}
}
pub enum Bort {
Bort1,
Bort2
}
pub impl Bort {
pub fn bort() -> ~str {
~"bort()"
}
}
}

View file

@ -9,13 +9,17 @@
// except according to those terms.
// xfail-fast
// aux-build:mod_trait_with_static_methods_lib.rs
extern mod mod_trait_with_static_methods_lib;
// aux-build:reexported_static_methods.rs
extern mod reexported_static_methods;
use mod_trait_with_static_methods_lib::Foo;
use mod_trait_with_static_methods_lib::Baz;
use reexported_static_methods::Foo;
use reexported_static_methods::Baz;
use reexported_static_methods::Boz;
use reexported_static_methods::Bort;
pub fn main() {
assert_eq!(42, Foo::foo());
assert_eq!(84, Baz::bar());
assert!(Boz::boz(1));
assert_eq!(~"bort()", Bort::bort());
}