Skip to content

2.1.0

Latest
Compare
Choose a tag to compare
@michaelbull michaelbull released this 03 Aug 17:04
· 1 commit to master since this release
  • Annotate Result#{value,error} direct access as unsafe by @hoc081098 (db45c67)
    • For full context and discussion on this topic, please read through the PR by @hoc081098 at #123, and the initial discussion presented by @kirillzh in #104.

Library consumers that directly access either Result.value or Result.error, e.g. in the situation they are extending the library to implement their own functionality, must now opt-in to unsafe access of these properties.

Failure to do so will result in a compilation error:

image

There are three ways to opt-in:

  1. On a function-level

     @OptIn(UnsafeResultValueAccess::class)
     fun myFunctionThatAccessesValueDirectly() { ... }
  2. On a file-level:

    @file:OptIn(UnsafeResultValueAccess::class)
    
    fun myFunctionThatAccessesValueDirectly() { ... }
    fun anotherFunctionThatAccessesValueDirectly() { ... }
  3. On a project-level in build.gradle.kts

    kotlin {
        compilerOptions {
            optIn.add("com.github.michaelbull.result.annotation.UnsafeResultValueAccess")
            optIn.add("com.github.michaelbull.result.annotation.UnsafeResultErrorAccess")
        }
    }