Instantly convert code snippets from Rust to Scala with our free online code converter. Transform your code easily and accurately.
Experience the full potential of AI-driven code conversion and transformation!
We prioritize your code's security and privacy. Your code is not stored on our servers and is only temporarily processed for conversion. We use OpenAI's secure servers for the conversion process, ensuring your code remains confidential.
Rust is a multi-paradigm programming language focused on performance and safety, especially safe concurrency.
Scala is a general-purpose programming language providing support for functional programming and a strong static type system.
fn is_palindrome(s: &str) -> bool {
let clean: String = s.chars()
.filter(|c| c.is_alphanumeric())
.map(|c| c.to_ascii_lowercase())
.collect();
clean.chars().eq(clean.chars().rev())
}
fn main() {
println!("{}", is_palindrome("A man, a plan, a canal: Panama")); // true
println!("{}", is_palindrome("race a car")); // false
}
object PalindromeChecker {
def isPalindrome(str: String): Boolean = {
val clean = str.toLowerCase.filter(_.isLetterOrDigit)
clean == clean.reverse
}
def main(args: Array[String]): Unit = {
println(isPalindrome("A man, a plan, a canal: Panama")) // true
println(isPalindrome("race a car")) // false
}
}
fn bubble_sort(arr: &mut [i32]) {
let n = arr.len();
for i in 0..n {
for j in 0..n - i - 1 {
if arr[j] > arr[j + 1] {
arr.swap(j, j + 1);
}
}
}
}
fn main() {
let mut arr = vec![64, 34, 25, 12, 22, 11, 90];
bubble_sort(&mut arr);
println!("{:?}", arr);
}
object BubbleSort {
def bubbleSort(arr: Array[Int]): Array[Int] = {
val n = arr.length
for (i <- 0 until n; j <- 0 until n - i - 1) {
if (arr(j) > arr(j + 1)) {
val temp = arr(j)
arr(j) = arr(j + 1)
arr(j + 1) = temp
}
}
arr
}
def main(args: Array[String]): Unit = {
val arr = Array(64, 34, 25, 12, 22, 11, 90)
println(bubbleSort(arr).mkString(" "))
}
}
Convert Rust to Python
Open ConverterConvert Rust to JavaScript
Open ConverterConvert Rust to TypeScript
Open ConverterConvert Rust to Java
Open ConverterConvert Rust to C
Open ConverterConvert Rust to C++
Open ConverterConvert Rust to C#
Open ConverterConvert Rust to Go
Open ConverterConvert Rust to Dart
Open ConverterConvert Rust to Ruby
Open ConverterConvert Rust to Swift
Open ConverterConvert Rust to Kotlin
Open ConverterConvert Rust to PHP
Open ConverterConvert Rust to R
Open ConverterConvert Rust to Haskell
Open ConverterConvert Rust to Julia
Open ConverterConvert Rust to MATLAB
Open ConverterConvert Rust to Lua
Open ConverterConvert Rust to Assembly
Open ConverterConvert Rust to Perl
Open ConverterConvert Rust to Groovy
Open ConverterConvert Rust to Elixir
Open ConverterConvert Rust to F#
Open ConverterConvert Rust to Clojure
Open ConverterConvert Rust to Delphi
Open Converter