Skip to content

Commit

Permalink
Merge pull request #10591 from som-snytt/tweak/using-this-types
Browse files Browse the repository at this point in the history
Type tweaks in Using
  • Loading branch information
som-snytt committed Nov 5, 2023
2 parents 3080c4b + 56e05a0 commit f4c2d8d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/library/scala/util/Using.scala
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ object Using {
* the resource is released when the manager is closed, and then
* returns the (unmodified) resource.
*/
def apply[R: Releasable](resource: R): R = {
def apply[R: Releasable](resource: R): resource.type = {
acquire(resource)
resource
}
Expand Down Expand Up @@ -421,6 +421,8 @@ object Using {
}

object Releasable {
// prefer explicit types 2.14
//implicit val AutoCloseableIsReleasable: Releasable[AutoCloseable] = new Releasable[AutoCloseable] {}
/** An implicit `Releasable` for [[java.lang.AutoCloseable `AutoCloseable`s]]. */
implicit object AutoCloseableIsReleasable extends Releasable[AutoCloseable] {
def release(resource: AutoCloseable): Unit = resource.close()
Expand Down

0 comments on commit f4c2d8d

Please sign in to comment.