Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
30 changes: 13 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,24 @@ jobs:
- name: Install Rust
run: rustup update stable
- run: rustup target add ${{ matrix.target }}
# TODO: Currently, valuable cannot build without `alloc` feature
# because `Debug` impl of `dyn Enumerable` uses `format!` macro.
# - run: cargo build --target ${{ matrix.target }} --no-default-features
# working-directory: valuable
# - run: cargo build --target ${{ matrix.target }} --no-default-features --features derive
# working-directory: valuable
- run: cargo build --target ${{ matrix.target }} --no-default-features
working-directory: valuable
- run: cargo build --target ${{ matrix.target }} --no-default-features --features derive
working-directory: valuable
- run: cargo build --target ${{ matrix.target }} --no-default-features --features alloc
working-directory: valuable
- run: cargo build --target ${{ matrix.target }} --no-default-features --features alloc,derive
working-directory: valuable

# TODO: Currently, valuable cannot build without `alloc` feature
# because `Debug` impl of `dyn Enumerable` uses `format!` macro.
# features:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Install Rust
# run: rustup update stable
# - name: Install cargo-hack
# run: cargo install cargo-hack
# - run: cargo hack build --workspace --feature-powerset --no-dev-deps
features:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Rust
run: rustup update stable
- name: Install cargo-hack
run: cargo install cargo-hack
- run: cargo hack build --workspace --feature-powerset --no-dev-deps
Copy link
Copy Markdown
Member Author

@taiki-e taiki-e May 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, our MSRV is 1.51 (because we use min const generics), so we can use resolver = "2" that the more preferable than --no-dev-deps (that edit Cargo.toml).

UPDATE: done in 013dca6


fmt:
runs-on: ubuntu-latest
Expand Down
6 changes: 4 additions & 2 deletions valuable/src/enumerable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,11 @@ impl<'a> DynamicVariant<'a> {

impl fmt::Debug for dyn Enumerable + '_ {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
let def = self.definition();
let variant = self.variant();
let name = format!("{}::{}", def.name(), variant.name());
#[cfg(feature = "alloc")]
let name = format!("{}::{}", self.definition().name(), variant.name());
#[cfg(not(feature = "alloc"))]
let name = variant.name();

if variant.is_named_fields() {
struct DebugEnum<'a, 'b> {
Expand Down
9 changes: 9 additions & 0 deletions valuable/src/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ use core::fmt;
macro_rules! slice {
(
$(
$(#[$attrs:meta])*
$variant:ident($ty:ty),
)*
) => {
#[non_exhaustive]
pub enum Slice<'a> {
$(
$(#[$attrs])*
$variant(&'a [$ty]),
)*
}
Expand All @@ -19,6 +21,7 @@ macro_rules! slice {

enum IterKind<'a> {
$(
$(#[$attrs])*
$variant(core::slice::Iter<'a, $ty>),
)*
}
Expand All @@ -27,6 +30,7 @@ macro_rules! slice {
pub fn len(&self) -> usize {
match self {
$(
$(#[$attrs])*
Slice::$variant(s) => s.len(),
)*
}
Expand All @@ -53,6 +57,7 @@ macro_rules! slice {
fn into_iter(self) -> Self::IntoIter {
Iter(match self {
$(
$(#[$attrs])*
Slice::$variant(s) => IterKind::$variant(s.iter()),
)*
})
Expand All @@ -67,6 +72,7 @@ macro_rules! slice {

match *self {
$(
$(#[$attrs])*
$variant(v) => d.entries(v),
)*
};
Expand All @@ -83,6 +89,7 @@ macro_rules! slice {

match &self.0 {
$(
$(#[$attrs])*
$variant(v) => v.size_hint(),
)*
}
Expand All @@ -93,6 +100,7 @@ macro_rules! slice {

match &mut self.0 {
$(
$(#[$attrs])*
$variant(v) => v.next().map(|v| {
Valuable::as_value(v)
}),
Expand All @@ -115,6 +123,7 @@ slice! {
I128(i128),
Isize(isize),
Str(&'a str),
#[cfg(feature = "alloc")]
String(alloc::string::String),
U8(u8),
U16(u16),
Expand Down