Skip to content

Fix BasisPoint struct #23

@ArtiomTr

Description

@ArtiomTr

Basis point struct should not expose inner value:

 #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
-pub struct BasisPoint(pub u64);
+pub struct BasisPoint(u64);

As you're violating encapsulation, and struct becomes pointless. Also, probably get method can be replaced with Deref trait implementation, and will be easier to use.

For constants, you can create convenience method BasisPoint::new_unchecked:

-pub const PROPOSER_REORG_CUTOFF_BPS: BasisPoint = match BasisPoint::new(2_500) { Some(x) => x, None => panic!() };
+pub const PROPOSER_REORG_CUTOFF_BPS: BasisPoint = BasisPoint::new_unchecked(2_500);

Just make sure to not make it public.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions