Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust: Update builtins and sample file #1922

Closed
nsfisis opened this issue Jan 28, 2023 · 0 comments
Closed

rust: Update builtins and sample file #1922

nsfisis opened this issue Jan 28, 2023 · 0 comments
Labels
bugfix-request A request for a bugfix to be developed.

Comments

@nsfisis
Copy link
Contributor

nsfisis commented Jan 28, 2023

Lexer

rust

Versions

  • Rouge: 4.0.1
  • Rust: 1.66

Problems

  • Rouge::Lexers::Rust#builtins()
    • The list has many removed structs/traits.
    • Some important built-in items are not included.
  • The sample file, spec/visual/samples/rust
    • It is written in very old version of Rust (pre-1.0, I guess).

Proposals

The built-in items

Things that should be removed

  • Cons
  • Const
  • Either
  • Failure
  • Gc
  • Left
  • Modulo
  • Nil
  • Num
  • Ptr
  • Right
  • Success

These structs or traits are not defined in newer versions of Rust, at least v1.66.

Things that should be added

Based on std::prelude: https://doc.rust-lang.org/std/prelude/index.html

  • FromIterator
  • ToOwned
  • ToString
  • TryFrom
  • TryInto

You can use any items in std::prelude module without importing.

The sample file

The sample file may be written in pre-1.0 Rust.

  • io::println => println!
    • Removed function
  • impl<A> &[A]: iterable<A> { ... } => impl<A> iterable<A> for &[A] { ... }
    • Removed syntax
  • for vec::each(self) |e| { ... } => for e in v.iter() { ... }
    • Removed syntax
  • assert some_expr => assert!(some_expr)
    • Removed syntax
  • 5...6 => 5..=6
    • Removed syntax
  • tag(~str, ~[HTMLFragment]) => Tag(String, Vec<Box<HTMLFragment>>)
    • Removed syntax

EDIT:

  • fn<'a> pointer(&'a u32) {} => fn pointer<'a>(n: &'a u32) {}
    • Removed syntax
  • int => i32
    • Removed type
  • uint => usize
    • Removed type
@nsfisis nsfisis added the bugfix-request A request for a bugfix to be developed. label Jan 28, 2023
nsfisis added a commit to nsfisis/rouge that referenced this issue Jan 28, 2023
nsfisis added a commit to nsfisis/rouge that referenced this issue Jan 28, 2023
@tancnle tancnle closed this as completed in d3df530 Apr 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix-request A request for a bugfix to be developed.
Projects
None yet
Development

No branches or pull requests

1 participant