Skip to content

Commit 0dc88d0

Browse files
authored
Add CI workflow and fix discovered issues. (#7)
1 parent ab1a2a9 commit 0dc88d0

File tree

4 files changed

+56
-3
lines changed

4 files changed

+56
-3
lines changed

.github/workflows/ci.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: ci
2+
on: [push, pull_request]
3+
jobs:
4+
test:
5+
name: test
6+
runs-on: ${{ matrix.os }}
7+
strategy:
8+
matrix:
9+
os: [ubuntu-latest, windows-latest, macOS-latest]
10+
rust: [1.56.1, stable, beta, nightly]
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v1
14+
- name: Install Rust
15+
uses: hecrj/setup-rust-action@v1
16+
with:
17+
rust-version: ${{ matrix.rust }}
18+
19+
# Because of all the features, we run build and test twice -- once with
20+
# full features and once without any features at all -- to make it more
21+
# likely that everything works.
22+
23+
# Clippy.
24+
#
25+
# Only do this once with all features enabled.
26+
# Only do Clippy on stable for the moment, due to
27+
# clippy::unknown_clippy_lints being removed.
28+
- if: matrix.rust == 'stable'
29+
run: rustup component add clippy
30+
- if: matrix.rust == 'stable'
31+
run: cargo clippy --all --all-features -- -D warnings
32+
33+
# Build
34+
- run: cargo build --verbose --all --all-features
35+
- run: cargo build --verbose --all
36+
37+
# Test
38+
- run: cargo test --verbose --all --all-features
39+

src/str.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ impl<Octets> Str<Octets> {
2929
}
3030

3131
/// Converts a sequence of octets into a string without checking.
32+
///
33+
/// # Safety
34+
///
35+
/// The caller must make sure that the contents of `octets` is a
36+
/// correctly encoded UTF-8 string.
3237
pub unsafe fn from_utf8_unchecked(octets: Octets) -> Self {
3338
Self(octets)
3439
}
@@ -264,7 +269,7 @@ impl<Octets> StrBuilder<Octets> {
264269
Some(len) => &octets[err.valid_up_to() + len ..],
265270
None => b""
266271
};
267-
err = match str::from_utf8(octets.as_ref()) {
272+
err = match str::from_utf8(octets) {
268273
Ok(_) => {
269274
res.try_append_slice(octets)?;
270275
break;
@@ -411,6 +416,15 @@ impl<Octets> StrBuilder<Octets> {
411416
}
412417

413418

419+
//-- Default
420+
421+
impl<Octets: EmptyBuilder> Default for StrBuilder<Octets> {
422+
fn default() -> Self {
423+
Self::new()
424+
}
425+
}
426+
427+
414428
//--- Deref, DerefMut, AsRef, AsMut, Borrow, BorrowMut
415429

416430
impl<Octets: AsRef<[u8]>> ops::Deref for StrBuilder<Octets> {

src/traits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
//! could be defined like so:
4545
//!
4646
//! ```
47-
//! # use octets::OctetsRef;
47+
//! # use octseq::OctetsRef;
4848
//!
4949
//! fn take_part<'a, Octets>(
5050
//! src: &'a Octets

src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl<const N: usize> FromBuilder for Array<N> {
182182

183183
//--- OctetsFrom
184184

185-
impl<const N: usize, Source: AsRef<[u8]>> OctetsFrom<Source> for Array<N> {
185+
impl<Source: AsRef<[u8]>, const N: usize> OctetsFrom<Source> for Array<N> {
186186
type Error = ShortBuf;
187187

188188
fn try_octets_from(source: Source) -> Result<Self, Self::Error> {

0 commit comments

Comments
 (0)