Skip to content

Type Option.as_ref, borrow indexed slice items, type enum_variant payloads - #28

Merged
dannote merged 2 commits into
masterfrom
option-as-ref-typing
Oct 26, 2026
Merged

dannote merged 2 commits into
masterfrom
option-as-ref-typing

Conversation

@dannote

@dannote dannote commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Gaps found while writing kiwi_codec's generator in plain Elixir:

  • option.as_ref() synthesizes Option<&T>, also through &Option<T>.
  • index(slice, i) keeps the item's metadata, so index(fields, i).kind borrows where a reference is expected.
  • let x = index(slice, i) of an item that is not Copy borrows it (&slice[i]) instead of moving out of the index.
  • Bindings in enum_variant(Enum, :tag, value) patterns are typed, so a copy payload bound through a reference is dereferenced when passed by value.
  • Term.cached_struct_keys takes its keys as R.slice(R.str()), so a plain list literal is borrowed as a slice.

@dannote
dannote merged commit af156c7 into master Oct 26, 2026
2 checks passed
@dannote
dannote deleted the option-as-ref-typing branch October 26, 2026 22:58
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.

1 participant