Skip to content

Commit

Permalink
Make improvements to the CI (#54)
Browse files Browse the repository at this point in the history
- Switch the default branch to "main"
- Run `cargo fmt --check` during CI
- Format the source code
- Improve job names
  • Loading branch information
mrobinson committed Feb 1, 2024
1 parent f9e0504 commit a5bf3ba
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
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};

0 comments on commit a5bf3ba

Please sign in to comment.