Skip to content

Commit

Permalink
Migrate from enum-as-derive to enum-as-inner
Browse files Browse the repository at this point in the history
  • Loading branch information
Volkalex28 committed Feb 16, 2025
1 parent 45d53ce commit 0a0190f
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ homepage = "https://github.com/Volkalex28/varu-emb#readme"
license = "MIT"
repository = "https://github.com/Volkalex28/varu-emb"
rust-version = "1.80"
version = "0.4.1"
version = "0.4.3"

[workspace]
members = ["cfg", "cross", "executor", "lockfree", "notifier", "utils", "build"]
Expand Down
2 changes: 1 addition & 1 deletion cfg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ version.workspace = true
proc-macro = true

[dependencies]
enum-as-derive = { version = "0.1" }
enum-as-inner = { version = "0.6" }
heck = { version = "0.5" }
linked-hash-map = { version = "0.5" }
proc-macro2 = { version = "1.0" }
Expand Down
6 changes: 3 additions & 3 deletions cfg/src/cfg.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use enum_as_derive::EnumAs;
use enum_as_inner::EnumAsInner;
use heck::{ToShoutySnakeCase, ToSnakeCase};
use proc_macro2::{Span, TokenStream};
use quote::{quote, ToTokens};
Expand All @@ -13,7 +13,7 @@ type Result<T, E = Error> = std::result::Result<T, E>;
type Fields<A = Attribute> = HashMap<syn::Ident, A>;
type CfgMap = HashMap<String, Fields<syn::Expr>>;

#[derive(EnumAs, ToTokens)]
#[derive(EnumAsInner, ToTokens)]
enum Attribute {
Default(TokenStream),

Expand Down Expand Up @@ -214,7 +214,7 @@ mod tokens {
mod parsing {
use super::*;

#[derive(Parse, EnumAs)]
#[derive(Parse, EnumAsInner)]
pub enum AttributeType {
#[parse(peek = tokens::default)]
Default { _default: tokens::default, _colon: Token![:], value: TokenStream },
Expand Down
2 changes: 1 addition & 1 deletion cross/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ embedded-hal = { version = "1.0.0" }
embedded-hal-async = { version = "1.0.0" }
embedded-io = { version = "0.6.1" }
embedded-io-async = { version = "0.6.1" }
enum-as-derive = { version = "0.1" }
enum-as-inner = { version = "0.6" }
forward-traits = { git = "https://github.com/Volkalex28/forward-traits.git", branch = "asynch" }
fugit = { version = "0.3" }
proc = { path = "proc", package = "varuemb-cross-proc" }
Expand Down
6 changes: 3 additions & 3 deletions cross/src/gpio.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use enum_as_derive::EnumAs;
use enum_as_inner::EnumAsInner;

pub use embedded_hal::digital::*;
pub use supply::{GpioErrorType as ErrorType, InputPin, OutputPin, StatefulOutputPin};
Expand All @@ -19,7 +19,7 @@ pub mod asynch {
}

/// Pull setting for an input.
#[derive(EnumAs, Debug, Eq, PartialEq, Copy, Clone)]
#[derive(EnumAsInner, Debug, Eq, PartialEq, Copy, Clone)]
pub enum Pull {
/// No pull
None,
Expand All @@ -39,7 +39,7 @@ impl From<Option<bool>> for Pull {
}

/// Digital input or output level.
#[derive(EnumAs, Debug, Eq, PartialEq, Copy, Clone)]
#[derive(EnumAsInner, Debug, Eq, PartialEq, Copy, Clone)]
pub enum Level {
/// Low
Low,
Expand Down
8 changes: 4 additions & 4 deletions cross/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ pub mod asynch {
}

pub mod serial {
use enum_as_derive::EnumAs;
use enum_as_inner::EnumAsInner;

/// Number of data bits
#[derive(EnumAs, PartialEq, Eq, Copy, Clone, Debug)]
#[derive(EnumAsInner, PartialEq, Eq, Copy, Clone, Debug)]
pub enum DataBits {
DataBits5 = 0,
DataBits6 = 1,
Expand All @@ -33,15 +33,15 @@ pub mod serial {
}

/// Parity check
#[derive(EnumAs, PartialEq, Eq, Copy, Clone, Debug)]
#[derive(EnumAsInner, PartialEq, Eq, Copy, Clone, Debug)]
pub enum Parity {
None,
Even,
Odd,
}

/// Number of stop bits
#[derive(EnumAs, PartialEq, Eq, Copy, Clone, Debug)]
#[derive(EnumAsInner, PartialEq, Eq, Copy, Clone, Debug)]
pub enum StopBits {
/// 0.5 stop bits
Stop0P5 = 1,
Expand Down
8 changes: 4 additions & 4 deletions cross/src/spi/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use enum_as_derive::EnumAs;
use enum_as_inner::EnumAsInner;

pub use embedded_hal::spi::*;

Expand All @@ -14,7 +14,7 @@ pub mod asynch {
}

/// SPI modes
#[derive(EnumAs, Debug, Clone, Copy, Eq, PartialEq)]
#[derive(EnumAsInner, Debug, Clone, Copy, Eq, PartialEq)]
pub enum Mode {
Mode0,
Mode1,
Expand All @@ -23,7 +23,7 @@ pub enum Mode {
}

/// SPI Bit Order
#[derive(EnumAs, Debug, Clone, Copy, Eq, PartialEq)]
#[derive(EnumAsInner, Debug, Clone, Copy, Eq, PartialEq)]
pub enum BitOrder {
MSBFirst,
LSBFirst,
Expand All @@ -34,7 +34,7 @@ pub enum BitOrder {
/// Single = 1 bit, 2 wires
/// Dual = 2 bit, 2 wires
/// Quad = 4 bit, 4 wires
#[derive(EnumAs, Debug, Clone, Copy, Eq, PartialEq)]
#[derive(EnumAsInner, Debug, Clone, Copy, Eq, PartialEq)]
pub enum DataMode {
Single,
Dual,
Expand Down
2 changes: 1 addition & 1 deletion devices/proc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ rust-version.workspace = true
proc-macro = true

[dependencies]
enum-as-derive = { version = "0.1" }
enum-as-inner = { version = "0.6" }
heck = { version = "0.5" }
linked-hash-map = { version = "0.5" }
proc-macro2 = { version = "1.0" }
Expand Down
12 changes: 6 additions & 6 deletions utils/proc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ proc-macro = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
enum-as-derive = { version = "0.1" }
heck = { version = "0.5" }
proc-macro2 = { version = "1.0" }
quote = { version = "1.0" }
syn = { version = "2.0", features = ["full"] }
syn_derive = { version = "0.2" }
enum-as-inner = { version = "0.6" }
heck = { version = "0.5" }
proc-macro2 = { version = "1.0" }
quote = { version = "1.0" }
syn = { version = "2.0", features = ["full"] }
syn_derive = { version = "0.2" }
6 changes: 3 additions & 3 deletions utils/proc/src/cfg_type_alias.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use enum_as_derive::EnumAs;
use enum_as_inner::EnumAsInner;
use proc_macro2::TokenStream;
use quote::ToTokens;
use std::cell::RefCell;
Expand All @@ -8,7 +8,7 @@ use syn::spanned::Spanned;
use syn::{parse, Result, Token};
use syn_derive::Parse;

#[derive(Parse, Clone, EnumAs)]
#[derive(Parse, Clone, EnumAsInner)]
enum GenericParam {
#[parse(peek = Token![=])]
Output {
Expand Down Expand Up @@ -44,7 +44,7 @@ impl ToTokens for CfgTypeAlias {
let mut this = self.0.borrow_mut();

let generics = core::mem::take::<Vec<_>>(&mut this.generics).into_iter().flat_map(|generics| generics.into_iter());
this.input.generics.params.extend(generics.clone().into_iter().filter_map(GenericParam::into_param));
this.input.generics.params.extend(generics.clone().into_iter().filter_map(|v| v.into_param().ok()));
let syn::Type::Path(type_path) = this.input.ty.as_mut() else { unreachable!() };
if let Some(segm) = type_path.path.segments.last_mut() {
let args = generics.map(|g| match g {
Expand Down

0 comments on commit 0a0190f

Please sign in to comment.