Skip to content

encoding.base32: fix warning of implicit clone of array by declaring unsafe - #21728

Merged
spytheman merged 1 commit into
vlang:masterfrom
mike-ward:fix_base32_warning
Jun 25, 2024
Merged

spytheman merged 1 commit into
vlang:masterfrom
mike-ward:fix_base32_warning

Conversation

@mike-ward

Copy link
Copy Markdown
Contributor

Received the following warning when importing encoding.base32

v run base32_test.v
/Users/mike/Documents/github/v/vlib/encoding/base32/base32.v:289:13: notice: an implicit clone of the slice was done here
  287 |             }
  288 |             in0 := src[0]
  289 |             src = src[1..]
      |                      ~~~~~
  290 |             if in0 == enc.padding_char && j >= 2 && src.len < 8 {
  291 |                 // We`ve reached the end and there`s padding
Details: /Users/mike/Documents/github/v/vlib/encoding/base32/base32.v:289:13: details: To silence this notice, use either an explicit `a[..].clone()`,
or use an explicit `unsafe{ a[..] }`, if you do not want a copy of the slice.
  287 |             }
  288 |             in0 := src[0]
  289 |             src = src[1..]
      |                      ~~~~~
  290 |             if in0 == enc.padding_char && j >= 2 && src.len < 8 {
  291 |                 // We`ve reached the end and there`s padding

This PR uses an explicit unsafe to suppress the warning.

@spytheman
spytheman merged commit e1d2342 into vlang:master Jun 25, 2024
raw-bin pushed a commit to raw-bin/v that referenced this pull request Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants