Skip to content

feat: implement bytes type#177

Closed
thesayyn wants to merge 1 commit into
facebook:mainfrom
thesayyn:bytes_type
Closed

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

Conversation

@thesayyn

@thesayyn thesayyn commented Mar 8, 2026

Copy link
Copy Markdown
Contributor
  • 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

meta-codesync Bot commented Mar 8, 2026

Copy link
Copy Markdown

@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.)

@thesayyn thesayyn mentioned this pull request Mar 8, 2026
@ndmitchell ndmitchell self-assigned this May 18, 2026
@ndmitchell

Copy link
Copy Markdown
Contributor

Thanks! I landed this as 10c5862 and 69593bb. Really high quality diff! Very nice work.

@ndmitchell ndmitchell closed this May 19, 2026
@thesayyn

Copy link
Copy Markdown
Contributor Author

thank you

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.

2 participants