From 762036963cbc92b21a05e14394114c017f147250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Gonz=C3=A1lez=20Palomo?= Date: Fri, 26 Mar 2021 18:50:29 +0100 Subject: [PATCH] doc: Add a note on how to define type aliases. (#9466) --- doc/docs.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/docs.md b/doc/docs.md index fbcce791a5..f2d468c197 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -86,10 +86,10 @@ For more details and troubleshooting, please visit the [vab GitHub repository](h * [Short struct literal syntax](#short-struct-initialization-syntax) * [Access modifiers](#access-modifiers) * [Methods](#methods) +* [Unions](#unions) -* [Unions](#unions) * [Functions 2](#functions-2) * [Pure functions by default](#pure-functions-by-default) * [Mutable arguments](#mutable-arguments) @@ -104,6 +104,7 @@ For more details and troubleshooting, please visit the [vab GitHub repository](h * [Interfaces](#interfaces) * [Enums](#enums) * [Sum types](#sum-types) + * [Type aliases](#type-aliases) * [Option/Result types & error handling](#optionresult-types-and-error-handling) * [Generics](#generics) * [Concurrency](#concurrency) @@ -2365,6 +2366,12 @@ fn pass_time(w World) { } ``` +### Type aliases + +To define a new type `NewType` as an alias for `ExistingType`, +do `type NewType = ExistingType`.
+This is a special case of a [sum type](#sum-types) declaration. + ### Option/Result types and error handling Option types are declared with `?Type`: