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

chore: code dedup in felt from bigint #94

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ArniStarkware
Copy link

@ArniStarkware ArniStarkware commented Sep 19, 2024

This change is Reviewable

@ArniStarkware ArniStarkware force-pushed the arni/felt/code_dedup/from_big_int branch from 2894abd to 21ec015 Compare September 22, 2024 08:58
@ArniStarkware
Copy link
Author

crates/starknet-types-core/src/felt/mod.rs line 565 at r1 (raw file):

impl From<&BigInt> for Felt {
    fn from(bigint: &BigInt) -> Felt {
        let (sign, bytes) = bigint.to_bytes_le();

the method to_bytes_le gets a referance.

    pub fn to_bytes_le(&self) -> (Sign, Vec<u8>) {
        (self.sign, self.data.to_bytes_le())
    }

Code quote:

bigint.to_bytes_le()

Copy link
Author

@ArniStarkware ArniStarkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @dan-starkware and @pefontana)


crates/starknet-types-core/src/felt/mod.rs line 583 at r1 (raw file):

impl From<&BigUint> for Felt {
    fn from(biguint: &BigUint) -> Felt {
        Felt::from_bytes_le_slice(&biguint.to_bytes_le())

the method to_bytes_le gets a referance.

    pub fn to_bytes_le(&self) -> (Sign, Vec<u8>) {
        (self.sign, self.data.to_bytes_le())
    }

Code quote:

biguint.to_bytes_le()

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