You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.5 KiB

7 months ago
  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>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
  10. <div id=nav>
  11. <a href="https://codemirror.net/5"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></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/codemirror5">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> = i32;
  27. enum bar {
  28. Some(i32, foo<f32>),
  29. None
  30. }
  31. fn check_crate(x: i32) {
  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>