mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Emplace variables made from types in expectations
This commit is contained in:
parent
04a3f1c00e
commit
9b24205906
3 changed files with 56 additions and 34 deletions
|
@ -38,6 +38,16 @@ impl<T> PExpected<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn map<U>(self, f: impl FnOnce(T) -> U) -> PExpected<U> {
|
||||
match self {
|
||||
PExpected::NoExpectation(val) => PExpected::NoExpectation(f(val)),
|
||||
PExpected::ForReason(reason, val, region) => {
|
||||
PExpected::ForReason(reason, f(val), region)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn replace<U>(self, new: U) -> PExpected<U> {
|
||||
match self {
|
||||
PExpected::NoExpectation(_val) => PExpected::NoExpectation(new),
|
||||
|
@ -89,6 +99,17 @@ impl<T> Expected<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn map<U>(self, f: impl FnOnce(T) -> U) -> Expected<U> {
|
||||
match self {
|
||||
Expected::NoExpectation(val) => Expected::NoExpectation(f(val)),
|
||||
Expected::ForReason(reason, val, region) => Expected::ForReason(reason, f(val), region),
|
||||
Expected::FromAnnotation(pattern, size, source, val) => {
|
||||
Expected::FromAnnotation(pattern, size, source, f(val))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn replace<U>(self, new: U) -> Expected<U> {
|
||||
match self {
|
||||
Expected::NoExpectation(_val) => Expected::NoExpectation(new),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue