Skip to content

Commit

Permalink
Remove dependency on the intertools crate (#109)
Browse files Browse the repository at this point in the history
This crate was only used in two small places in the ouroboros_macro
crate which could be easily replaced with stdlib variants.

Removing it might help compile times a bit.
  • Loading branch information
dnaka91 authored May 23, 2024
1 parent 9058a2b commit 16dd079
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
1 change: 0 additions & 1 deletion ouroboros_macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ proc-macro = true

[dependencies]
heck = "0.4.1"
itertools = "0.12.0"
proc-macro2 = "1.0"
proc-macro2-diagnostics = "0.10"
quote = "1.0"
Expand Down
9 changes: 4 additions & 5 deletions ouroboros_macro/src/generate/with_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::{
info_structures::{FieldType, Options, StructInfo},
utils::{replace_this_with_lifetime, uses_this_lifetime},
};
use itertools::Itertools;
use proc_macro2::{Span, TokenStream};
use quote::{format_ident, quote};
use syn::{Error, Lifetime, WhereClause};
Expand All @@ -24,7 +23,7 @@ pub fn make_with_all_mut_function(
let field_name = &field.name;
let field_type = &field.typ;
let lifetime = format_ident!("this{}", lifetime_idents.len());
if uses_this_lifetime(quote! { #field_type }) || field.field_type == FieldType::Borrowed {
if uses_this_lifetime(quote! { #field_type }) || field.field_type == FieldType::Borrowed {
lifetime_idents.push(lifetime.clone());
}
let field_type = replace_this_with_lifetime(quote! { #field_type }, lifetime.clone());
Expand Down Expand Up @@ -87,9 +86,9 @@ pub fn make_with_all_mut_function(
.predicates
.extend(extra.predicates.into_iter());
}
for (outlives, lt) in lifetime_idents.iter().tuple_windows() {
let lt = Lifetime::new(&format!("'{}", lt), Span::call_site());
let outlives = Lifetime::new(&format!("'{}", outlives), Span::call_site());
for idents in lifetime_idents.windows(2) {
let lt = Lifetime::new(&format!("'{}", idents[1]), Span::call_site());
let outlives = Lifetime::new(&format!("'{}", idents[0]), Span::call_site());
let extra: WhereClause = syn::parse_quote! { where #lt: #outlives };
generic_where
.predicates
Expand Down
3 changes: 1 addition & 2 deletions ouroboros_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use generate::{
};
use heck::ToSnakeCase;
use info_structures::BuilderType;
use itertools::Itertools;
use proc_macro::TokenStream;
use proc_macro2::TokenStream as TokenStream2;
use proc_macro2::TokenTree;
Expand Down Expand Up @@ -65,7 +64,7 @@ fn self_referencing_impl(
let with_errors = with_errors
.into_iter()
.map(|err| err.emit_as_expr_tokens())
.collect_vec();
.collect::<Vec<_>>();
let (with_all_struct_def, with_all_fn_def) = make_with_all_function(&info, options)?;
let (with_all_mut_struct_def, with_all_mut_fn_def) =
make_with_all_mut_function(&info, options)?;
Expand Down

0 comments on commit 16dd079

Please sign in to comment.