Skip to content

a compiler plugin that adds `toTuple` method to all case classes

License

Notifications You must be signed in to change notification settings

aoiroaoino/totuple

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

totuple

Maven Central Travis

A tiny compiler plugin that adds the toTuple method to all case classes.

Support scala versions: Scala 2.11 and 2.12

Usage

Add following setting in your build.sbt.

addCompilerPlugin("com.github.aoiroaoino" %% "totuple" % "0.1.2")

The toTuple method is added to the case class with arguments 1 to 22.

case class User(id: Long, name: String)

val user = User(1, "John Doe")

assert(user.toTuple == (user.id, user.name))
case class Foo()
case class Bar(p1: Int, p2: Int, ..., p23: Int)

val foo = Foo()
val bar = Bar(1, 2, ..., 23)

// compile error
foo.toTuple
bar.toTuple

License

MIT

About

a compiler plugin that adds `toTuple` method to all case classes

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages