Skip to content

feat: implement bytes type#177

Open
thesayyn wants to merge 1 commit intofacebook:mainfrom
thesayyn:bytes_type
Open

feat: implement bytes type#177
thesayyn wants to merge 1 commit intofacebook:mainfrom
thesayyn:bytes_type

Conversation

@thesayyn
Copy link
Copy Markdown

@thesayyn thesayyn commented Mar 8, 2026

  • Value::to_str() now calls collect_str() instead of falling back to to_repr(), so print(b"hello")
    outputs hello instead of b"hello"
  • ord() accepts 1-byte bytes per spec — ord(b"A") == 65; returns the byte value as an integer
  • StarlarkBytes is now part of the public API — starlark::values::bytes::StarlarkBytes is accessible to
    downstream crates
  • AllocValue/AllocFrozenValue impls for &[u8] and Vec — heap.alloc(b"hi" as &[u8]) and
    heap.alloc(vec![1u8, 2]) now work directly
  • StarlarkBytes::from_vec() constructor converts Vec to Box<[u8]> in-place, eliminating a redundant
    copy in add, mul, slice, and bytes()
  • Duplicate bytes key detection in the linter — {b"a": 1, b"a": 2} now raises a duplicate-key warning

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 8, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented Mar 8, 2026

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this in D95696965. (Because this pull request was imported automatically, there will not be any future comments.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant