From ae3d684511c6535c6d4149be5b35fb23197c9988 Mon Sep 17 00:00:00 2001 From: Christian Sahar <125399153+saharct@users.noreply.github.com> Date: Tue, 13 Jun 2023 14:16:23 -0700 Subject: [PATCH 1/2] Add note that functions can return references --- developer-docs-site/docs/move/book/functions.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/developer-docs-site/docs/move/book/functions.md b/developer-docs-site/docs/move/book/functions.md index e95d533fff145..7f306b629bb0e 100644 --- a/developer-docs-site/docs/move/book/functions.md +++ b/developer-docs-site/docs/move/book/functions.md @@ -327,6 +327,10 @@ fun zero(): u64 { 0 } Here `: u64` indicates that the function's return type is `u64`. +:::tip +A function can return an immutable `&` or mutable `&mut` [reference](./references.md) if derived from an input reference. Keep in mind, this means that a function [cannot return a reference to global storage](./references.md#references-cannot-be-stored). +::: + Using tuples, a function can return multiple values: ```move From ecd0c5dea16b356354b069774e3b6a06d8bd7f09 Mon Sep 17 00:00:00 2001 From: Christian Sahar <125399153+saharct@users.noreply.github.com> Date: Wed, 14 Jun 2023 17:25:07 -0700 Subject: [PATCH 2/2] Mention that inline functions can return such references --- developer-docs-site/docs/move/book/functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/developer-docs-site/docs/move/book/functions.md b/developer-docs-site/docs/move/book/functions.md index 7f306b629bb0e..2e19ffd90b78c 100644 --- a/developer-docs-site/docs/move/book/functions.md +++ b/developer-docs-site/docs/move/book/functions.md @@ -328,7 +328,7 @@ fun zero(): u64 { 0 } Here `: u64` indicates that the function's return type is `u64`. :::tip -A function can return an immutable `&` or mutable `&mut` [reference](./references.md) if derived from an input reference. Keep in mind, this means that a function [cannot return a reference to global storage](./references.md#references-cannot-be-stored). +A function can return an immutable `&` or mutable `&mut` [reference](./references.md) if derived from an input reference. Keep in mind, this means that a function [cannot return a reference to global storage](./references.md#references-cannot-be-stored) unless it is an [inline function](#inline-functions). ::: Using tuples, a function can return multiple values: