From 2a9635b6f9b62ebeb985a133f1b34135698dfc28 Mon Sep 17 00:00:00 2001 From: gordon Date: Mon, 29 May 2023 21:13:18 +0100 Subject: [PATCH] add directions for using external types --- src/tour/external-types.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/tour/external-types.md b/src/tour/external-types.md index 166b3121..368f7d6d 100644 --- a/src/tour/external-types.md +++ b/src/tour/external-types.md @@ -17,3 +17,31 @@ pub external fn length(Queue(a)) -> Int = "queue" "len" pub external fn push(Queue(a), a) -> Queue(a) = "queue" "in" ``` + +When you need an external type you must use the `import` command to bring them into a module. + +There are two ways to refer to an external type. + +The first is an explicit named import: + +```rust,noplaypen +import mytypes.{MySpecialType} + +... + +fn myfun(x: MySpecialType) -> Int + +... +``` + +The second is a general import with name: + +```rust,noplaypen +import mytypes + +... + +fn myfun(x: mytypes.MySpecialType) -> Int + +... +```