MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / try_assign

Method try_assign

cranelift/assembler-x64/meta/src/dsl/encoding.rs:534–554  ·  view source on GitHub ↗

Attempt to parse a `byte` as a prefix and, if successful, assigns it to the correct prefix group. # Panics This function panics if the prefix for a group is already set; this disallows specifying multiple prefixes per group.

(&mut self, byte: u8)

Source from the content-addressed store, hash-verified

532 /// This function panics if the prefix for a group is already set; this
533 /// disallows specifying multiple prefixes per group.
534 fn try_assign(&mut self, byte: u8) -> Result<(), ()> {
535 if let Ok(p) = Group1Prefix::try_from(byte) {
536 assert!(self.group1.is_none());
537 self.group1 = Some(p);
538 Ok(())
539 } else if let Ok(p) = Group2Prefix::try_from(byte) {
540 assert!(self.group2.is_none());
541 self.group2 = Some(p);
542 Ok(())
543 } else if let Ok(p) = Group3Prefix::try_from(byte) {
544 assert!(self.group3.is_none());
545 self.group3 = Some(p);
546 Ok(())
547 } else if let Ok(p) = Group4Prefix::try_from(byte) {
548 assert!(self.group4.is_none());
549 self.group4 = Some(p);
550 Ok(())
551 } else {
552 Err(())
553 }
554 }
555
556 /// Check if any prefix is present.
557 pub fn is_empty(&self) -> bool {

Callers 1

parseMethod · 0.80

Calls 1

OkFunction · 0.85

Tested by

no test coverage detected