edlang/ariadne/trait.Span.html

24 lines
16 KiB
HTML
Raw Normal View History

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="A trait implemented by spans within a character-based source."><title>Span in ariadne - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-dd39b87e5fcfba68.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="ariadne" data-themes="" data-resource-suffix="" data-rustdoc-version="1.80.0 (051478957 2024-07-21)" data-channel="1.80.0" data-search-js="search-d52510db62a78183.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-118b08c4c78b968e.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-df360f571f6edeae.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../ariadne/index.html">ariadne</a><span class="version">0.4.1</span></h2></div><h2 class="location"><a href="#">Span</a></h2><div class="sidebar-elems"><section><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.SourceId">SourceId</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.end">end</a></li><li><a href="#tymethod.source">source</a></li><li><a href="#tymethod.start">start</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.contains">contains</a></li><li><a href="#method.is_empty">is_empty</a></li><li><a href="#method.len">len</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-Span-for-(Id,+Range%3Cusize%3E)">(Id, Range&lt;usize&gt;)</a></li><li><a href="#impl-Span-for-Range%3Cusize%3E">Range&lt;usize&gt;</a></li></ul><h3><a href="#object-safety">Object Safety</a></h3><h3><a href="#implementors">Implementors</a></h3></section><h2><a href="index.html">In crate ariadne</a></h2></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Trait <a href="index.html">ariadne</a>::<wbr><a class="trait" href="#">Span</a><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><span class="out-of-band"><a class="src" href="../src/ariadne/lib.rs.html#29-62">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><pre class="rust item-decl"><code>pub trait Span {
type <a href="#associatedtype.SourceId" class="associatedtype">SourceId</a>: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>;
// Required methods
fn <a href="#tymethod.source" class="fn">source</a>(&amp;self) -&gt; &amp;Self::<a class="associatedtype" href="trait.Span.html#associatedtype.SourceId" title="type ariadne::Span::SourceId">SourceId</a>;
<span class="item-spacer"></span> fn <a href="#tymethod.start" class="fn">start</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.usize.html">usize</a>;
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fn">end</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.usize.html">usize</a>;
// Provided methods
fn <a href="#method.len" class="fn">len</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.usize.html">usize</a> { ... }
<span class="item-spacer"></span> fn <a href="#method.is_empty" class="fn">is_empty</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a> { ... }
<span class="item-spacer"></span> fn <a href="#method.contains" class="fn">contains</a>(&amp;self, offset: <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.usize.html">usize</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a> { ... }
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A trait implemented by spans within a character-based source.</p>
</div></details><h2 id="required-associated-types" class="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.SourceId" class="method"><a class="src rightside" href="../src/ariadne/lib.rs.html#31">source</a><h4 class="code-header">type <a href="#associatedtype.SourceId" class="associatedtype">SourceId</a>: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></h4></section></summary><div class="docblock"><p>The identifier used to uniquely refer to a source. In most cases, this is the fully-qualified path of the file.</p>
</div></details></div><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.source" class="method"><a class="src rightside" href="../src/ariadne/lib.rs.html#34">source</a><h4 class="code-header">fn <a href="#tymethod.source" class="fn">source</a>(&amp;self) -&gt; &amp;Self::<a class="associatedtype" href="trait.Span.html#associatedtype.SourceId" title="type ariadne::Span::SourceId">SourceId</a></h4></section></summary><div class="docblock"><p>Get the identifier of the source that this span refers to.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.start" class="method"><a class="src rightside" href="../src/ariadne/lib.rs.html#39">source</a><h4 class="code-header">fn <a href="#tymethod.start" class="fn">start</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>Get the start offset of this span.</p>
<p>Offsets are zero-indexed character offsets from the beginning of the source.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.end" class="method"><a class="src rightside" href="../src/ariadne/lib.rs.html#46">source</a><h4 class="code-header">fn <a href="#tymethod.end" class="fn">end</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>Get the (exclusive) end offset of this span.</p>
<p>The end offset should <em>always</em> be greater than or equal to the start offset as given by <a href="trait.Span.html#tymethod.start" title="method ariadne::Span::start"><code>Span::start</code></a>.</p>
<p>Offsets are zero-indexed character offsets from the beginning of the source.</p>
</div></details></div><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.len" class="method"><a class="src rightside" href="../src/ariadne/lib.rs.html#49-51">source</a><h4 class="code-header">fn <a href="#method.len" class="fn">len</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>Get the length of this span (difference between the start of the span and the end of the span).</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_empty" class="method"><a class="src rightside" href="../src/ariadne/lib.rs.html#54-56">source</a><h4 class="code-header">fn <a href="#method.is_empty" class="fn">is_empty</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if this span has length zero.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.contains" class="method"><a class="src rightside" href="../src/ariadne/lib.rs.html#59-61">source</a><h4 class="code-header">fn <a href="#method.contains" class="fn">contains</a>(&amp;self, offset: <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.usize.html">usize</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Determine whether the span contains the given offset.</p>
</div></details></div><h2 id="object-safety" class="section-header">Object Safety<a href="#object-safety" class="anchor">§</a></h2><div class="object-safety-info">This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.80.0/reference/items/traits.html#object-safety">object safe</a>.</div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-Span-for-Range%3Cusize%3E" class="impl"><a class="src rightside" href="../src/ariadne/lib.rs.html#64-76">source</a><a href="#impl-Span-for-Range%3Cusize%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Span.html" title="trait ariadne::Span">Span</a> for <a class="struct" href="https://doc.rust-lang.org/1.80.0/core/ops/range/struct.Range.html" title="struct core::ops::range::Range">Range</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.usize.html">usize</a>&gt;</h3></section></summary><div class="impl-items"><section id="associatedtype.SourceId-1" class="associatedtype trait-impl"><a href="#associatedtype.SourceId-1" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.SourceId" class="associatedtype">SourceId</a> = <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.unit.html">()</a></h4></section><section id="method.source" class="method trait-impl"><a class="src rightside" href="../src/ariadne/lib.rs.html#67-69">source</a><a href="#method.source" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.source" class="fn">source</a>(&amp;self) -&gt; &amp;Self::<a class="associatedtype" href="trait.Span.html#associatedtype.SourceId" title="type ariadne::Span::SourceId">SourceId</a></h4></section><section id="method.start" class="method trait-impl"><a class="src rightside" href="../src/ariadne/lib.rs.html#70-72">source</a><a href="#method.start" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.start" class="fn">start</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.usize.html">usize</a></h4></section><section id="method.end" class="method trait-impl"><a class="src rightside" href="../src/ariadne/lib.rs.html#73-75">source</a><a href="#method.end" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.end" class="fn">end</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.usize.html">usize</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Span-for-(Id,+Range%3Cusize%3E)" class="impl"><a class="src rightside" href="../src/ariadne/lib.rs.html#78-90">source</a><a href="#impl-Span-for-(Id,+Range%3Cusize%3E)" class="anchor">§</a><h3 class="code-header">impl&lt;Id: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a>&gt; <a class="trait" href="trait.Span.html" title="trait ariadne::Span">Span</a> for (Id, <a class="struct" href="https://doc.rust-lang.org/1.80.0/core/ops/range/struct.Range.html" title="struct core::ops::range::Range">Range</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.usize.html">usize</a>&gt;)</h3></section></summary><div class="impl-items"><section id="associatedtype.SourceId-2" class="associatedtype trait-impl"><a href="#associatedtype.SourceId-2" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype