index.html 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <!doctype html>
  2. <title>CodeMirror: Rust mode</title>
  3. <meta charset="utf-8"/>
  4. <link rel=stylesheet href="../../doc/docs.css">
  5. <link rel="stylesheet" href="../../lib/codemirror.css">
  6. <script src="../../lib/codemirror.js"></script>
  7. <script src="../../addon/mode/simple.js"></script>
  8. <script src="rust.js"></script>
  9. <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
  10. <div id=nav>
  11. <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
  12. <ul>
  13. <li><a href="../../index.html">Home</a>
  14. <li><a href="../../doc/manual.html">Manual</a>
  15. <li><a href="https://github.com/codemirror/codemirror">Code</a>
  16. </ul>
  17. <ul>
  18. <li><a href="../index.html">Language modes</a>
  19. <li><a class=active href="#">Rust</a>
  20. </ul>
  21. </div>
  22. <article>
  23. <h2>Rust mode</h2>
  24. <div><textarea id="code" name="code">
  25. // Demo code.
  26. type foo<T> = int;
  27. enum bar {
  28. some(int, foo<float>),
  29. none
  30. }
  31. fn check_crate(x: int) {
  32. let v = 10;
  33. match foo {
  34. 1 ... 3 {
  35. print_foo();
  36. if x {
  37. blah().to_string();
  38. }
  39. }
  40. (x, y) { "bye" }
  41. _ { "hi" }
  42. }
  43. }
  44. </textarea></div>
  45. <script>
  46. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  47. lineNumbers: true,
  48. lineWrapping: true,
  49. indentUnit: 4,
  50. mode: "rust"
  51. });
  52. </script>
  53. <p><strong>MIME types defined:</strong> <code>text/x-rustsrc</code>.</p>
  54. </article>