From 2f39681f4115f6d094fb04a7529c290aecf1d392 Mon Sep 17 00:00:00 2001 From: Illia Sheshyn <187636533+illiasheshyn@users.noreply.github.com> Date: Sun, 9 Mar 2025 14:30:19 +1030 Subject: [PATCH 1/3] use `capacity` value for allocation Signed-off-by: Illia Sheshyn <187636533+illiasheshyn@users.noreply.github.com> --- mojo/docs/manual/lifecycle/life.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mojo/docs/manual/lifecycle/life.mdx b/mojo/docs/manual/lifecycle/life.mdx index dbdd5f11cd..eea19916be 100644 --- a/mojo/docs/manual/lifecycle/life.mdx +++ b/mojo/docs/manual/lifecycle/life.mdx @@ -451,7 +451,7 @@ struct HeapArray: fn __init__(out self, size: Int, val: Int): self.size = size self.cap = size * 2 - self.data = UnsafePointer[Int].alloc(self.size) + self.data = UnsafePointer[Int].alloc(self.cap) for i in range(self.size): (self.data + i).init_pointee_copy(val) From 6eea0317bd369a603754a154109ea0c567c15bf9 Mon Sep 17 00:00:00 2001 From: Illia Sheshyn <187636533+illiasheshyn@users.noreply.github.com> Date: Sun, 9 Mar 2025 14:32:08 +1030 Subject: [PATCH 2/3] now 3 cases mentioned Signed-off-by: Illia Sheshyn <187636533+illiasheshyn@users.noreply.github.com> --- mojo/docs/manual/lifecycle/life.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mojo/docs/manual/lifecycle/life.mdx b/mojo/docs/manual/lifecycle/life.mdx index eea19916be..e86ca646e8 100644 --- a/mojo/docs/manual/lifecycle/life.mdx +++ b/mojo/docs/manual/lifecycle/life.mdx @@ -158,7 +158,7 @@ can happen when one of the following occurs: - You return a value of one type from a function that specifies a different return type. -In both cases, implicit conversion is supported when the target type +In all cases, implicit conversion is supported when the target type defines a constructor that meets the following criteria: - Is declared with the `@implicit` decorator. From 03ea4df2d41586b2020b2ca601345e7c3c57bea2 Mon Sep 17 00:00:00 2001 From: Illia Sheshyn <187636533+illiasheshyn@users.noreply.github.com> Date: Sun, 9 Mar 2025 12:23:06 +0000 Subject: [PATCH 3/3] display `TODO` as note Signed-off-by: Illia Sheshyn <187636533+illiasheshyn@users.noreply.github.com> --- mojo/docs/manual/functions.mdx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mojo/docs/manual/functions.mdx b/mojo/docs/manual/functions.mdx index 81f1e4db09..0ed584b8c9 100644 --- a/mojo/docs/manual/functions.mdx +++ b/mojo/docs/manual/functions.mdx @@ -368,8 +368,13 @@ def greet(*names: String): Inside the function body, the variadic argument is available as an iterable list for ease of use. Currently there are some differences in handling the list depending on whether the arguments are register-passable types (such as `Int`) -or memory-only types (such as `String`). TODO: We hope to remove these -differences in the future. +or memory-only types (such as `String`). + +:::note TODO + +We hope to remove these differences in the future. + +::: Register-passable types, such as `Int`, are available as a [`VariadicList`](/mojo/stdlib/builtin/list_literal/VariadicList) type. As