This Rust-based tool generates, compiles, and tests code using LLMs, resolves dependencies, and provides explanations of existing code through embeddings.
Create copies of "prompt.txt" in the "kotlin" folder
Launch example
rustsn --lang=kotlin
Example query:
take 2 params and add them and return result
Example generation:
build.gradle.kts
plugins {
kotlin("jvm") version "1.8.0"
application
}
group = "com.example"
version = "1.0.0"
repositories {
mavenCentral()
}
dependencies {
testImplementation(kotlin("test"))
}
application {
mainClass.set("com.example.SolutionKt")
}
tasks.test {
useJUnitPlatform()
}
src/main/kotlin/com/example/Solution.kt
fun solution(a: Any, b: Any): Any {
return when {
a is Int && b is Int -> a + b
a is String && b is Int -> a + b.toString()
else -> throw IllegalArgumentException("Unsupported parameter types")
}
}
fun main() {
println(solution(1, 2)) // Outputs: 3
println(solution(-1, -2)) // Outputs: -3
println(solution("1", 2)) // Outputs: 12
}
src/test/kotlin/com/example/SolutionTest.kt
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
class SolutionTest {
@Test
fun test1() {
assertEquals(3, solution(1, 2))
}
@Test
fun test2() {
assertEquals(-3, solution(-1, -2))
}
@Test
fun test3() {
assertEquals("12", solution("1", 2))
}
@Test
fun testInvalidParams() {
assertFailsWith<IllegalArgumentException> {
solution(1.0, 2.0)
}
}
}
Launch example
Example query:
Example generation:
build.gradle.kts
src/main/kotlin/com/example/Solution.kt
src/test/kotlin/com/example/SolutionTest.kt
Example install dependencies
Example launch compilation
Example launch tests