From 3cc473f2101af6d55db40c16cb3c1512c45dbfa6 Mon Sep 17 00:00:00 2001 From: Micah Johnston Date: Sun, 14 Jul 2024 21:47:09 -0500 Subject: [PATCH] rename FromBuffers::bind method to from_buffers --- src/buffers.rs | 2 +- src/buffers/collect.rs | 50 +++++++++++++++++++++--------------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/buffers.rs b/src/buffers.rs index dd319aa..c1206b5 100644 --- a/src/buffers.rs +++ b/src/buffers.rs @@ -112,7 +112,7 @@ impl<'a, 'b> Buffers<'a, 'b> { pub fn collect>(self) -> Option { let mut iter = self.into_iter(); - let result = B::bind(&mut iter)?; + let result = B::from_buffers(&mut iter)?; if iter.next().is_none() { Some(result) diff --git a/src/buffers/collect.rs b/src/buffers/collect.rs index e6488b9..7a60424 100644 --- a/src/buffers/collect.rs +++ b/src/buffers/collect.rs @@ -3,14 +3,14 @@ use std::array; use super::{AnyBuffer, Buffer, BufferMut}; pub trait FromBuffers<'a, 'b>: Sized { - fn bind(buffers: &mut I) -> Option + fn from_buffers(buffers: &mut I) -> Option where I: Iterator>; } impl<'a, 'b> FromBuffers<'a, 'b> for Buffer<'a, 'b> { #[inline] - fn bind(buffers: &mut I) -> Option + fn from_buffers(buffers: &mut I) -> Option where I: Iterator>, { @@ -23,17 +23,17 @@ impl<'a, 'b> FromBuffers<'a, 'b> for Buffer<'a, 'b> { impl<'a, 'b, const N: usize> FromBuffers<'a, 'b> for [&'b [f32]; N] { #[inline] - fn bind(buffers: &mut I) -> Option + fn from_buffers(buffers: &mut I) -> Option where I: Iterator>, { - Buffer::bind(buffers)?.collect() + Buffer::from_buffers(buffers)?.collect() } } impl<'a, 'b> FromBuffers<'a, 'b> for BufferMut<'a, 'b> { #[inline] - fn bind(buffers: &mut I) -> Option + fn from_buffers(buffers: &mut I) -> Option where I: Iterator>, { @@ -46,28 +46,28 @@ impl<'a, 'b> FromBuffers<'a, 'b> for BufferMut<'a, 'b> { impl<'a, 'b, const N: usize> FromBuffers<'a, 'b> for [&'b mut [f32]; N] { #[inline] - fn bind(buffers: &mut I) -> Option + fn from_buffers(buffers: &mut I) -> Option where I: Iterator>, { - BufferMut::bind(buffers)?.collect() + BufferMut::from_buffers(buffers)?.collect() } } -macro_rules! bind_buffers { - ($($binding:ident),*) => { - impl<'a, 'b, $($binding),*> FromBuffers<'a, 'b> for ($($binding,)*) +macro_rules! from_buffers { + ($($buffer:ident),*) => { + impl<'a, 'b, $($buffer),*> FromBuffers<'a, 'b> for ($($buffer,)*) where - $($binding: FromBuffers<'a, 'b>),* + $($buffer: FromBuffers<'a, 'b>),* { #[inline] - fn bind(buffers: &mut I) -> Option + fn from_buffers(buffers: &mut I) -> Option where I: Iterator>, { Some(( $( - $binding::bind(buffers)?, + $buffer::from_buffers(buffers)?, )* )) } @@ -75,30 +75,30 @@ macro_rules! bind_buffers { } } -bind_buffers!(B0); -bind_buffers!(B0, B1); -bind_buffers!(B0, B1, B2); -bind_buffers!(B0, B1, B2, B3); -bind_buffers!(B0, B1, B2, B3, B4); -bind_buffers!(B0, B1, B2, B3, B4, B5); -bind_buffers!(B0, B1, B2, B3, B4, B5, B6); -bind_buffers!(B0, B1, B2, B3, B4, B5, B6, B7); -bind_buffers!(B0, B1, B2, B3, B4, B5, B6, B7, B8); -bind_buffers!(B0, B1, B2, B3, B4, B5, B6, B7, B8, B9); +from_buffers!(B0); +from_buffers!(B0, B1); +from_buffers!(B0, B1, B2); +from_buffers!(B0, B1, B2, B3); +from_buffers!(B0, B1, B2, B3, B4); +from_buffers!(B0, B1, B2, B3, B4, B5); +from_buffers!(B0, B1, B2, B3, B4, B5, B6); +from_buffers!(B0, B1, B2, B3, B4, B5, B6, B7); +from_buffers!(B0, B1, B2, B3, B4, B5, B6, B7, B8); +from_buffers!(B0, B1, B2, B3, B4, B5, B6, B7, B8, B9); impl<'a, 'b, const N: usize, B> FromBuffers<'a, 'b> for [B; N] where B: FromBuffers<'a, 'b>, { #[inline] - fn bind(buffers: &mut I) -> Option + fn from_buffers(buffers: &mut I) -> Option where I: Iterator>, { let mut results = array::from_fn(|_| None); for result in results.iter_mut() { - *result = Some(B::bind(buffers)?); + *result = Some(B::from_buffers(buffers)?); } Some(results.map(|result| result.unwrap()))