diff --git a/backend/code-execution-service/main.go b/backend/code-execution-service/main.go index 26273fc..8c77fab 100644 --- a/backend/code-execution-service/main.go +++ b/backend/code-execution-service/main.go @@ -59,6 +59,13 @@ func executeCode(language string, code string) (string, error) { return string(cmdOutput), err } cmd = exec.Command(tmpFile.Name()[:len(tmpFile.Name())-4]) + case "rs": + execCmd := exec.Command("rustc", tmpFile.Name()) + if err := execCmd.Run(); err != nil { + cmdOutput,_ := execCmd.CombinedOutput() + + return string(cmdOutput), err + } case "java": tmpFileName := filepath.Join(os.TempDir(), "Main.java") tmpFile, err = os.Create(tmpFileName) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 5556980..916430b 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -14,7 +14,7 @@ import { useNavigate } from "react-router-dom"; import "devicon/devicon.min.css"; -type Language = "c" | "cpp" | "python" | "java" | "go"; +type Language = "c" | "cpp" | "python" | "java" | "go" | "rs"; const INITIAL_CODE: Record = { c: '#include \n\nint main() {\n printf("Hello world !"); \n return 0; \n}', @@ -22,6 +22,7 @@ const INITIAL_CODE: Record = { python: 'print("Hello, World!")', java: 'public class Main {\n public static void main(String[] args) {\n System.out.println("Hello, World!");\n }\n}', go: 'package main\n\nimport "fmt"\n\nfunc main() {\n fmt.Println("Hello, World!")\n}', + rust: 'fn main() {\n\tprintln!("Hello world !")\n}' }; const LANGUAGE_CONFIGS = { @@ -30,10 +31,11 @@ const LANGUAGE_CONFIGS = { python: { label: "Python", icon: "devicon-python-plain colored" , color: "text-yellow-500" }, java: { label: "Java", icon: "devicon-java-plain colored", color: "text-red-500" }, go: { label: "Go", icon: "devicon-go-plain colored", color: "text-cyan-500" }, + rust: { label: "Rust", icon: "devicon-rust-original colored", color: "text-red-500"} }; function App() { - const [selectedLanguage, setSelectedLanguage] = useState("go"); + const [selectedLanguage, setSelectedLanguage] = useState("c"); const [code, setCode] = useState(INITIAL_CODE[selectedLanguage]); const [output, setOutput] = useState("Output will appear here..."); const [editorInstance, setEditorInstance] = useState(null);