about summary refs log tree commit diff
path: root/src/docs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-10-25 00:14:59 +0000
committerbors <bors@rust-lang.org>2022-10-25 00:14:59 +0000
commit039af9c9e758d010dad7610fe543ffcc2b1bdd8a (patch)
tree3cad38bc5015ed99c4d17c3f5ca79b7e1495d31e /src/docs
parentb698a151b3eb1c6cd6a70d3e9d9d0aab2711f672 (diff)
parentb9b9d6a751ca3a9ccdd64f50390361e339f5124f (diff)
Auto merge of #9667 - dorublanzeanu:master, r=giraffate
add new lint `seek_to_start_instead_of_rewind `

changelog: `seek_to_start_instead_of_rewind`: new lint to suggest using `rewind` instead of `seek` to start

Resolve #8600
Diffstat (limited to 'src/docs')
-rw-r--r--src/docs/seek_to_start_instead_of_rewind.txt22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/docs/seek_to_start_instead_of_rewind.txt b/src/docs/seek_to_start_instead_of_rewind.txt
new file mode 100644
index 00000000000..bef11b2312a
--- /dev/null
+++ b/src/docs/seek_to_start_instead_of_rewind.txt
@@ -0,0 +1,22 @@
+### What it does
+
+Checks for jumps to the start of a stream that implements `Seek`
+and uses the `seek` method providing `Start` as parameter.
+
+### Why is this bad?
+
+Readability. There is a specific method that was implemented for
+this exact scenario.
+
+### Example
+```
+fn foo<T: io::Seek>(t: &mut T) {
+    t.seek(io::SeekFrom::Start(0));
+}
+```
+Use instead:
+```
+fn foo<T: io::Seek>(t: &mut T) {
+    t.rewind();
+}
+```
\ No newline at end of file