authorgravatar for 14938807+xackus@users.noreply.github.comxackus <14938807+xackus@users.noreply.github.com> 2019-10-27 21:52:28+01:00
committergravatar for 14938807+xackus@users.noreply.github.comxackus <14938807+xackus@users.noreply.github.com> 2019-10-27 21:52:28+01:00
log36fa5fabc6402777ff3a806475d0b60f30edf389
treea6c776a573d48934db930b6f7acacb61f0437621
parenteeb6536c85c817bee2c137650ecfd941df20c38d

rename error and specify it in function


1 files changed, 4 insertions(+), 4 deletions(-)

lib/std/json.zig+4-4
...@@ -867,7 +867,7 @@ pub const TokenStream = struct {...@@ -867,7 +867,7 @@ pub const TokenStream = struct {
867 parser: StreamingParser,867 parser: StreamingParser,
868 token: ?Token,868 token: ?Token,
869869
870 pub const Error = StreamingParser.Error || error.Incomplete;870 pub const Error = StreamingParser.Error || error{UnexpectedEndOfJson};
871871
872 pub fn init(slice: []const u8) TokenStream {872 pub fn init(slice: []const u8) TokenStream {
873 return TokenStream{873 return TokenStream{
...@@ -878,7 +878,7 @@ pub const TokenStream = struct {...@@ -878,7 +878,7 @@ pub const TokenStream = struct {
878 };878 };
879 }879 }
880880
881 pub fn next(self: *TokenStream) !?Token {881 pub fn next(self: *TokenStream) Error!?Token {
882 if (self.token) |token| {882 if (self.token) |token| {
883 const copy = token;883 const copy = token;
884 self.token = null;884 self.token = null;
...@@ -901,7 +901,7 @@ pub const TokenStream = struct {...@@ -901,7 +901,7 @@ pub const TokenStream = struct {
901 if(self.parser.complete){901 if(self.parser.complete){
902 return null;902 return null;
903 } else {903 } else {
904 return error.Incomplete;904 return error.UnexpectedEndOfJson;
905 }905 }
906 }906 }
907};907};
...@@ -1456,5 +1456,5 @@ test "write json then parse it" {...@@ -1456,5 +1456,5 @@ test "write json then parse it" {
1456test "parsing empty string gives appropriate error" {1456test "parsing empty string gives appropriate error" {
1457 var p = Parser.init(debug.global_allocator, false);1457 var p = Parser.init(debug.global_allocator, false);
1458 defer p.deinit();1458 defer p.deinit();
1459 testing.expectError(error.Incomplete, p.parse(""));1459 testing.expectError(error.UnexpectedEndOfJson, p.parse(""));
1460}1460}