Paul Woitaschek
02/02/2025, 9:59 AMpublic inline fun <T> networkResult(action: () -> T): NetworkResult<T> {
  contract {
    callsInPlace(action, InvocationKind.EXACTLY_ONCE)
  }
  return try {
    NetworkResult.Worked(action())
  } catch (e: Exception) {
    val failure = e.asFailureOrThrow
    NetworkResult.Failed(failure)
  }
}EXACTLY_ONCEYoussef Shoaib [MOD]
02/02/2025, 10:02 AMEXACTLY_ONCEEXACTLY_ONCEval foo: Int
networkResult {
  ...
  foo = 5
  ...
}
// foo must be guaranteed to be set here.Paul Woitaschek
02/02/2025, 10:06 AMA function parameter will be invoked exactly one time.Youssef Shoaib [MOD]
02/02/2025, 10:16 AMfoo