Skip to content

Commit dbbcbe9

Browse files
committed
Lints
1 parent 7d6c846 commit dbbcbe9

File tree

8 files changed

+64
-65
lines changed

8 files changed

+64
-65
lines changed

crates/bevy_ecs/src/system/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ use super::{Res, ResMut, SystemState};
106106
///
107107
/// The implementor must ensure that the state returned
108108
/// from [`SystemParamBuilder::build`] is valid for `P`.
109-
/// Note that the exact safety requiremensts depend on the implementation of [`SystemParam`],
109+
/// Note that the exact safety requirements depend on the implementation of [`SystemParam`],
110110
/// so if `Self` is not a local type then you must call [`SystemParam::init_state`]
111111
/// or another [`SystemParamBuilder::build`].
112112
pub unsafe trait SystemParamBuilder<P: SystemParam>: Sized {

crates/bevy_text/src/undo_2/README.md

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Undo done the right way!
1+
# Undo done the right way
22

3-
Via https://gitlab.com/okannen/undo_2/-/tree/b32c34edb2c15c266b946f0d82188624f3aa3fdc
3+
Via [](https://gitlab.com/okannen/undo_2/-/tree/b32c34edb2c15c266b946f0d82188624f3aa3fdc)
44

55
## Introduction
66

@@ -10,34 +10,33 @@ end of the Undo history as a precursor to your new change. I found the idea in
1010
[zaboople/klong][zaboople]. This crate is an implementation
1111
of this idea with a minor variation explained below.
1212

13-
As an example consider the following sequence of commands:
13+
As an example consider the following sequence of commands:
1414

1515
| Command | State |
1616
| ------- | ----- |
17-
| Init | |
17+
| Init | |
1818
| Do A | A |
1919
| Do B | A, B |
20-
| Undo | A |
21-
| Do C | A, C |
20+
| Undo | A |
21+
| Do C | A, C |
2222

23-
With the **classical undo**, repeated undo would lead to the sequence:
23+
With the **classical undo**, repeated undo would lead to the sequence:
2424

2525
| Command | State |
2626
|---------|-------|
2727
| | A, C |
2828
| Undo | A |
29-
| Undo | |
30-
29+
| Undo | |
3130

32-
Starting from 5, with **undo_2**, repeating undo would lead to the sequence:
31+
Starting from 5, with **undo_2**, repeating undo would lead to the sequence:
3332

3433
| Command | State |
3534
|---------|-------|
3635
| | A, C |
3736
| Undo | A |
38-
| Undo | A,B |
39-
| Undo | A |
40-
| Undo | |
37+
| Undo | A,B |
38+
| Undo | A |
39+
| Undo | |
4140

4241
**undo_2**'s undo navigates back in history, while classical undo navigates back
4342
through the sequence of command that builds the state.
@@ -53,7 +52,7 @@ and it is similar to vim :earlier.
5352
4. very lightweight, dumb and simple.
5453
5. possibility to merge and splice commands.
5554

56-
## How to use it
55+
## How to use it
5756

5857
Add the dependency to the cargo file:
5958

@@ -74,7 +73,7 @@ be interpreted by the application. This design pattern makes implementation
7473
easier because it is not necessary to borrow data within the stored list of
7574
commands.
7675

77-
```
76+
```rs
7877
use undo_2::{Commands,Action};
7978
use Action::{Do,Undo};
8079

@@ -156,22 +155,22 @@ assert_eq!(editor.text, "a");
156155
forming the sequence are merged. This makes the traversal of the undo
157156
sequence more concise by avoiding state duplication.
158157

159-
| Command | State | Comment |
158+
| Command | State | Comment |
160159
|---------|------- |----------------------|
161-
| Init | | |
160+
| Init | | |
162161
| Do A | A | |
163162
| Do B | A,B | |
164163
| Do C | A, B, C | |
165-
| Undo | A, B |Merged |
166-
| Undo | A |Merged |
167-
| Do D | A, D | |
164+
| Undo | A, B |Merged |
165+
| Undo | A |Merged |
166+
| Do D | A, D | |
168167
| Undo | A |Redo the 2 Merged Undo|
169-
| Undo | A, B, C | |
170-
| Undo | A, B | |
171-
| Undo | A | |
172-
| Undo | | |
168+
| Undo | A, B, C | |
169+
| Undo | A, B | |
170+
| Undo | A | |
171+
| Undo | | |
173172

174-
2. Each execution of an undos or redo may lead to the execution of a sequence of
173+
1. Each execution of an undos or redo may lead to the execution of a sequence of
175174
actions in the form `Undo(a)+Do(b)+Do(c)`. Basic arithmetic is implemented
176175
assuming that `Do(a)+Undo(a)` is equivalent to not doing anything (here the
177176
2 `a`'s designate the same entity, not to equal objects).
@@ -249,13 +248,15 @@ assert_eq!(editor.text, "az12");
249248
```
250249

251250
## Release note
251+
252252
### Version 0.3
253-
- [Action] is now an enum taking commands, the list of command to be
254-
executed is of the form [Action<T>];
255-
- added [Commands::can_undo] and [Commands::can_redo];
256-
- added [Commands::rebuild], which correspond to the classical redo;
257-
- fixed a bug in [Commands::undo_or_redo_to_index]
258-
- Added support for special commands that represent a state setting. See [SetOrTransition].
253+
254+
- [`Action`] is now an enum taking commands, the list of command to be
255+
executed is of the form [`Action<T>`];
256+
- added [`Commands::can_undo`] and [`Commands::can_redo`];
257+
- added [`Commands::rebuild`], which correspond to the classical redo;
258+
- fixed a bug in [`Commands::undo_or_redo_to_index`]
259+
- Added support for special commands that represent a state setting. See [`SetOrTransition`].
259260

260261
[zaboople]: https://github.com/zaboople/klonk/blob/master/TheGURQ.md
261262

crates/bevy_text/src/undo_2/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
mod lib;
32
mod tests;
43

crates/bevy_text/src/undo_2/tests/merge.rs

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
use crate::undo_2::*;
2-
31
#[test]
42
fn merge() {
5-
use std::ops::ControlFlow;
63
use crate::undo_2::CommandItem;
4+
use crate::undo_2::Commands;
75
use crate::undo_2::IterRealized;
86
use crate::undo_2::Merge;
7+
use std::ops::ControlFlow;
98
#[derive(Eq, PartialEq, Debug)]
109
enum Command {
1110
A,
@@ -15,7 +14,7 @@ fn merge() {
1514
}
1615
use Command::*;
1716
fn is_ab(mut it: IterRealized<'_, Command>) -> (bool, IterRealized<'_, Command>) {
18-
let cond = it.next() == Some(&Command::B) && it.next() == Some(&Command::A);
17+
let cond = it.next() == Some(&B) && it.next() == Some(&A);
1918
(cond, it)
2019
}
2120
fn parse(
@@ -25,27 +24,27 @@ fn merge() {
2524
ControlFlow::Continue(Some(Merge {
2625
start,
2726
end,
28-
command: Some(Command::AB),
27+
command: Some(AB),
2928
}))
3029
} else {
3130
ControlFlow::Continue(None)
3231
}
3332
}
3433
{
3534
let mut commands = Commands::new();
36-
commands.push(Command::A);
37-
commands.push(Command::B);
35+
commands.push(A);
36+
commands.push(B);
3837

3938
commands.merge(parse);
40-
assert_eq!(*commands, [CommandItem::Command(Command::AB)]);
39+
assert_eq!(*commands, [CommandItem::Command(AB)]);
4140
}
4241
{
4342
let mut commands = Commands::new();
44-
commands.push(Command::A);
45-
commands.push(Command::C);
46-
commands.push(Command::B);
47-
commands.push(Command::A);
48-
commands.push(Command::B);
43+
commands.push(A);
44+
commands.push(C);
45+
commands.push(B);
46+
commands.push(A);
47+
commands.push(B);
4948

5049
commands.merge(parse);
5150
assert_eq!(
@@ -60,13 +59,13 @@ fn merge() {
6059
}
6160
{
6261
let mut commands = Commands::new();
63-
commands.push(Command::A);
64-
commands.push(Command::C);
65-
commands.push(Command::A);
66-
commands.push(Command::B);
67-
commands.push(Command::B);
68-
commands.push(Command::A);
69-
commands.push(Command::B);
62+
commands.push(A);
63+
commands.push(C);
64+
commands.push(A);
65+
commands.push(B);
66+
commands.push(B);
67+
commands.push(A);
68+
commands.push(B);
7069

7170
commands.merge(parse);
7271
assert_eq!(
@@ -82,10 +81,10 @@ fn merge() {
8281
}
8382
{
8483
let mut commands = Commands::new();
85-
commands.push(Command::A);
86-
commands.push(Command::B);
87-
commands.push(Command::A);
88-
commands.push(Command::B);
84+
commands.push(A);
85+
commands.push(B);
86+
commands.push(A);
87+
commands.push(B);
8988

9089
commands.merge(parse);
9190
assert_eq!(

crates/bevy_text/src/undo_2/tests/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
mod iter_realized;
32
mod merge;
43
mod redo;

crates/bevy_text/src/undo_2/tests/set_and_transition.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::mem::{discriminant, Discriminant};
22

3-
use crate::undo_2::{Commands, IndepStateKey, SetOrTransition, SetTransAction};
3+
use crate::undo_2::{IndepStateKey, SetTransAction};
44

55
#[derive(Copy, Clone, Debug)]
66
struct State {
@@ -67,7 +67,7 @@ enum TransitionCommand {
6767

6868
#[test]
6969
fn set_and_transition() {
70-
use SetOrTransition::*;
70+
use crate::undo_2::{Commands, SetOrTransition::*};
7171
let mut commands = Commands::new();
7272
let mut state = State::new();
7373

crates/bevy_text/src/undo_2/tests/splice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![allow(unused)]
22

3-
use std::ops::ControlFlow;
43
use crate::undo_2::*;
4+
use std::ops::ControlFlow;
55

66
#[derive(PartialEq, Debug)]
77
enum Command {

typos.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
[files]
22
extend-exclude = [
3-
"*.pbxproj", # metadata file
4-
"*.patch", # Automatically generated files that should not be manually modified.
5-
"*.bin", # Binary files
6-
".git/", # Version control files
3+
"*.pbxproj", # metadata file
4+
"*.patch", # Automatically generated files that should not be manually modified.
5+
"*.bin", # Binary files
6+
".git/", # Version control files
7+
"crates/bevy_text/src/undo_2/", # undo_2
78
]
89
ignore-hidden = false
910

0 commit comments

Comments
 (0)