You've already forked uutils.github.io
mirror of
https://github.com/uutils/uutils.github.io.git
synced 2026-06-10 16:12:28 -07:00
deploy: f0e8d44e6e
This commit is contained in:
@@ -319,6 +319,7 @@
|
||||
<a href="#319" id="319">319</a>
|
||||
<a href="#320" id="320">320</a>
|
||||
<a href="#321" id="321">321</a>
|
||||
<a href="#322" id="322">322</a>
|
||||
</pre></div><pre class="rust"><code><span class="comment">// * This file is part of the uutils coreutils package.
|
||||
// *
|
||||
// * (c) Michael Debertol <michael.debertol..AT..gmail.com>
|
||||
@@ -337,21 +338,22 @@
|
||||
};
|
||||
|
||||
<span class="kw">use </span>memchr::memchr_iter;
|
||||
<span class="kw">use </span>ouroboros::self_referencing;
|
||||
<span class="kw">use </span>self_cell::self_cell;
|
||||
<span class="kw">use </span>uucore::error::{UResult, USimpleError};
|
||||
|
||||
<span class="kw">use crate</span>::{numeric_str_cmp::NumInfo, GeneralF64ParseResult, GlobalSettings, Line, SortError};
|
||||
|
||||
<span class="doccomment">/// The chunk that is passed around between threads.
|
||||
/// `lines` consist of slices into `buffer`.
|
||||
</span><span class="attr">#[self_referencing(pub_extras)]
|
||||
#[derive(Debug)]
|
||||
</span><span class="kw">pub struct </span>Chunk {
|
||||
<span class="kw">pub </span>buffer: Vec<u8>,
|
||||
<span class="attr">#[borrows(buffer)]
|
||||
#[covariant]
|
||||
</span><span class="kw">pub </span>contents: ChunkContents<<span class="lifetime">'this</span>>,
|
||||
}
|
||||
<span class="macro">self_cell!</span>(
|
||||
<span class="doccomment">/// The chunk that is passed around between threads.
|
||||
</span><span class="kw">pub struct </span>Chunk {
|
||||
owner: Vec<u8>,
|
||||
|
||||
<span class="attr">#[covariant]
|
||||
</span>dependent: ChunkContents,
|
||||
}
|
||||
|
||||
<span class="kw">impl </span>{Debug}
|
||||
);
|
||||
|
||||
<span class="attr">#[derive(Debug)]
|
||||
</span><span class="kw">pub struct </span>ChunkContents<<span class="lifetime">'a</span>> {
|
||||
@@ -369,7 +371,7 @@
|
||||
<span class="kw">impl </span>Chunk {
|
||||
<span class="doccomment">/// Destroy this chunk and return its components to be reused.
|
||||
</span><span class="kw">pub fn </span>recycle(<span class="kw-2">mut </span><span class="self">self</span>) -> RecycledChunk {
|
||||
<span class="kw">let </span>recycled_contents = <span class="self">self</span>.with_contents_mut(|contents| {
|
||||
<span class="kw">let </span>recycled_contents = <span class="self">self</span>.with_dependent_mut(|<span class="kw">_</span>, contents| {
|
||||
contents.lines.clear();
|
||||
contents.line_data.selections.clear();
|
||||
contents.line_data.num_infos.clear();
|
||||
@@ -402,15 +404,15 @@
|
||||
selections: recycled_contents.<span class="number">1</span>,
|
||||
num_infos: recycled_contents.<span class="number">2</span>,
|
||||
parsed_floats: recycled_contents.<span class="number">3</span>,
|
||||
buffer: <span class="self">self</span>.into_heads().buffer,
|
||||
buffer: <span class="self">self</span>.into_owner(),
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">pub fn </span>lines(<span class="kw-2">&</span><span class="self">self</span>) -> <span class="kw-2">&</span>Vec<Line> {
|
||||
<span class="kw-2">&</span><span class="self">self</span>.borrow_contents().lines
|
||||
<span class="kw-2">&</span><span class="self">self</span>.borrow_dependent().lines
|
||||
}
|
||||
<span class="kw">pub fn </span>line_data(<span class="kw-2">&</span><span class="self">self</span>) -> <span class="kw-2">&</span>LineData {
|
||||
<span class="kw-2">&</span><span class="self">self</span>.borrow_contents().line_data
|
||||
<span class="kw-2">&</span><span class="self">self</span>.borrow_dependent().line_data
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -444,7 +444,7 @@
|
||||
<span class="doccomment">/// The function that is executed on the sorter thread.
|
||||
</span><span class="kw">fn </span>sorter(receiver: <span class="kw-2">&</span>Receiver<Chunk>, sender: <span class="kw-2">&</span>SyncSender<Chunk>, settings: <span class="kw-2">&</span>GlobalSettings) {
|
||||
<span class="kw">while let </span><span class="prelude-val">Ok</span>(<span class="kw-2">mut </span>payload) = receiver.recv() {
|
||||
payload.with_contents_mut(|contents| {
|
||||
payload.with_dependent_mut(|<span class="kw">_</span>, contents| {
|
||||
sort_by(<span class="kw-2">&mut </span>contents.lines, settings, <span class="kw-2">&</span>contents.line_data);
|
||||
});
|
||||
<span class="kw">if </span>sender.send(payload).is_err() {
|
||||
|
||||
@@ -843,7 +843,7 @@
|
||||
file_number: file.file_number,
|
||||
});
|
||||
|
||||
file.current_chunk.with_contents(|contents| {
|
||||
file.current_chunk.with_dependent(|<span class="kw">_</span>, contents| {
|
||||
<span class="kw">let </span>current_line = <span class="kw-2">&</span>contents.lines[file.line_idx];
|
||||
<span class="kw">if </span>settings.unique {
|
||||
<span class="kw">if let </span><span class="prelude-val">Some</span>(prev) = <span class="kw-2">&</span>prev {
|
||||
|
||||
@@ -765,15 +765,6 @@
|
||||
<a href="#765" id="765">765</a>
|
||||
<a href="#766" id="766">766</a>
|
||||
<a href="#767" id="767">767</a>
|
||||
<a href="#768" id="768">768</a>
|
||||
<a href="#769" id="769">769</a>
|
||||
<a href="#770" id="770">770</a>
|
||||
<a href="#771" id="771">771</a>
|
||||
<a href="#772" id="772">772</a>
|
||||
<a href="#773" id="773">773</a>
|
||||
<a href="#774" id="774">774</a>
|
||||
<a href="#775" id="775">775</a>
|
||||
<a href="#776" id="776">776</a>
|
||||
</pre></div><pre class="rust"><code><span class="comment">// TODO fix broken links
|
||||
</span><span class="attr">#![allow(rustdoc::broken_intra_doc_links)]
|
||||
</span><span class="doccomment">//! All utils return exit with an exit code. Usually, the following scheme is used:
|
||||
@@ -1172,7 +1163,7 @@
|
||||
<span class="kw">fn </span>fmt(<span class="kw-2">&</span><span class="self">self</span>, f: <span class="kw-2">&mut </span>Formatter<<span class="lifetime">'_</span>>) -> <span class="prelude-ty">Result</span><(), std::fmt::Error> {
|
||||
<span class="kw">use </span>std::io::ErrorKind::<span class="kw-2">*</span>;
|
||||
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>message;
|
||||
<span class="kw">let </span>message;
|
||||
<span class="kw">let </span>message = <span class="kw">if </span><span class="self">self</span>.inner.raw_os_error().is_some() {
|
||||
<span class="comment">// These are errors that come directly from the OS.
|
||||
// We want to normalize their messages across systems,
|
||||
@@ -1200,7 +1191,6 @@
|
||||
// (https://github.com/rust-lang/rust/issues/86442)
|
||||
// are stabilized, we should add them to the match statement.
|
||||
</span>message = strip_errno(<span class="kw-2">&</span><span class="self">self</span>.inner);
|
||||
capitalize(<span class="kw-2">&mut </span>message);
|
||||
<span class="kw-2">&</span>message
|
||||
}
|
||||
}
|
||||
@@ -1211,7 +1201,6 @@
|
||||
// a file that was not found.
|
||||
// There are also errors with entirely custom messages.
|
||||
</span>message = <span class="self">self</span>.inner.to_string();
|
||||
capitalize(<span class="kw-2">&mut </span>message);
|
||||
<span class="kw-2">&</span>message
|
||||
};
|
||||
<span class="kw">if let </span><span class="prelude-val">Some</span>(ctx) = <span class="kw-2">&</span><span class="self">self</span>.context {
|
||||
@@ -1222,13 +1211,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
<span class="doccomment">/// Capitalize the first character of an ASCII string.
|
||||
</span><span class="kw">fn </span>capitalize(text: <span class="kw-2">&mut </span>str) {
|
||||
<span class="kw">if let </span><span class="prelude-val">Some</span>(first) = text.get_mut(..<span class="number">1</span>) {
|
||||
first.make_ascii_uppercase();
|
||||
}
|
||||
}
|
||||
|
||||
<span class="doccomment">/// Strip the trailing " (os error XX)" from io error strings.
|
||||
</span><span class="kw">pub fn </span>strip_errno(err: <span class="kw-2">&</span>std::io::Error) -> String {
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>msg = err.to_string();
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user