Skip to content

Commit

Permalink
chore: use scala3 formatting for native examples
Browse files Browse the repository at this point in the history
  • Loading branch information
myyk committed Nov 7, 2024
1 parent ac4517d commit 845f5c9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
6 changes: 2 additions & 4 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ runner.dialect = scala213

project {
excludePaths = [
"glob:**/example/scalalib/linting/1-scalafmt/src/Foo.scala",
# Stop ignoring these paths after upgrading to runner.dialect = scala3,
"glob:**/example/scalalib/native/1-simple/src/Foo.scala",
"glob:**/example/scalalib/native/4-common-config/src/Foo.scala"
"glob:**/example/scalalib/linting/1-scalafmt/src/Foo.scala"
]
}

Expand All @@ -37,4 +34,5 @@ fileOverride {
"glob:**/example/**/build.sc" {
docstrings.style = keep
}
"glob:**/example/scalalib/native/**/*.scala" = scala3
}
7 changes: 3 additions & 4 deletions example/scalalib/native/1-simple/src/Foo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import scala.scalanative.unsafe._
import mainargs.{main, ParserForMethods}

object Foo {
def generateHtml(text: String) (using Zone) = {

def generateHtml(text: String)(using Zone) = {
val html = "<h1>" + text + "</h1>\n"

val cResult = toCString(html)
cResult

}

@main
Expand All @@ -21,4 +21,3 @@ object Foo {

def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args)
}

5 changes: 2 additions & 3 deletions example/scalalib/native/4-common-config/src/Foo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ import fansi._

object Foo {

def generateHtml(text: String) (using Zone) = {
def generateHtml(text: String)(using Zone) = {
val colored = Console.RED + "<h1>" + text + "</h1>" + Console.RESET

val cResult = toCString(colored)
cResult
}

def main(args: Array[String]): Unit = Zone {
val value = generateHtml("hello")
stdio.printf(c"Value: %s\n", value)
}
}

0 comments on commit 845f5c9

Please sign in to comment.