From 80aec8581186804073c96fcc45b3e2611ba6fd5c Mon Sep 17 00:00:00 2001 From: Yan Chen <48968912+chenyan-dfinity@users.noreply.github.com> Date: Thu, 18 Jul 2024 09:40:12 -0700 Subject: [PATCH 1/3] add Nat.hash --- src/Nat.mo | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Nat.mo b/src/Nat.mo index caa3f90ed..1c2d1d65a 100644 --- a/src/Nat.mo +++ b/src/Nat.mo @@ -12,6 +12,7 @@ import Int "Int"; import Order "Order"; import Prim "mo:⛔"; import Char "Char"; +import Hash "Hash"; module { @@ -27,6 +28,9 @@ module { /// ``` public func toText(n : Nat) : Text = Int.toText n; + /// Computes a hash from the least significant 32-bits of `n`, ignoring other bits. + public func hash(n : Nat) : Hash.Hash = Int.hash n; + /// Creates a natural number from its textual representation. Returns `null` /// if the input is not a valid natural number. /// From ecf3451396bc08254a1210b3edb059c3643c56c3 Mon Sep 17 00:00:00 2001 From: Yan Chen <48968912+chenyan-dfinity@users.noreply.github.com> Date: Thu, 18 Jul 2024 09:58:38 -0700 Subject: [PATCH 2/3] fix --- src/Nat.mo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nat.mo b/src/Nat.mo index 1c2d1d65a..92761df01 100644 --- a/src/Nat.mo +++ b/src/Nat.mo @@ -26,10 +26,10 @@ module { /// ```motoko include=import /// Nat.toText 1234 // => "1234" /// ``` - public func toText(n : Nat) : Text = Int.toText n; + let toText : Nat -> Text = Int.toText; /// Computes a hash from the least significant 32-bits of `n`, ignoring other bits. - public func hash(n : Nat) : Hash.Hash = Int.hash n; + let hash : Nat -> Hash.Hash = Int.hash; /// Creates a natural number from its textual representation. Returns `null` /// if the input is not a valid natural number. From 03c484696fd047b2dee19fe2b2454f34826bb99a Mon Sep 17 00:00:00 2001 From: Yan Chen <48968912+chenyan-dfinity@users.noreply.github.com> Date: Thu, 18 Jul 2024 10:06:21 -0700 Subject: [PATCH 3/3] fix --- src/Nat.mo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nat.mo b/src/Nat.mo index 92761df01..b73774d81 100644 --- a/src/Nat.mo +++ b/src/Nat.mo @@ -26,10 +26,10 @@ module { /// ```motoko include=import /// Nat.toText 1234 // => "1234" /// ``` - let toText : Nat -> Text = Int.toText; + public let toText : Nat -> Text = Int.toText; /// Computes a hash from the least significant 32-bits of `n`, ignoring other bits. - let hash : Nat -> Hash.Hash = Int.hash; + public let hash : Nat -> Hash.Hash = Int.hash; /// Creates a natural number from its textual representation. Returns `null` /// if the input is not a valid natural number.