Skip to content

Commit

Permalink
fix: handle more cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Alxandr committed Dec 15, 2022
1 parent f62ce5a commit b236c76
Show file tree
Hide file tree
Showing 10 changed files with 824 additions and 185 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/upload-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ jobs:
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v1

- name: Install cargo plugins
run: cargo install cargo-workspaces
- name: Publish
run: cargo workspaces publish --from-git --yes --token "${{ secrets.CRATES_IO_TOKEN }}"

# TODO: probably get creative with earthly or something
# - name: Upload binaries to release
# uses: svenstaro/upload-release-action@v2
Expand Down
6 changes: 5 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
"kind": "bin"
}
},
"args": ["featurex"],
"args": [
"featurex",
"--manifest-path",
"../hass-rs/crates/mqtt-provider/Cargo.toml"
],
"cwd": "${workspaceFolder}"
},
{
Expand Down
77 changes: 61 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ repository = "https://github.com/YoloDev/cargo-featurex"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bit-set = "0.5.3"
bytemuck = { version = "1.12.3", features = ["min_const_generics"] }
cargo_metadata = "0.15.2"
clap = { version = "4.0.29", features = ["derive"] }
error-stack = "0.2.4"
itertools = "0.10.5"
lasso = { version = "0.6.0", features = ["ahasher"] }
serde = { version = "1.0.150", features = ["derive"] }
serde_json = "1.0.89"
termcolor = "1.1.3"
Expand Down
36 changes: 36 additions & 0 deletions src/collect_result.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
pub(crate) enum CollectResult<T, E> {
Ok(T),
Err(error_stack::Report<E>),
}

impl<T, E> CollectResult<T, E> {
pub(crate) fn into_result(self) -> error_stack::Result<T, E> {
match self {
Self::Ok(results) => Ok(results),
Self::Err(report) => Err(report),
}
}
}

impl<A, E, V> FromIterator<error_stack::Result<A, E>> for CollectResult<V, E>
where
V: FromIterator<A>,
{
fn from_iter<I: IntoIterator<Item = error_stack::Result<A, E>>>(iter: I) -> Self {
let mut iter = iter.into_iter();
let mut vec = Vec::with_capacity(iter.size_hint().0);

while let Some(item) = iter.next() {
match item {
Ok(item) => vec.push(item),
Err(mut report) => {
report.extend(iter.filter_map(Result::err));

return Self::Err(report);
}
}
}

Self::Ok(vec.into_iter().collect())
}
}
Loading

0 comments on commit b236c76

Please sign in to comment.