-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ascii and utf8 interpolators #381
Add ascii and utf8 interpolators #381
Conversation
Hmm, I suppose the naming is perhaps a bit overloaded. An |
We'd have to watch out for name conflicts at the very least. E.g., it's common to import both |
I think the Scala compiler is capable of disambiguating that case actually. //> using scala "2.12.16"
//> using lib "org.scodec::scodec-bits::1.1.34"
package object foo {
def hex(args: String): Unit = ???
}
import scodec.bits._
import foo._
object Test {
hex"deadbeef"
} In any case, maybe |
assertEquals(asciiBytes"deadbeef", ByteVector.encodeAscii(s"deadbeef").toOption.get) | ||
assert(compileErrors("""asciiBytes"ɟǝǝqpɐǝp"""").contains("error")) | ||
} | ||
|
||
test("utf8 interpolator") { | ||
assertEquals(utf8"ɟǝǝqpɐǝp", ByteVector.encodeUtf8(s"ɟǝǝqpɐǝp").toOption.get) | ||
assertEquals(utf8Bytes"ɟǝǝqpɐǝp", ByteVector.encodeUtf8(s"ɟǝǝqpɐǝp").toOption.get) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this /shrug
Love this. Have this in a lot of cases and have wanted precisely this. |
Wanted these at least a few times :)