about summary refs log tree commit diff
path: root/src/docs
diff options
context:
space:
mode:
Diffstat (limited to 'src/docs')
-rw-r--r--src/docs/rewind_instead_of_seek_to_start.txt22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/docs/rewind_instead_of_seek_to_start.txt b/src/docs/rewind_instead_of_seek_to_start.txt
new file mode 100644
index 00000000000..bef11b2312a
--- /dev/null
+++ b/src/docs/rewind_instead_of_seek_to_start.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