Skip to content

Commit

Permalink
Derive more (#18)
Browse files Browse the repository at this point in the history
## Introduced changes

<!-- A brief description of the changes -->

- Add Display, Default, Ord, PartialOrd

## Checklist

<!-- Make sure all of these are complete -->

- [ ] Linked relevant issue
- [ ] Updated relevant documentation
- [ ] Added relevant tests
- [x] Performed self-review of the code
- [ ] Added changes to `CHANGELOG.md`
  • Loading branch information
ksew1 authored Oct 7, 2024
1 parent f42193f commit 35fb668
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 25 deletions.
34 changes: 13 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ cairo-lang-sierra-to-casm = "2.8.2"
cairo-lang-sierra = "2.8.2"
camino = { version = "1.1.9", features = ["serde1"] }
thiserror = "1.0.64"
derive_more = { version = "1.0.0", features = ["add", "add_assign", "mul", "mul_assign"] }
derive_more = { version = "1.0.0", features = ["add", "add_assign", "mul", "mul_assign", "display"] }
serde = { version = "1.0.195", features = ["derive"] }
serde_json = "1.0.128"
assert_fs = "1.1.2"
Expand Down
10 changes: 8 additions & 2 deletions crates/cairo-annotations/src/annotations/coverage.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::annotations::impl_helpers::impl_namespace;
use cairo_lang_sierra::program::StatementIdx;
use derive_more::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
use derive_more::{Add, AddAssign, Display, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::collections::HashMap;

Expand Down Expand Up @@ -38,7 +38,9 @@ pub struct CodeLocation(pub SourceFileFullPath, pub SourceCodeSpan);
/// May contain multiple Cairo virtual file markings if the code is generated by macros.
/// Like `/path/to/project/lib.cairo[array_inline_macro][assert_macro]`
/// where `array_inline_macro` and `assert_macro` is a virtual file marking.
#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
#[derive(
Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd, Serialize, Deserialize, Display, Default,
)]
pub struct SourceFileFullPath(pub String);

/// A span in a Cairo source file.
Expand Down Expand Up @@ -80,6 +82,8 @@ pub struct SourceCodeLocation {
MulAssign,
Div,
DivAssign,
Display,
Default,
)]
pub struct ColumnNumber(pub usize);

Expand All @@ -102,6 +106,8 @@ pub struct ColumnNumber(pub usize);
MulAssign,
Div,
DivAssign,
Display,
Default,
)]
pub struct LineNumber(pub usize);

Expand Down
5 changes: 4 additions & 1 deletion crates/cairo-annotations/src/annotations/profiler.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::annotations::impl_helpers::impl_namespace;
use cairo_lang_sierra::program::StatementIdx;
use derive_more::Display;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::collections::HashMap;

Expand Down Expand Up @@ -29,7 +30,9 @@ pub struct ProfilerAnnotationsV1 {
}

/// The fully qualified Cairo path of the Cairo function.
#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
#[derive(
Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd, Serialize, Deserialize, Display, Default,
)]
pub struct FunctionName(pub String);

// We can't use untagged enum here. See https://github.com/serde-rs/json/issues/1103
Expand Down

0 comments on commit 35fb668

Please sign in to comment.