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

Make improvements to the CI #54

Merged
merged 1 commit into from Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Expand Up @@ -2,7 +2,7 @@ name: CI

on:
push:
branches: [master]
branches: [main]
pull_request:
merge_group:
types: [checks_requested]
Expand All @@ -17,13 +17,13 @@ jobs:
toolchain: stable
override: true
profile: minimal
- name: Check Formatting
run: cargo fmt --check
- name: Test
run: cargo test

- name: Serde check
- name: Check (`--features="serde_serialization"`)
run: cargo check --features="serde_serialization"

- name: Num traits check
- name: Check (`--features="num_traits"`)
run: cargo check --features="num_traits"

build_result:
Expand Down
16 changes: 9 additions & 7 deletions src/app_unit.rs
Expand Up @@ -5,21 +5,24 @@
#[cfg(feature = "num_traits")]
use num_traits::Zero;
#[cfg(feature = "serde_serialization")]
use serde::{Serialize, Deserialize, Deserializer};
use serde::{Deserialize, Deserializer, Serialize};

use std::{fmt, i32, default::Default, ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, Sub, SubAssign}};
use std::iter::Sum;
use std::{
default::Default,
fmt, i32,
ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, Sub, SubAssign},
};

/// The number of app units in a pixel.
pub const AU_PER_PX: i32 = 60;
/// The minimum number of app units, same as in Gecko.
pub const MIN_AU: Au = Au(- ((1 << 30) - 1));
pub const MIN_AU: Au = Au(-((1 << 30) - 1));
/// The maximum number of app units, same as in Gecko.
///
///
/// (1 << 30) - 1 lets us add/subtract two Au and check for overflow after the operation.
pub const MAX_AU: Au = Au((1 << 30) - 1);


#[repr(transparent)]
#[derive(Clone, Copy, Hash, PartialEq, PartialOrd, Eq, Ord, Default)]
#[cfg_attr(feature = "serde_serialization", derive(Serialize), serde(transparent))]
Expand Down Expand Up @@ -73,7 +76,6 @@ impl Sub for Au {
fn sub(self, other: Au) -> Au {
Au(self.0 - other.0).clamp()
}

}

impl Mul<Au> for i32 {
Expand Down Expand Up @@ -391,7 +393,7 @@ fn convert() {
assert_eq!(Au::from_f64_px(6.13), Au(368));
}

#[cfg(feature ="serde_serialization")]
#[cfg(feature = "serde_serialization")]
#[test]
fn serialize() {
let serialized = ron::to_string(&Au(42)).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Expand Up @@ -8,4 +8,4 @@

mod app_unit;

pub use app_unit::{Au, MIN_AU, MAX_AU, AU_PER_PX};
pub use app_unit::{Au, AU_PER_PX, MAX_AU, MIN_AU};