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

Maintenance #14

Merged
merged 6 commits into from
Dec 26, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
updates:

# Create PRs for GitHub Actions updates
# src: https://github.com/marketplace/actions/build-and-push-docker-images#keep-up-to-date-with-github-dependabot
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"

# Note: Rust dependencies are not handled here. For those
# dependencies, we want Dependabot only for security updates, which is
# already enabled through GitHub repository settings.
47 changes: 15 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
on:
push:
branches:
- main
pull_request:
schedule:
- cron: '30 3 * * 2'

Expand All @@ -12,62 +15,42 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rust: [1.34.0, stable]
rust: [1.74.1, stable]
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
override: true
- name: Run check
uses: actions-rs/cargo@v1
with:
command: check
args: --all-features
- name: Run tests through tarpaulin
uses: actions-rs/tarpaulin@v0.1
with:
args: --ignore-tests
- run: cargo check --all-features

ensure_no_std:
name: Ensure no_std
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: dtolnay/rust-toolchain@stable
- name: Download cargo-nono
run: |
wget https://github.com/hobofan/cargo-nono/releases/download/0.1.8/cargo-nono-0.1.8-x86_64-unknown-linux-gnu.tar.gz \
&& tar xfvz cargo-nono-0.1.8-x86_64-unknown-linux-gnu.tar.gz
- name: Run check
run: ./cargo-nono check
wget https://github.com/hobofan/cargo-nono/releases/download/0.1.9/cargo-nono-0.1.9-x86_64-unknown-linux-gnu.tar.gz \
&& tar xfvz cargo-nono-0.1.9-x86_64-unknown-linux-gnu.tar.gz
- run: ./cargo-nono check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
override: true
- uses: actions-rs/clippy-check@v1
- uses: dtolnay/rust-toolchain@1.74.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features
components: clippy
- run: cargo clippy --all-features -- -D warnings

rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt
override: true
components: rustfmt
- run: cargo fmt -- --check
8 changes: 4 additions & 4 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl Humidity {
return Err(HumidityError::OutOfRange);
}

let integer = if val >= 256.0 || val < 0.0 {
let integer = if !(0.0..256.0).contains(&val) {
return Err(HumidityError::OutOfRange);
} else {
val.trunc() as u8
Expand All @@ -103,10 +103,10 @@ impl Humidity {
}
}

impl Into<f32> for Humidity {
impl From<Humidity> for f32 {
/// Convert a `Humidity` instance to a f32.
fn into(self) -> f32 {
f32::from(self.integer) + (f32::from(self.fractional) / 256.0)
fn from(val: Humidity) -> Self {
f32::from(val.integer) + (f32::from(val.fractional) / 256.0)
}
}

Expand Down