Skip to content

Commit

Permalink
Added trailing commas required by nightly cargo fmt
Browse files Browse the repository at this point in the history
Nightly cargo fmt seems to have added new rules since the last commit,
so the code (including code that I didn't touch in this PR) doesn't
past `cargo fmt +nightly -- --check` anymore.
  • Loading branch information
boazy committed Oct 17, 2024
1 parent 45061fd commit ada43b8
Showing 1 changed file with 45 additions and 44 deletions.
89 changes: 45 additions & 44 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl<const OSC_RAW_BUF_SIZE: usize> Parser<OSC_RAW_BUF_SIZE> {
Action::None => (),
action => {
self.perform_action(performer, action, $arg);
}
},
}
};
}
Expand All @@ -180,18 +180,18 @@ impl<const OSC_RAW_BUF_SIZE: usize> Parser<OSC_RAW_BUF_SIZE> {
State::Anywhere => {
// Just run the action
self.perform_action(performer, action, byte);
}
},
state => {
match self.state {
State::DcsPassthrough => {
self.perform_action(performer, Action::Unhook, byte);
}
},
State::OscString => {
self.perform_action(performer, Action::OscEnd, byte);
}
},
State::OpaqueString => {
self.perform_action(performer, Action::OpaqueEnd, byte);
}
},
_ => (),
}

Expand All @@ -200,22 +200,22 @@ impl<const OSC_RAW_BUF_SIZE: usize> Parser<OSC_RAW_BUF_SIZE> {
match state {
State::CsiEntry | State::DcsEntry | State::Escape => {
self.perform_action(performer, Action::Clear, byte);
}
},
State::DcsPassthrough => {
self.perform_action(performer, Action::Hook, byte);
}
},
State::OscString => {
self.perform_action(performer, Action::OscStart, byte);
}
},
State::OpaqueString => {
self.perform_action(performer, Action::OpaqueStart, byte);
}
},
_ => (),
}

// Assume the new state
self.state = state;
}
},
}
}

Expand Down Expand Up @@ -252,12 +252,12 @@ impl<const OSC_RAW_BUF_SIZE: usize> Parser<OSC_RAW_BUF_SIZE> {
}

performer.hook(self.params(), self.intermediates(), self.ignoring, byte as char);
}
},
Action::Put => performer.put(byte),
Action::OscStart => {
self.osc_raw.clear();
self.osc_num_params = 0;
}
},
Action::OscPut => {
#[cfg(feature = "no_std")]
{
Expand All @@ -278,21 +278,21 @@ impl<const OSC_RAW_BUF_SIZE: usize> Parser<OSC_RAW_BUF_SIZE> {
// First param is special - 0 to current byte index
0 => {
self.osc_params[param_idx] = (0, idx);
}
},

// All other params depend on previous indexing
_ => {
let prev = self.osc_params[param_idx - 1];
let begin = prev.1;
self.osc_params[param_idx] = (begin, idx);
}
},
}

self.osc_num_params += 1;
} else {
self.osc_raw.push(byte);
}
}
},
Action::OscEnd => {
let param_idx = self.osc_num_params;
let idx = self.osc_raw.len();
Expand All @@ -305,18 +305,18 @@ impl<const OSC_RAW_BUF_SIZE: usize> Parser<OSC_RAW_BUF_SIZE> {
0 => {
self.osc_params[param_idx] = (0, idx);
self.osc_num_params += 1;
}
},

// All other params depend on previous indexing
_ => {
let prev = self.osc_params[param_idx - 1];
let begin = prev.1;
self.osc_params[param_idx] = (begin, idx);
self.osc_num_params += 1;
}
},
}
self.osc_dispatch(performer, byte);
}
},
Action::Unhook => performer.unhook(),
Action::CsiDispatch => {
if self.params.is_full() {
Expand All @@ -331,18 +331,18 @@ impl<const OSC_RAW_BUF_SIZE: usize> Parser<OSC_RAW_BUF_SIZE> {
self.ignoring,
byte as char,
);
}
},
Action::EscDispatch => {
performer.esc_dispatch(self.intermediates(), self.ignoring, byte);
}
},
Action::Collect => {
if self.intermediate_idx == MAX_INTERMEDIATES {
self.ignoring = true;
} else {
self.intermediates[self.intermediate_idx] = byte;
self.intermediate_idx += 1;
}
}
},
Action::Param => {
if self.params.is_full() {
self.ignoring = true;
Expand All @@ -360,15 +360,15 @@ impl<const OSC_RAW_BUF_SIZE: usize> Parser<OSC_RAW_BUF_SIZE> {
self.param = self.param.saturating_mul(10);
self.param = self.param.saturating_add((byte - b'0') as u16);
}
}
},
Action::Clear => {
// Reset everything on ESC/CSI/DCS entry
self.intermediate_idx = 0;
self.ignoring = false;
self.param = 0;

self.params.clear();
}
},
Action::BeginUtf8 => self.process_utf8(performer, byte),
Action::Ignore => (),
Action::None => (),
Expand All @@ -392,7 +392,7 @@ impl<const OSC_RAW_BUF_SIZE: usize> Parser<OSC_RAW_BUF_SIZE> {
OpaqueSequenceKind::Pm => performer.pm_start(),
OpaqueSequenceKind::Apc => performer.apc_start(),
}
}
},
Action::OpaquePut => {
match self.opaque_sequence_kind {
Some(OpaqueSequenceKind::Sos) => performer.sos_put(byte),
Expand All @@ -402,7 +402,7 @@ impl<const OSC_RAW_BUF_SIZE: usize> Parser<OSC_RAW_BUF_SIZE> {
// that the opaque_sequence_kind is set to a Some(x) value.
None => unreachable!("opaque sequence kind not set"),
}
}
},
Action::OpaqueEnd => {
match self.opaque_sequence_kind {
Some(OpaqueSequenceKind::Sos) => performer.sos_end(),
Expand All @@ -413,7 +413,7 @@ impl<const OSC_RAW_BUF_SIZE: usize> Parser<OSC_RAW_BUF_SIZE> {
None => unreachable!("opaque sequence kind not set"),
}
self.opaque_sequence_kind = None;
}
},
}
}
}
Expand Down Expand Up @@ -470,7 +470,8 @@ pub trait Perform {
_intermediates: &[u8],
_ignore: bool,
_action: char,
) {}
) {
}

/// The final character of an escape sequence has arrived.
///
Expand Down Expand Up @@ -639,7 +640,7 @@ mod tests {
assert_eq!(params.len(), 2);
assert_eq!(params[0], &OSC_BYTES[2..3]);
assert_eq!(params[1], &OSC_BYTES[4..(OSC_BYTES.len() - 1)]);
}
},
_ => panic!("expected osc sequence"),
}
}
Expand Down Expand Up @@ -676,7 +677,7 @@ mod tests {
Sequence::Osc(params, _) => {
assert_eq!(params.len(), MAX_OSC_PARAMS);
assert!(params.iter().all(Vec::is_empty));
}
},
_ => panic!("expected osc sequence"),
}
}
Expand Down Expand Up @@ -734,7 +735,7 @@ mod tests {
Sequence::Osc(params, _) => {
assert_eq!(params[0], &[b'2']);
assert_eq!(params[1], &INPUT[5..(INPUT.len() - 1)]);
}
},
_ => panic!("expected osc sequence"),
}
}
Expand All @@ -753,7 +754,7 @@ mod tests {
match &dispatcher.dispatched[0] {
Sequence::Osc(params, _) => {
assert_eq!(params[1], &INPUT[4..(INPUT.len() - 2)]);
}
},
_ => panic!("expected osc sequence"),
}
}
Expand Down Expand Up @@ -859,7 +860,7 @@ mod tests {

#[cfg(feature = "no_std")]
assert_eq!(params[1].len(), MAX_OSC_RAW - params[0].len());
}
},
_ => panic!("expected osc sequence"),
}
}
Expand All @@ -884,7 +885,7 @@ mod tests {
Sequence::Csi(params, _, ignore, _) => {
assert_eq!(params.len(), params::MAX_PARAMS);
assert!(!ignore);
}
},
_ => panic!("expected csi sequence"),
}
}
Expand All @@ -909,7 +910,7 @@ mod tests {
Sequence::Csi(params, _, ignore, _) => {
assert_eq!(params.len(), params::MAX_PARAMS);
assert!(ignore);
}
},
_ => panic!("expected csi sequence"),
}
}
Expand Down Expand Up @@ -981,7 +982,7 @@ mod tests {
assert_eq!(intermediates, &[b'?']);
assert_eq!(params, &[[1049]]);
assert!(!ignore);
}
},
_ => panic!("expected csi sequence"),
}
}
Expand All @@ -1002,7 +1003,7 @@ mod tests {
assert_eq!(params, &[vec![38, 2, 255, 0, 255], vec![1]]);
assert_eq!(intermediates, &[]);
assert!(!ignore);
}
},
_ => panic!("expected csi sequence"),
}
}
Expand All @@ -1024,7 +1025,7 @@ mod tests {
assert_eq!(params.len(), params::MAX_PARAMS);
assert!(params.iter().all(|param| param == &[1]));
assert!(ignore);
}
},
_ => panic!("expected dcs sequence"),
}
}
Expand All @@ -1045,7 +1046,7 @@ mod tests {
assert_eq!(intermediates, &[b'$']);
assert_eq!(params, &[[1]]);
assert!(!ignore);
}
},
_ => panic!("expected dcs sequence"),
}
assert_eq!(dispatcher.dispatched[1], Sequence::DcsPut(b'x'));
Expand All @@ -1067,7 +1068,7 @@ mod tests {
Sequence::DcsHook(params, _, _, c) => {
assert_eq!(params, &[[0], [1]]);
assert_eq!(c, &'|');
}
},
_ => panic!("expected dcs sequence"),
}
for (i, byte) in b"17/ab".iter().enumerate() {
Expand Down Expand Up @@ -1109,7 +1110,7 @@ mod tests {
assert_eq!(intermediates, &[b'(']);
assert_eq!(*byte, b'A');
assert!(!ignore);
}
},
_ => panic!("expected esc sequence"),
}
}
Expand All @@ -1131,7 +1132,7 @@ mod tests {
assert_eq!(params, &[[0; 32]]);
assert_eq!(c, &'x');
assert!(ignore);
}
},
_ => panic!("expected csi sequence"),
}
}
Expand All @@ -1153,7 +1154,7 @@ mod tests {
assert_eq!(intermediates, &[b'?']);
assert_eq!(params, &[[1049]]);
assert!(!ignore);
}
},
_ => panic!("expected csi sequence"),
}
}
Expand Down Expand Up @@ -1193,7 +1194,7 @@ mod tests {
for item in params[1].iter() {
assert_eq!(*item, b'a');
}
}
},
_ => panic!("expected osc sequence"),
}
}
Expand Down Expand Up @@ -1223,7 +1224,7 @@ mod tests {
Sequence::Osc(params, false) => {
assert_eq!(params[0], b"2");
assert_eq!(params[1], INPUT_MIDDLE);
}
},
_ => panic!("expected osc sequence"),
}
}
Expand Down

0 comments on commit ada43b8

Please sign in to comment.