maplit icon indicating copy to clipboard operation
maplit copied to clipboard

Add array! macro for non-copy types

Open Nokel81 opened this issue 4 years ago • 4 comments

Fixes: #32

Nokel81 avatar Mar 12 '20 15:03 Nokel81

This is unsound. Consider what happens if break is used as an expression. Also, this should be using $crate:: to avoid risk of referring to wrong std.

KamilaBorowska avatar Jan 25 '22 10:01 KamilaBorowska

Consider what happens if break is used as an expression.

There is no break, is there?

The only issue would be a potential panic! in the body of the loop and the already initialized elements not getting dropped, leading to a memory leak

oaleaf avatar Feb 12 '22 19:02 oaleaf

Consider what happens if break is used as an expression.

There is no break, is there?

The only issue would be a potential panic! in the body of the loop and the already initialized elements not getting dropped, leading to a memory leak

Well, the user could provide break as an expression, and that would escape the loop early.

KamilaBorowska avatar Feb 12 '22 22:02 KamilaBorowska

Oh I see what you mean now.

Maybe moving the expression to a variable outside the loop and cloning it for every element would be better in that regard?

oaleaf avatar Feb 13 '22 07:02 oaleaf