Update docs for import/export

This commit is contained in:
Brian Anderson 2011-08-17 11:33:34 -07:00
parent 0d83956e2b
commit 556de425b3

View File

@ -1757,12 +1757,19 @@ path required to refer to a module item.
dependencies are independently declared with @code{use} dependencies are independently declared with @code{use}
declarations. @xref{Ref.Comp.Crate}. declarations. @xref{Ref.Comp.Crate}.
An example of an import: An example of imports:
@example @example
import std::math::sin; import std::math::sin;
import std::option::*;
import std::str::@{char_at, hash@};
fn main() @{ fn main() @{
// Equivalent to 'log std::math::sin(1.0);' // Equivalent to 'log std::math::sin(1.0);'
log sin(1.0); log sin(1.0);
// Equivalent to 'log std::option::some(1.0);'
log some(1.0);
// Equivalent to 'log std::str::hash(std::str::char_at("foo"));'
log hash(char_at("foo"));
@} @}
@end example @end example
@ -1800,6 +1807,27 @@ fn main() @{
@} @}
@end example @end example
Multiple items may be exported from a single export declaration:
@example
mod foo @{
export primary, secondary;
fn primary() @{
helper(1, 2);
helper(3, 4);
@}
fn secondary() @{
@dots{}
@}
fn helper(x: int, y: int) @{
@dots{}
@}
@}
@end example
@node Ref.Item.Fn @node Ref.Item.Fn
@subsection Ref.Item.Fn @subsection Ref.Item.Fn