Skip to content

Commit

Permalink
Merge pull request #1071 from xuwei-k/JsResult-instance-size
Browse files Browse the repository at this point in the history
reduce `JsSuccess` and `JsError` instance size
  • Loading branch information
mkurz authored Sep 4, 2024
2 parents 02e70c4 + 13199c3 commit 6d2feae
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import scala.collection.Seq
case class JsSuccess[T](value: T, path: JsPath = JsPath()) extends JsResult[T] {
def get: T = value

val isSuccess = true
val isError = false
def isSuccess = true
def isError = false

def fold[U](invalid: Seq[(JsPath, Seq[JsonValidationError])] => U, valid: T => U): U = valid(value)

Expand Down Expand Up @@ -60,8 +60,8 @@ case class JsError(errors: Seq[(JsPath, Seq[JsonValidationError])]) extends JsRe
def +:(error: (JsPath, JsonValidationError)): JsError = JsError.merge(JsError(error), this)
def prepend(error: (JsPath, JsonValidationError)): JsError = this.+:(error)

val isSuccess = false
val isError = true
def isSuccess = false
def isError = true

def fold[U](invalid: Seq[(JsPath, Seq[JsonValidationError])] => U, valid: Nothing => U): U = invalid(errors)

Expand All @@ -84,7 +84,7 @@ case class JsError(errors: Seq[(JsPath, Seq[JsonValidationError])]) extends JsRe

def orElse[U >: Nothing](t: => JsResult[U]): JsResult[U] = t

val asOpt = None
def asOpt = None

def asEither: Either[Seq[(JsPath, Seq[JsonValidationError])], Nothing] = Left(errors)

Expand Down

0 comments on commit 6d2feae

Please sign in to comment.