Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency on the itertools crate #109

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading