edlang/ariadne/trait.Span.html

23 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><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-5bc39a1768837dd0.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.77.2 (25ef9e3d8 2024-04-09)" data-channel="1.77.2" data-search-js="search-dd67cee4cfa65049.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-4c98445ec4002617.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-48f368f3872407c8.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-04d5337699b92874.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-16x16-8b506e7a72182f1c.png"><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.0</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.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"><nav class="sub"><form class="search-form"><span></span><div id="sidebar-button" tabindex="-1"><a href="../ariadne/all.html" title="show sidebar"></a></div><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" tabindex="-1"><a href="../help.html" title="help">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><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"><img src="../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="src" href="../src/ariadne/lib.rs.html#29-53">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.77.2/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a> + <a class="trait" href="https://doc.rust-lang.org/1.77.2/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.77.2/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.77.2/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.77.2/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.77.2/std/primitive.usize.html">usize</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.77.2/std/primitive.usize.html">usize</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.77.2/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.77.2/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a> + <a class="trait" href="https://doc.rust-lang.org/1.77.2/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.77.2/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.77.2/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.77.2/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">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.77.2/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.contains" class="method"><a class="src rightside" href="../src/ariadne/lib.rs.html#52">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.77.2/std/primitive.usize.html">usize</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.77.2/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.77.2/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#55-61">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.77.2/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.77.2/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.77.2/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#58">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#59">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.77.2/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#60">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.77.2/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#63-69">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.77.2/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> + <a class="trait" href="https://doc.rust-lang.org/1.77.2/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> + <a class="trait" href="https://doc.rust-lang.org/1.77.2/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a> + <a class="trait" href="https://doc.rust-lang.org/1.77.2/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/1.77.2/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.77.2/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.77.2/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.SourceId