Skip to content
This repository was archived by the owner on Oct 23, 2022. It is now read-only.

Commit 8b7011f

Browse files
committed
chore(unixfs): clippies
this includes a change on making `unixfs::InvalidCidInLink` properly `#[non_exhaustive]` instead of using the hidden field trick. it probably isn't a breaking change, but then again requires a more recent rustc, which sort of makes it a breaking change.
1 parent 1b3842c commit 8b7011f

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

unixfs/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Next
22

33
* Document panic introduced in walker ergonomics [#435]
4+
* `#[non_exhaustive]` on `unixfs::InvalidCidInLink` error [#480]
45

56
[#435]: https://github.com/rs-ipfs/rust-ipfs/pull/435
7+
[#480]: https://github.com/rs-ipfs/rust-ipfs/pull/480
68

79
# 0.2.0
810

unixfs/src/dir/builder/custom_pb.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ impl<'a> CustomFlatUnixFs<'a> {
1515
fn mapped(&self) -> impl Iterator<Item = NamedLeafAsPBLink<'_>> + '_ {
1616
self.links
1717
.iter()
18-
.map(|triple| triple.as_ref().map(|l| NamedLeafAsPBLink(l)).unwrap())
18+
// FIXME: this unwrap here seems dangerious; it seems to follow from
19+
// `crate::dir::builder::iter::Leaves` assumption that all of these options have
20+
// already been filled at the previous stages of post-order visit
21+
.map(|triple| triple.as_ref().map(NamedLeafAsPBLink).unwrap())
1922
}
2023
}
2124

unixfs/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub(crate) mod test_support;
3737

3838
/// A link could not be transformed into a Cid.
3939
#[derive(Debug)]
40+
#[non_exhaustive]
4041
pub struct InvalidCidInLink {
4142
/// The index of this link, from zero
4243
pub nth: usize,
@@ -47,8 +48,6 @@ pub struct InvalidCidInLink {
4748
pub name: Cow<'static, str>,
4849
/// Error from the attempted conversion
4950
pub source: cid::Error,
50-
/// This is to deny creating these outside of the crate
51-
hidden: (),
5251
}
5352

5453
impl<'a> From<(usize, pb::PBLink<'a>, cid::Error)> for InvalidCidInLink {
@@ -70,7 +69,6 @@ impl<'a> From<(usize, pb::PBLink<'a>, cid::Error)> for InvalidCidInLink {
7069
hash,
7170
name,
7271
source,
73-
hidden: (),
7472
}
7573
}
7674
}

0 commit comments

Comments
 (0)