Skip to content

Commit

Permalink
Made Upcast a constraint on ToStatic::Static (workaround for rust-lan…
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Jeffrey committed Feb 24, 2016
1 parent d4642c9 commit 0687da5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
17 changes: 7 additions & 10 deletions src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,11 @@ pub struct AndThen<P, Q>(P, Q);

impl<P, Q> Parser for AndThen<P, Q> {}

impl<P, Q, Ch, Str, PStaticOutput> Committed<Ch, Str> for AndThen<P, Q>
impl<P, Q, Ch, Str> Committed<Ch, Str> for AndThen<P, Q>
where P: Committed<Ch, Str>,
Q: 'static + Copy + Committed<Ch, Str>,
Str: Iterator<Item = Ch>,
PStaticOutput: 'static + Upcast<P::Output>,
P::Output: ToStatic<Static = PStaticOutput>,
P::Output: ToStatic,
{

fn empty(&self) -> Self::Output {
Expand All @@ -299,16 +298,15 @@ impl<P, Q, Ch, Str, PStaticOutput> Committed<Ch, Str> for AndThen<P, Q>

}

impl<P, Q, Ch, Str, PStaticOutput> Uncommitted<Ch, Str> for AndThen<P, Q>
impl<P, Q, Ch, Str> Uncommitted<Ch, Str> for AndThen<P, Q>
where P: Uncommitted<Ch, Str>,
Q: 'static + Copy + Committed<Ch, Str>,
Str: Iterator<Item = Ch>,
PStaticOutput: 'static + Upcast<P::Output>,
P::Output: ToStatic<Static = PStaticOutput>,
P::Output: ToStatic,
{

type Output = (P::Output, Q::Output);
type State = AndThenState<P::State, Q, PStaticOutput, Q::State>;
type State = AndThenState<P::State, Q, <P::Output as ToStatic>::Static, Q::State>;

fn init(&self, string: &mut Str) -> Option<ParseResult<Self::State, Self::Output>> {
match self.0.init(string) {
Expand Down Expand Up @@ -337,13 +335,12 @@ pub enum AndThenState<PState, Q, PStaticOutput, QState> {
InRhs(PStaticOutput, QState),
}

impl<PState, Q, Ch, Str, PStaticOutput> Stateful<Ch, Str> for AndThenState<PState, Q, PStaticOutput, Q::State>
impl<PState, Q, PStaticOutput, Ch, Str> Stateful<Ch, Str> for AndThenState<PState, Q, PStaticOutput, Q::State>
where PState: Stateful<Ch, Str>,
Q: Committed<Ch, Str>,
Str: Iterator<Item = Ch>,
PStaticOutput: 'static + Upcast<PState::Output>,
PState::Output: ToStatic<Static = PStaticOutput>,

PStaticOutput: 'static + Upcast<PState::Output>,
{

type Output = (PState::Output, Q::Output);
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ impl<S, T, D, E> Upcast<Result<T,E>> for Result<S,D>
/// and restored from `Cow<'static,T>` when `T` is static.
pub trait ToStatic {
type Static: 'static;
type Static: 'static + Upcast<Self>;
fn to_static(self) -> Self::Static where Self: Sized;
}

Expand Down

0 comments on commit 0687da5

Please sign in to comment.