Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(serde_v8): support BigInt serialization #18225

Merged
merged 4 commits into from
Mar 16, 2023

Conversation

lucacasonato
Copy link
Member

This commit enables serializing v8::BigInt to num_bigint::BigInt
in Rust.

Pre-requisite for sub upcoming feature work.

This commit enables serializing `v8::BigInt` to `num_bigint::BigInt`
in Rust.
Copy link
Collaborator

@aapoalas aapoalas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Member

@littledivy littledivy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use i64?

let v8bigint = v8::Local::<v8::BigInt>::try_from(value)
.map_err(|_| Error::ExpectedBigInt)?;
let word_count = v8bigint.word_count();
let mut words = vec![0; word_count];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use SmallVec

@lucacasonato
Copy link
Member Author

Why not use i64?

@littledivy because we already support i64, and i64 is limited to fixed width 8 byte integers, and this specific thing is encoding a variable size integer. This could be a i65565 :D

@lucacasonato lucacasonato enabled auto-merge (squash) March 16, 2023 15:52
@lucacasonato lucacasonato merged commit b99c431 into denoland:main Mar 16, 2023
@lucacasonato lucacasonato deleted the serde_v8_bigint branch March 16, 2023 17:29
hardfist pushed a commit to hardfist/deno that referenced this pull request Aug 7, 2024
This commit enables serializing `v8::BigInt` to `num_bigint::BigInt`
in Rust.

Pre-requisite for sub upcoming feature work.
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.

3 participants