fix: Using covariant interface for IParser and IParseResult.

Rename CanonSharp.Common to CanonSharp.Pascal.
This commit is contained in:
2024-08-14 19:41:10 +08:00
parent 65d4d0e6e8
commit 65d6b9794c
51 changed files with 399 additions and 393 deletions

View File

@@ -19,7 +19,7 @@ public static class ParseResultBuilder
/// <typeparam name="T">解析成功的对象类型</typeparam>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ParseResult<TToken, T> Succeed<TToken, TState, T>(T value, TState state)
public static IParseResult<TToken, T> Succeed<TToken, TState, T>(T value, TState state)
where TState : IReadState<TToken, TState>
=> new InternalSuccessfulResult<TToken, TState, T>(value, state);
@@ -32,7 +32,7 @@ public static class ParseResultBuilder
/// <typeparam name="T">解析成功的对象类型</typeparam>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ParseResult<TToken, T> Fail<TToken, TState, T>(TState state)
public static IParseResult<TToken, T> Fail<TToken, TState, T>(TState state)
where TState : IReadState<TToken, TState>
=> new FailedResultWithError<TToken, TState, T>(state);
@@ -47,7 +47,7 @@ public static class ParseResultBuilder
/// <typeparam name="T">解析成功的对象类型</typeparam>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ParseResult<TToken, T> Fail<TToken, TState, T>(string message, TState state)
public static IParseResult<TToken, T> Fail<TToken, TState, T>(string message, TState state)
where TState : IReadState<TToken, TState>
=> new FailedResultWithMessage<TToken, TState, T>(message, state);
@@ -61,7 +61,7 @@ public static class ParseResultBuilder
/// <typeparam name="T">解析成功的对象类型</typeparam>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ParseResult<TToken, T> Fail<TToken, TState, T>(Exception exception, TState state)
public static IParseResult<TToken, T> Fail<TToken, TState, T>(Exception exception, TState state)
where TState : IReadState<TToken, TState>
=> new FailedResultWithException<TToken, TState, T>(exception, state);
}