PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, December 12, 2022

[FIXED] What does "=>" mean in Rust?

 December 12, 2022     rust, syntax     No comments   

Issue

I am trying to modify the VGA buffer's character. I don't understand the meaning of =>:

b'\n' => self.new_line()

Solution

The context matters. I imagine this is probably from the middle of a match statement like this:

match foo {
    b'\n' => self.new_line(),
    // If foo is any other byte, do nothing (empty code block).
    _ => {}
}

In this case, b'\n' => self.new_line() roughly means "If the thing I am trying to match is the byte for a new line, call self.new_line()".

match a {
    // If a matches b do c, otherwise try next case
    b => c,
    // etc.
}

In C this would probably look a bit more like this:

switch (foo) {
    case '\n':
        new_line(self);
        break;
    // etc.
}


Answered By - Locke
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing