Skip to content

Commit

Permalink
clipclop
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjg committed Feb 3, 2025
1 parent 44e68f8 commit e682505
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 44 deletions.
14 changes: 7 additions & 7 deletions autosurgeon-derive/src/reconcile/enum_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl<'a> TryFrom<&'a syn::Variant> for Variant<'a> {
}
}

impl<'a> Variant<'a> {
impl Variant<'_> {
fn match_arm(
&self,
reconciler_ident: &syn::Ident,
Expand Down Expand Up @@ -155,7 +155,7 @@ enum EnumKeyInnerType<'a> {
NoInnerKeyTuple,
}

impl<'a> EnumKeyInnerType<'a> {
impl EnumKeyInnerType<'_> {
fn get_key(&self, key_type_name: &syn::Ident, variant_name: &syn::Ident) -> TokenStream {
match self {
Self::Unit => {
Expand Down Expand Up @@ -340,7 +340,7 @@ struct EnumKeyVariant<'a> {
ty: EnumKeyInnerType<'a>,
}

impl<'a> EnumKeyVariant<'a> {
impl EnumKeyVariant<'_> {
fn non_unit_match_arm(
&self,
outer_name: &syn::Ident,
Expand Down Expand Up @@ -642,7 +642,7 @@ struct EnumUnnamedField<'a> {
attrs: attrs::Field,
}

impl<'a> VariantField for EnumUnnamedField<'a> {
impl VariantField for EnumUnnamedField<'_> {
fn name(&self) -> syn::Ident {
format_ident!("field_{}", self.idx)
}
Expand All @@ -652,13 +652,13 @@ impl<'a> VariantField for EnumUnnamedField<'a> {
}
}

impl<'a> EnumUnnamedField<'a> {
impl EnumUnnamedField<'_> {
fn name(&self) -> syn::Ident {
format_ident!("field_{}", self.idx)
}
}

impl<'a> Field for EnumUnnamedField<'a> {
impl Field for EnumUnnamedField<'_> {
fn attrs(&self) -> &[syn::Attribute] {
&self.field.attrs
}
Expand Down Expand Up @@ -699,7 +699,7 @@ struct EnumNamedField<'a> {
name: &'a syn::Ident,
}

impl<'a> VariantField for EnumNamedField<'a> {
impl VariantField for EnumNamedField<'_> {
fn name(&self) -> syn::Ident {
self.name.clone()
}
Expand Down
4 changes: 2 additions & 2 deletions autosurgeon-derive/src/reconcile/struct_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl<'a> NamedField<'a> {
}
}

impl<'a> Field for NamedField<'a> {
impl Field for NamedField<'_> {
fn attrs(&self) -> &[syn::Attribute] {
&self.field.attrs
}
Expand Down Expand Up @@ -202,7 +202,7 @@ impl<'a> TupleField<'a> {
}
}

impl<'a> Field for TupleField<'a> {
impl Field for TupleField<'_> {
fn attrs(&self) -> &[syn::Attribute] {
&self.field.attrs
}
Expand Down
7 changes: 5 additions & 2 deletions autosurgeon/src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,11 @@ impl ReadDoc for am::AutoCommit {
}
}

impl<'a> ReadDoc for am::transaction::Transaction<'a> {
type Parents<'b> = am::Parents<'b> where Self: 'b;
impl ReadDoc for am::transaction::Transaction<'_> {
type Parents<'b>
= am::Parents<'b>
where
Self: 'b;
fn get_heads(&self) -> Vec<am::ChangeHash> {
am::transaction::Transactable::base_heads(self)
}
Expand Down
2 changes: 1 addition & 1 deletion autosurgeon/src/hydrate/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl<T: Hydrate> Hydrate for Option<T> {
}
}

impl<'a, T: Hydrate + Clone> Hydrate for Cow<'a, T> {
impl<T: Hydrate + Clone> Hydrate for Cow<'_, T> {
fn hydrate<D: ReadDoc>(
doc: &D,
obj: &automerge::ObjId,
Expand Down
2 changes: 1 addition & 1 deletion autosurgeon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//! ## Feature Flags
//!
//! * `uuid` - Includes implementations of `Reconcile` and `Hydrate` for the [`Uuid`](https://docs.rs/uuid/latest/uuid/) crate which will
//! reconcile to a [`automerge::ScalarValue::Bytes`]
//! reconcile to a [`automerge::ScalarValue::Bytes`]
//!
//! ## Example
//!
Expand Down
6 changes: 3 additions & 3 deletions autosurgeon/src/prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub enum Prop<'a> {
Index(u32),
}

impl<'a> std::fmt::Display for Prop<'a> {
impl std::fmt::Display for Prop<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Key(s) => write!(f, "{}", s),
Expand All @@ -16,7 +16,7 @@ impl<'a> std::fmt::Display for Prop<'a> {
}
}

impl<'a> From<&Prop<'a>> for automerge::Prop {
impl From<&Prop<'_>> for automerge::Prop {
fn from(p: &Prop) -> Self {
match p {
Prop::Key(k) => automerge::Prop::Map(k.to_string()),
Expand Down Expand Up @@ -49,7 +49,7 @@ impl<'a> From<&'a str> for Prop<'a> {
}
}

impl<'a> From<am::Prop> for Prop<'a> {
impl From<am::Prop> for Prop<'_> {
fn from(p: am::Prop) -> Self {
match p {
am::Prop::Map(k) => Prop::Key(Cow::Owned(k)),
Expand Down
72 changes: 46 additions & 26 deletions autosurgeon/src/reconcile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,14 +415,22 @@ struct RootReconciler<'a, D> {

impl<'a, D: Doc> Reconciler for RootReconciler<'a, D> {
type Error = ReconcileError;
type Map<'b> = InMap<'b, D>
where Self: 'b;
type Seq<'b> = InSeq<'b, D>
where Self: 'b;
type Text<'b> = InText<'b, D>
where Self: 'b;
type Counter<'b> = AtCounter<'b, D>
where Self: 'b;
type Map<'b>
= InMap<'b, D>
where
Self: 'b;
type Seq<'b>
= InSeq<'b, D>
where
Self: 'b;
type Text<'b>
= InText<'b, D>
where
Self: 'b;
type Counter<'b>
= AtCounter<'b, D>
where
Self: 'b;

fn none(&mut self) -> Result<(), Self::Error> {
Err(ReconcileError::TopLevelNotMap)
Expand Down Expand Up @@ -486,7 +494,7 @@ enum PropAction<'a> {
Insert(u32),
}

impl<'a> PropAction<'a> {
impl PropAction<'_> {
fn get_target<'b, D: Doc>(
&self,
doc: &'b D,
Expand Down Expand Up @@ -530,16 +538,24 @@ struct PropReconciler<'a, D> {
action: PropAction<'a>,
}

impl<'a, D: Doc> Reconciler for PropReconciler<'a, D> {
impl<D: Doc> Reconciler for PropReconciler<'_, D> {
type Error = ReconcileError;
type Map<'b> = InMap<'b, D>
where Self: 'b;
type Seq<'b> = InSeq<'b, D>
where Self: 'b;
type Text<'b> = InText<'b, D>
where Self: 'b;
type Counter<'b> = AtCounter<'b, D>
where Self: 'b;
type Map<'b>
= InMap<'b, D>
where
Self: 'b;
type Seq<'b>
= InSeq<'b, D>
where
Self: 'b;
type Text<'b>
= InText<'b, D>
where
Self: 'b;
type Counter<'b>
= AtCounter<'b, D>
where
Self: 'b;

fn none(&mut self) -> Result<(), Self::Error> {
self.action
Expand Down Expand Up @@ -659,7 +675,7 @@ struct AtCounter<'a, D> {
action: &'a PropAction<'a>,
}

impl<'a, D: Doc> CounterReconciler for AtCounter<'a, D> {
impl<D: Doc> CounterReconciler for AtCounter<'_, D> {
type Error = ReconcileError;

fn increment(&mut self, by: i64) -> Result<(), Self::Error> {
Expand Down Expand Up @@ -703,10 +719,12 @@ struct InMap<'a, D> {
current_obj: automerge::ObjId,
}

impl<'a, D: Doc> MapReconciler for InMap<'a, D> {
impl<D: Doc> MapReconciler for InMap<'_, D> {
type Error = ReconcileError;
type EntriesIter<'b> = InMapEntries<'b>
where Self: 'b;
type EntriesIter<'b>
= InMapEntries<'b>
where
Self: 'b;

fn entries(&self) -> Self::EntriesIter<'_> {
InMapEntries {
Expand Down Expand Up @@ -779,10 +797,12 @@ impl<'a> Iterator for ItemsInSeq<'a> {
}
}

impl<'a, D: Doc> SeqReconciler for InSeq<'a, D> {
impl<D: Doc> SeqReconciler for InSeq<'_, D> {
type Error = ReconcileError;
type ItemIter<'b> = ItemsInSeq<'b>
where Self: 'b;
type ItemIter<'b>
= ItemsInSeq<'b>
where
Self: 'b;

fn items<'b>(&'_ self) -> Self::ItemIter<'_> {
ItemsInSeq {
Expand Down Expand Up @@ -844,7 +864,7 @@ struct InText<'a, D> {
obj: automerge::ObjId,
}

impl<'a, D: Doc> TextReconciler for InText<'a, D> {
impl<D: Doc> TextReconciler for InText<'_, D> {
type Error = ReconcileError;

fn splice<S: AsRef<str>>(
Expand Down
3 changes: 2 additions & 1 deletion autosurgeon/src/reconcile/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Reconcile for str {
}
}

impl<'a, T: Reconcile + ?Sized> Reconcile for &'a T {
impl<T: Reconcile + ?Sized> Reconcile for &'_ T {
type Key<'b> = T::Key<'b>;
fn reconcile<R: Reconciler>(&self, reconciler: R) -> Result<(), R::Error> {
(*self).reconcile(reconciler)
Expand Down Expand Up @@ -171,6 +171,7 @@ macro_rules! int_impl {
Ok(match doc.get(obj, &prop)? {
Some((Value::Scalar(s), _)) => {
if let ScalarValue::$from(i) = s.as_ref() {
#[allow(irrefutable_let_patterns)]
if let Ok(v) = $ty::try_from(*i) {
LoadKey::Found(v)
} else {
Expand Down
2 changes: 1 addition & 1 deletion autosurgeon/src/reconcile/seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct Hook<'a, T, S> {
items: &'a [T],
}

impl<'a, T, S> similar::algorithms::DiffHook for Hook<'a, T, S>
impl<T, S> similar::algorithms::DiffHook for Hook<'_, T, S>
where
T: Reconcile,
S: SeqReconciler,
Expand Down

0 comments on commit e682505

Please sign in to comment.