Skip to content

Commit

Permalink
Use safer optional values, and other enabling changes
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Jan 24, 2025
1 parent 4d9e8c8 commit f69ce54
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/core/wisteria.ContextRequirement.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ object ContextRequirement:
given required: ContextRequirement:
type Optionality[Type] = Type
type Required = true
def wrap[ValueType](optional: Optional[ValueType]): ValueType = optional.vouch(using Unsafe)
def wrap[ValueType](optional: Optional[ValueType]): ValueType = optional.vouch

object relaxed extends ContextRequirement:
type Optionality[Type] = Optional[Type]
Expand Down
2 changes: 1 addition & 1 deletion src/core/wisteria.ProductDerivationMethods.scala
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ trait ProductDerivationMethods[TypeclassType[_]]:
accumulator => [FieldType2] => field =>
if index == fieldIndex then field.asInstanceOf[FieldType] else accumulator

. vouch(using Unsafe)
. vouch

protected transparent inline def fields[DerivationType <: Product](inline product: DerivationType)
(using requirement: ContextRequirement)
Expand Down
4 changes: 2 additions & 2 deletions src/core/wisteria.SumDerivationMethods.scala
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ trait SumDerivationMethods[TypeclassType[_]]:
fold[DerivationType, Variants, Labels](variantLabel, size, 0, true)(label == variantLabel):
[VariantType <: DerivationType] => context => lambda[VariantType](context)

. vouch(using Unsafe)
. vouch

protected transparent inline def variant[DerivationType](sum: DerivationType)
(using reflection: SumReflection[DerivationType], requirement: ContextRequirement)
Expand All @@ -131,7 +131,7 @@ trait SumDerivationMethods[TypeclassType[_]]:
fold[DerivationType, Variants, Labels](sum, size, 0, false)(index == reflection.ordinal(sum)):
[VariantType <: DerivationType] => variant => lambda[VariantType](variant)

. vouch(using Unsafe)
. vouch

private transparent inline def fold[DerivationType, VariantsType <: Tuple, LabelsType <: Tuple]
(inline inputLabel: Text, size: Int, index: Int, fallible: Boolean)
Expand Down

0 comments on commit f69ce54

Please sign in to comment.