Skip to content

Commit

Permalink
refactor: ran pre-commit on all files
Browse files Browse the repository at this point in the history
  • Loading branch information
acovaci committed May 17, 2024
1 parent fbd539e commit 880c037
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 42 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ repos:
- id: fmt
- id: cargo-check
- id: clippy
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v3.2.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
4 changes: 1 addition & 3 deletions src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@ use crate::parse::array::{ArrayBuilder, ArrayTokenizer};
use crate::types::ArrayDefinition;

pub(crate) struct Input {
pub(crate) visibility: syn::Visibility,
pub(crate) definition: ArrayDefinition,
pub(crate) tokenizer: ArrayTokenizer,
}

impl syn::parse::Parse for Input {
fn parse(stream: syn::parse::ParseStream) -> syn::Result<Self> {
let visibility = stream.parse()?;
let _: syn::Visibility = stream.parse()?;
let definition = stream.parse()?;
stream.parse::<syn::Token![,]>()?;
let tokenizer = stream.parse()?;

Ok(Self {
visibility,
definition,
tokenizer,
})
Expand Down
4 changes: 1 addition & 3 deletions src/parse/converter.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use syn::Lit;

use super::interface::SynInterface;
use super::traits::{ArrayLiteralConverter, LiteralConverter};
use super::traits::LiteralConverter;

impl LiteralConverter<u8> for SynInterface<u8> {
fn value_from_lit(lit: syn::ExprLit) -> syn::Result<u8> {
Expand Down
4 changes: 2 additions & 2 deletions src/parse/definition.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::types::{Array, ArrayDefinition};
use crate::types::ArrayDefinition;

impl syn::parse::Parse for ArrayDefinition {
fn parse(stream: syn::parse::ParseStream) -> syn::Result<Self> {
Expand Down Expand Up @@ -29,6 +29,6 @@ impl syn::parse::Parse for ArrayDefinition {
))
}
};
Ok(Self::new(len, *typ)?)
Self::new(len, *typ)
}
}
4 changes: 1 addition & 3 deletions src/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ mod traits;
mod types;

pub mod interface {
pub use super::traits::{
ArrayLiteralConverter, IntoTokens, LiteralConverter, Tokenizer, TypeConverter,
};
pub use super::traits::{ArrayLiteralConverter, IntoTokens, Tokenizer, TypeConverter};

pub struct SynInterface<T> {
_marker: std::marker::PhantomData<T>,
Expand Down
13 changes: 0 additions & 13 deletions src/parse/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,3 @@ pub trait Tokenizer<T> {
pub trait IntoTokens {
fn into_tokens(self) -> proc_macro2::TokenStream;
}

pub trait TryIntoTokens {
fn try_into_tokens(self) -> syn::Result<proc_macro2::TokenStream>;
}

impl<T> TryIntoTokens for T
where
T: IntoTokens,
{
fn try_into_tokens(self) -> syn::Result<proc_macro2::TokenStream> {
Ok(self.into_tokens())
}
}
6 changes: 1 addition & 5 deletions src/types/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,12 @@ where
Self { values }
}

pub fn add(&mut self, value: T) {
self.values.push(value);
}

pub fn check_size(&self, size: usize) -> bool {
self.values.len() <= size
}

pub fn values(&self) -> Vec<T> {
self.values.iter().cloned().collect()
self.values.to_vec()
}

pub fn ensure_size(&mut self, size: usize) -> syn::Result<()> {
Expand Down
13 changes: 0 additions & 13 deletions src/types/rust_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@ impl RustType {
self.segments.is_empty()
}

// pub fn range(start: Option<&Self>, end: Option<&Self>) -> ::std::ops::Range<Self> {
// match (start, end) {
// (Some(start), Some(end)) => start.clone()..end.clone(),
// (Some(start), None) => start.clone()..Self::from_string(""),
// (None, Some(end)) => Self::from_string("")..end.clone(),
// (None, None) => Self::from_string("")..Self::from_string(""),
// }
// }

pub fn is_supported(&self) -> bool {
SUPPORTED_TYPES
.iter()
Expand All @@ -47,10 +38,6 @@ impl RustType {
self >= other && (self.is_supported() && other.is_supported())
}

pub fn segments(&self) -> &[String] {
&self.segments
}

pub fn exact_same_as(&self, other: &Self) -> bool {
self.segments == other.segments
}
Expand Down

0 comments on commit 880c037

Please sign in to comment.