Skip to content

Commit 34806b8

Browse files
authored
Merge pull request #14 from sile/2024-edition
Update Rust edition to 2024 and modernize CI workflows
2 parents 2bf6a37 + 1de63cf commit 34806b8

File tree

7 files changed

+64
-27
lines changed

7 files changed

+64
-27
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: CI
22

3-
on: [push, pull_request]
3+
on: [push]
44

55
jobs:
66
check:
@@ -11,9 +11,9 @@ jobs:
1111
toolchain: [stable, beta, nightly]
1212
steps:
1313
- name: Checkout sources
14-
uses: actions/checkout@v4
14+
uses: actions/checkout@v5
1515
- run: rustup update ${{ matrix.toolchain }}
16-
- run: cargo check --all-features
16+
- run: cargo check --all
1717

1818
test:
1919
name: Test Suite
@@ -23,9 +23,9 @@ jobs:
2323
toolchain: [stable, beta, nightly]
2424
steps:
2525
- name: Checkout sources
26-
uses: actions/checkout@v4
26+
uses: actions/checkout@v5
2727
- run: rustup update ${{ matrix.toolchain }}
28-
- run: cargo test --all-features
28+
- run: cargo test --all
2929

3030
lints:
3131
name: Lints
@@ -35,7 +35,7 @@ jobs:
3535
toolchain: [stable, beta, nightly]
3636
steps:
3737
- name: Checkout sources
38-
uses: actions/checkout@v4
38+
uses: actions/checkout@v5
3939
- run: rustup update ${{ matrix.toolchain }}
40-
- run: cargo fmt -- --check
41-
- run: cargo clippy --all-features -- -D warnings
40+
- run: cargo fmt --all -- --check
41+
- run: cargo clippy --all -- -D warnings

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Create GitHub Release and Publish to crates.io
2+
3+
on:
4+
push:
5+
tags: ['v*']
6+
7+
jobs:
8+
github-release:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
steps:
13+
- uses: actions/checkout@v5
14+
15+
- id: create-release
16+
run: gh release create ${{ github.ref_name }} --title "${{ github.ref_name }}" --generate-notes
17+
env:
18+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
20+
publish:
21+
runs-on: ubuntu-latest
22+
# environment: release # Optional: for enhanced security
23+
permissions:
24+
id-token: write
25+
steps:
26+
- uses: actions/checkout@v5
27+
- uses: rust-lang/crates-io-auth-action@v1
28+
id: auth
29+
- run: cargo publish
30+
env:
31+
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repository = "https://github.com/sile/eetf"
99
readme = "README.md"
1010
keywords = ["erlang"]
1111
license = "MIT"
12-
edition = "2021"
12+
edition = "2024"
1313

1414
[dependencies]
1515
byteorder = "1"

src/codec.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ mod aux {
810810
Err(io::Error::new(io::ErrorKind::InvalidData, message))
811811
}
812812
pub fn other_error<T>(message: String) -> io::Result<T> {
813-
Err(io::Error::new(io::ErrorKind::Other, message))
813+
Err(io::Error::other(message))
814814
}
815815
pub fn latin1_bytes_to_string(buf: &[u8]) -> io::Result<String> {
816816
// FIXME: Supports Latin1 characters
@@ -826,10 +826,6 @@ mod aux {
826826
}
827827
}
828828
pub fn sign_to_byte(sign: Sign) -> u8 {
829-
if sign == Sign::Minus {
830-
1
831-
} else {
832-
0
833-
}
829+
if sign == Sign::Minus { 1 } else { 0 }
834830
}
835831
}

src/convert.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,7 @@ pub trait AsOption {
9696
}
9797
impl AsOption for bool {
9898
fn as_option(&self) -> Option<&Self> {
99-
if *self {
100-
Some(self)
101-
} else {
102-
None
103-
}
99+
if *self { Some(self) } else { None }
104100
}
105101
}
106102

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,8 +852,8 @@ impl From<HashMap<String, Term>> for Map {
852852
#[cfg(test)]
853853
mod tests {
854854
use super::*;
855-
use crate::pattern::any;
856855
use crate::pattern::U8;
856+
use crate::pattern::any;
857857

858858
#[test]
859859
fn it_works() {

tests/lib.rs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,9 @@ fn reference_test() {
230230

231231
// Encode
232232
assert_eq!(
233-
vec![131, 90, 0, 1, 100, 0, 3, 102, 111, 111, 0, 0, 0, 0, 0, 0, 0, 123],
233+
vec![
234+
131, 90, 0, 1, 100, 0, 3, 102, 111, 111, 0, 0, 0, 0, 0, 0, 0, 123
235+
],
234236
encode(Term::from(Reference::from(("foo", 123))))
235237
);
236238
}
@@ -246,12 +248,17 @@ fn external_fun_test() {
246248
// Decode
247249
assert_eq!(
248250
Ok(ExternalFun::from(("foo", "bar", 3))),
249-
decode(&[131, 113, 100, 0, 3, 102, 111, 111, 100, 0, 3, 98, 97, 114, 97, 3]).try_into()
251+
decode(&[
252+
131, 113, 100, 0, 3, 102, 111, 111, 100, 0, 3, 98, 97, 114, 97, 3
253+
])
254+
.try_into()
250255
);
251256

252257
// Encode
253258
assert_eq!(
254-
vec![131, 113, 100, 0, 3, 102, 111, 111, 100, 0, 3, 98, 97, 114, 97, 3],
259+
vec![
260+
131, 113, 100, 0, 3, 102, 111, 111, 100, 0, 3, 98, 97, 114, 97, 3
261+
],
255262
encode(Term::from(ExternalFun::from(("foo", "bar", 3))))
256263
);
257264
}
@@ -461,15 +468,22 @@ fn map_test() {
461468
// Decode
462469
assert_eq!(
463470
Ok(map.clone()),
464-
decode(&[131, 116, 0, 0, 0, 2, 97, 1, 97, 2, 100, 0, 1, 97, 100, 0, 1, 98]).try_into()
471+
decode(&[
472+
131, 116, 0, 0, 0, 2, 97, 1, 97, 2, 100, 0, 1, 97, 100, 0, 1, 98
473+
])
474+
.try_into()
465475
);
466476

467477
// Encode
468478
let buf = encode(Term::from(map.clone()));
469479
// Hashmap Iter is not deterministic, so we need to check both possible outputs
470480
assert!(
471-
[131, 116, 0, 0, 0, 2, 97, 1, 97, 2, 100, 0, 1, 97, 100, 0, 1, 98] == buf.as_slice()
472-
|| [131, 116, 0, 0, 0, 2, 100, 0, 1, 97, 100, 0, 1, 98, 97, 1, 97, 2] == buf.as_slice()
481+
[
482+
131, 116, 0, 0, 0, 2, 97, 1, 97, 2, 100, 0, 1, 97, 100, 0, 1, 98
483+
] == buf.as_slice()
484+
|| [
485+
131, 116, 0, 0, 0, 2, 100, 0, 1, 97, 100, 0, 1, 98, 97, 1, 97, 2
486+
] == buf.as_slice()
473487
);
474488

475489
//Access

0 commit comments

Comments
 (0)