<commit_before>use std::mem;
use std::marker::PhantomData;
use super::SessionType;
use protocol::{Channel, Protocol, Handler, Defer, DeferFunc};

/// This trait effectively posits that a protocol which handles `T` must
/// additionally handle other types. If `T` is an `Accept<S, Q>` the
/// protocol must handle `S` *and* be an `Acceptor` of `Q`. If `T` is 
/// a `Finally<S>` it must handle `S`.
pub trait Acceptor<I, E, T>: Protocol + Sized {
	fn defer<X: SessionType, Y: SessionType>(chan: Channel<Self, I, X, Y>, usize) -> Defer<Self, I>;
}
impl<I, E: SessionType, H: Protocol + Handler<I, E, S> + Acceptor<I, E, Q>, S: SessionType, Q: SessionType> Acceptor<I, E, Accept<S, Q>> for H {
	fn defer<X: SessionType, Y: SessionType>(chan: Channel<Self, I, X, Y>, num: usize) -> Defer<H, I> {
		if num == 0 {
			let next_func: DeferFunc<Self, I, E, S> = <Self as Handler<I, E, S>>::with;

			Defer::new(chan, unsafe { mem::transmute(next_func) }, true)
		} else {
			<Self as Acceptor<I, E, Q>>::defer(chan, num - 1)
		}
	}
}
impl<I, E: SessionType, H: Protocol + Handler<I, E, S>,                     S: SessionType>                 Acceptor<I, E, Finally<S>>   for H {
	fn defer<X: SessionType, Y: SessionType>(chan: Channel<Self, I, X, Y>, _: usize) -> Defer<H, I> {
		// regardless of num we cannot proceed further than Finally<commit_msg>Clean up some unnecessary type parameters.<commit_after>use std::mem;
use std::marker::PhantomData;
use super::SessionType;
use protocol::{Channel, Protocol, Handler, Defer, DeferFunc};

/// This trait effectively posits that a protocol which handles `T` must
/// additionally handle other types. If `T` is an `Accept<S, Q>` the
/// protocol must handle `S` *and* be an `Acceptor` of `Q`. If `T` is 
/// a `Finally<S>` it must handle `S`.
pub trait Acceptor<I, E: SessionType, T>: Protocol + Sized {
	fn defer<Y: SessionType>(chan: Channel<Self, I, E, Y>, usize) -> Defer<Self, I>;
}
impl<I, E: SessionType, H: Protocol + Handler<I, E, S> + Acceptor<I, E, Q>, S: SessionType, Q: SessionType> Acceptor<I, E, Accept<S, Q>> for H {
	fn defer<Y: SessionType>(chan: Channel<Self, I, E, Y>, num: usize) -> Defer<H, I> {
		if num == 0 {
			let next_func: DeferFunc<Self, I, E, S> = <Self as Handler<I, E, S>>::with;

			Defer::new(chan, unsafe { mem::transmute(next_func) }, true)
		} else {
			<Self as Acceptor<I, E, Q>>::defer(chan, num - 1)
		}
	}
}
impl<I, E: SessionType, H: Protocol + Handler<I, E, S>,                     S: SessionType>                 Acceptor<I, E, Finally<S>>   for H {
	fn defer<Y: SessionType>(chan: Channel<Self, I, E, Y>, _: usize) -> Defer<H, I> {
		// regardless of num we cannot proceed further than Finally
{'fraction_non_alphanumeric': 0.17102315160567588, 'fraction_numerical': 0.0014936519790888724, 'mean_word_length': 3.7669039145907472, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2460240', 'n_tokens_mistral': 998, 'n_tokens_neox': 955, 'n_words': 337}