448 lines
124 KiB
HTML
448 lines
124 KiB
HTML
<!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="Stores elements of a certain type in a 2D grid structure."><title>Grid in grid - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.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-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="grid" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.0 (9fc6b4312 2025-01-07)" data-channel="1.84.0" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc struct"><!--[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="../grid/index.html">grid</a><span class="version">0.14.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Grid</a></h2><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.clear" title="clear">clear</a></li><li><a href="#method.cols" title="cols">cols</a></li><li><a href="#method.fill" title="fill">fill</a></li><li><a href="#method.fill_with" title="fill_with">fill_with</a></li><li><a href="#method.flatten" title="flatten">flatten</a></li><li><a href="#method.flip_cols" title="flip_cols">flip_cols</a></li><li><a href="#method.flip_rows" title="flip_rows">flip_rows</a></li><li><a href="#method.from_vec" title="from_vec">from_vec</a></li><li><a href="#method.from_vec_with_order" title="from_vec_with_order">from_vec_with_order</a></li><li><a href="#method.get" title="get">get</a></li><li><a href="#method.get_mut" title="get_mut">get_mut</a></li><li><a href="#method.get_unchecked" title="get_unchecked">get_unchecked</a></li><li><a href="#method.get_unchecked_mut" title="get_unchecked_mut">get_unchecked_mut</a></li><li><a href="#method.indexed_iter" title="indexed_iter">indexed_iter</a></li><li><a href="#method.indexed_iter_mut" title="indexed_iter_mut">indexed_iter_mut</a></li><li><a href="#method.init" title="init">init</a></li><li><a href="#method.init_with_order" title="init_with_order">init_with_order</a></li><li><a href="#method.insert_col" title="insert_col">insert_col</a></li><li><a href="#method.insert_row" title="insert_row">insert_row</a></li><li><a href="#method.into_vec" title="into_vec">into_vec</a></li><li><a href="#method.is_empty" title="is_empty">is_empty</a></li><li><a href="#method.iter" title="iter">iter</a></li><li><a href="#method.iter_col" title="iter_col">iter_col</a></li><li><a href="#method.iter_col_mut" title="iter_col_mut">iter_col_mut</a></li><li><a href="#method.iter_cols" title="iter_cols">iter_cols</a></li><li><a href="#method.iter_mut" title="iter_mut">iter_mut</a></li><li><a href="#method.iter_row" title="iter_row">iter_row</a></li><li><a href="#method.iter_row_mut" title="iter_row_mut">iter_row_mut</a></li><li><a href="#method.iter_rows" title="iter_rows">iter_rows</a></li><li><a href="#method.new" title="new">new</a></li><li><a href="#method.new_with_order" title="new_with_order">new_with_order</a></li><li><a href="#method.order" title="order">order</a></li><li><a href="#method.pop_col" title="pop_col">pop_col</a></li><li><a href="#method.pop_row" title="pop_row">pop_row</a></li><li><a href="#method.push_col" title="push_col">push_col</a></li><li><a href="#method.push_row" title="push_row">push_row</a></li><li><a href="#method.remove_col" title="remove_col">remove_col</a></li><li><a href="#method.remove_row" title="remove_row">remove_row</a></li><li><a href="#method.rotate_half" title="rotate_half">rotate_half</a></li><li><a href="#method.rotate_left" title="rotate_left">rotate_left</a></li><li><a href="#method.rotate_right" title="rotate_right">rotate_right</a></li><li><a href="#method.rows" title="rows">rows</a></li><li><a href="#method.size" title="size">size</a></li><li><a href="#method.transpose" title="transpose">transpose</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Clone-for-Grid%3CT%3E" title="Clone">Clone</a></li><li><a href="#impl-Debug-for-Grid%3CT%3E" title="Debug">Debug</a></li><li><a href="#impl-Default-for-Grid%3CT%3E" title="Default">Default</a></li><li><a href="#impl-Eq-for-Grid%3CT%3E" title="Eq">Eq</a></li><li><a href="#impl-From%3C%26Vec%3C%26Vec%3CT%3E%3E%3E-for-Grid%3CT%3E" title="From<&Vec<&Vec<T>>>">From<&Vec<&Vec<T>>></a></li><li><a href="#impl-From%3C%26Vec%3CVec%3CT%3E%3E%3E-for-Grid%3CT%3E" title="From<&Vec<Vec<T>>>">From<&Vec<Vec<T>>></a></li><li><a href="#impl-From%3C(%26Vec%3CT%3E,+%26usize)%3E-for-Grid%3CT%3E" title="From<(&Vec<T>, &usize)>">From<(&Vec<T>, &usize)></a></li><li><a href="#impl-From%3C(%26Vec%3CT%3E,+usize)%3E-for-Grid%3CT%3E" title="From<(&Vec<T>, usize)>">From<(&Vec<T>, usize)></a></li><li><a href="#impl-From%3C(Vec%3CT%3E,+usize)%3E-for-Grid%3CT%3E" title="From<(Vec<T>, usize)>">From<(Vec<T>, usize)></a></li><li><a href="#impl-From%3CVec%3CVec%3CT%3E%3E%3E-for-Grid%3CT%3E" title="From<Vec<Vec<T>>>">From<Vec<Vec<T>>></a></li><li><a href="#impl-Hash-for-Grid%3CT%3E" title="Hash">Hash</a></li><li><a href="#impl-Index%3C(usize,+usize)%3E-for-Grid%3CT%3E" title="Index<(usize, usize)>">Index<(usize, usize)></a></li><li><a href="#impl-IndexMut%3C(usize,+usize)%3E-for-Grid%3CT%3E" title="IndexMut<(usize, usize)>">IndexMut<(usize, usize)></a></li><li><a href="#impl-PartialEq-for-Grid%3CT%3E" title="PartialEq">PartialEq</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-Freeze-for-Grid%3CT%3E" title="Freeze">Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-Grid%3CT%3E" title="RefUnwindSafe">RefUnwindSafe</a></li><li><a href="#impl-Send-for-Grid%3CT%3E" title="Send">Send</a></li><li><a href="#impl-Sync-for-Grid%3CT%3E" title="Sync">Sync</a></li><li><a href="#impl-Unpin-for-Grid%3CT%3E" title="Unpin">Unpin</a></li><li><a href="#impl-UnwindSafe-for-Grid%3CT%3E" title="UnwindSafe">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T" title="Any">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T" title="Borrow<T>">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T" title="BorrowMut<T>">BorrowMut<T></a></li><li><a href="#impl-CloneToUninit-for-T" title="CloneToUninit">CloneToUninit</a></li><li><a href="#impl-From%3CT%3E-for-T" title="From<T>">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-T" title="Into<U>">Into<U></a></li><li><a href="#impl-ToOwned-for-T" title="ToOwned">ToOwned</a></li><li><a href="#impl-TryFrom%3CU%3E-for-T" title="TryFrom<U>">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-T" title="TryInto<U>">TryInto<U></a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate grid</a></h2></div></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"><span class="rustdoc-breadcrumbs"><a href="index.html">grid</a></span><h1>Struct <span class="struct">Grid</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/grid/lib.rs.html#215-220">Source</a> </span></div><pre class="rust item-decl"><code>pub struct Grid<T> { <span class="comment">/* private fields */</span> }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Stores elements of a certain type in a 2D grid structure.</p>
|
||
<p>Uses a rust <code>Vec<T></code> type to reference the grid data on the heap.
|
||
Also the internal memory layout as well as the number of
|
||
rows and columns are stored in the grid data structure.</p>
|
||
<p>The size limit of a grid is <code>rows * cols < usize</code>.</p>
|
||
</div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Grid%3CT%3E" class="impl"><a class="src rightside" href="../src/grid/lib.rs.html#318-1474">Source</a><a href="#impl-Grid%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="struct" href="struct.Grid.html" title="struct grid::Grid">Grid</a><T></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.new" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#338-343">Source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a>(rows: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>, cols: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>) -> Self<div class="where">where
|
||
T: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/default/trait.Default.html" title="trait core::default::Default">Default</a>,</div></h4></section></summary><div class="docblock"><p>Init a grid of size rows x columns with default values of the given type.
|
||
For example this will generate a 2x3 grid of zeros:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::Grid;
|
||
<span class="kw">let </span>grid : Grid<u8> = Grid::new(<span class="number">2</span>,<span class="number">3</span>);
|
||
<span class="macro">assert_eq!</span>(grid[(<span class="number">0</span>, <span class="number">0</span>)], <span class="number">0</span>);</code></pre></div>
|
||
<p>If <code>rows == 0</code> or <code>cols == 0</code> the grid will be empty with no cols and rows.</p>
|
||
<p>This create a grid with a row-major memory layout.
|
||
If you need a column-major one, see <a href="struct.Grid.html#method.new_with_order" title="associated function grid::Grid::new_with_order"><code>new_with_order</code></a>.</p>
|
||
<h5 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h5>
|
||
<p>Panics if <code>rows * cols > usize::MAX</code>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.new_with_order" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#350-370">Source</a><h4 class="code-header">pub fn <a href="#method.new_with_order" class="fn">new_with_order</a>(rows: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>, cols: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>, order: <a class="enum" href="enum.Order.html" title="enum grid::Order">Order</a>) -> Self<div class="where">where
|
||
T: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/default/trait.Default.html" title="trait core::default::Default">Default</a>,</div></h4></section></summary><div class="docblock"><p>Same as <a href="struct.Grid.html#method.new" title="associated function grid::Grid::new"><code>new</code></a> but with a specific <a href="enum.Order.html" title="enum grid::Order"><code>Order</code></a>.</p>
|
||
<h5 id="panics-1"><a class="doc-anchor" href="#panics-1">§</a>Panics</h5>
|
||
<p>Panics if <code>rows * cols > usize::MAX</code>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.init" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#383-388">Source</a><h4 class="code-header">pub fn <a href="#method.init" class="fn">init</a>(rows: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>, cols: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>, data: T) -> Self<div class="where">where
|
||
T: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</div></h4></section></summary><div class="docblock"><p>Init a grid of size rows x columns with the given data element.</p>
|
||
<p>If <code>rows == 0</code> or <code>cols == 0</code> the grid will be empty with no cols and rows.</p>
|
||
<p>This create a grid with a row-major memory layout.
|
||
If you need a column-major one, see <a href="struct.Grid.html#method.init_with_order" title="associated function grid::Grid::init_with_order"><code>init_with_order</code></a>.</p>
|
||
<h5 id="panics-2"><a class="doc-anchor" href="#panics-2">§</a>Panics</h5>
|
||
<p>Panics if <code>rows * cols > usize::MAX</code>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.init_with_order" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#395-413">Source</a><h4 class="code-header">pub fn <a href="#method.init_with_order" class="fn">init_with_order</a>(rows: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>, cols: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>, order: <a class="enum" href="enum.Order.html" title="enum grid::Order">Order</a>, data: T) -> Self<div class="where">where
|
||
T: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</div></h4></section></summary><div class="docblock"><p>Same as <a href="struct.Grid.html#method.init" title="associated function grid::Grid::init"><code>init</code></a> but with a specific <a href="enum.Order.html" title="enum grid::Order"><code>Order</code></a>.</p>
|
||
<h5 id="panics-3"><a class="doc-anchor" href="#panics-3">§</a>Panics</h5>
|
||
<p>Panics if <code>rows * cols > usize::MAX</code>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.from_vec" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#445-447">Source</a><h4 class="code-header">pub fn <a href="#method.from_vec" class="fn">from_vec</a>(vec: <a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>, cols: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>) -> Self</h4></section></summary><div class="docblock"><p>Returns a grid from a vector with a given column length.
|
||
The length of <code>vec</code> must be a multiple of <code>cols</code>.</p>
|
||
<p>This create a grid with a row-major memory layout.
|
||
If you need a column-major one, see <a href="struct.Grid.html#method.from_vec_with_order" title="associated function grid::Grid::from_vec_with_order"><code>from_vec_with_order</code></a>.</p>
|
||
<p>For example:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::Grid;
|
||
<span class="kw">let </span>grid = Grid::from_vec(<span class="macro">vec!</span>[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>,<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>], <span class="number">3</span>);
|
||
<span class="macro">assert_eq!</span>(grid.size(), (<span class="number">2</span>, <span class="number">3</span>));</code></pre></div>
|
||
<p>will create a grid with the following layout:
|
||
[1,2,3]
|
||
[4,5,6]</p>
|
||
<p>This example will fail, because <code>vec.len()</code> is not a multiple of <code>cols</code>:</p>
|
||
|
||
<div class="example-wrap should_panic"><a href="#" class="tooltip" title="This example panics">ⓘ</a><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::Grid;
|
||
Grid::from_vec(<span class="macro">vec!</span>[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>,<span class="number">4</span>,<span class="number">5</span>], <span class="number">3</span>);</code></pre></div>
|
||
<h5 id="panics-4"><a class="doc-anchor" href="#panics-4">§</a>Panics</h5>
|
||
<p>This panics if the vector length isn’t a multiple of the number of columns.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.from_vec_with_order" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#455-479">Source</a><h4 class="code-header">pub fn <a href="#method.from_vec_with_order" class="fn">from_vec_with_order</a>(vec: <a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>, cols: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>, order: <a class="enum" href="enum.Order.html" title="enum grid::Order">Order</a>) -> Self</h4></section></summary><div class="docblock"><p>Same as <a href="struct.Grid.html#method.from_vec" title="associated function grid::Grid::from_vec"><code>from_vec</code></a> but with a specific <a href="enum.Order.html" title="enum grid::Order"><code>Order</code></a>.</p>
|
||
<h5 id="panics-5"><a class="doc-anchor" href="#panics-5">§</a>Panics</h5>
|
||
<p>This panics if the vector length isn’t a multiple of the number of columns.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_unchecked" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#499-502">Source</a><h4 class="code-header">pub unsafe fn <a href="#method.get_unchecked" class="fn">get_unchecked</a>(
|
||
&self,
|
||
row: impl <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>>,
|
||
col: impl <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>>,
|
||
) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.reference.html">&T</a></h4></section></summary><div class="docblock"><p>Returns a reference to an element, without performing bound checks.
|
||
Generally not recommended, use with caution!</p>
|
||
<h5 id="safety"><a class="doc-anchor" href="#safety">§</a>Safety</h5>
|
||
<p>Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_unchecked_mut" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#512-519">Source</a><h4 class="code-header">pub unsafe fn <a href="#method.get_unchecked_mut" class="fn">get_unchecked_mut</a>(
|
||
&mut self,
|
||
row: impl <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>>,
|
||
col: impl <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>>,
|
||
) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.reference.html">&mut T</a></h4></section></summary><div class="docblock"><p>Returns a mutable reference to an element, without performing bound checks.
|
||
Generally not recommended, use with caution!</p>
|
||
<h5 id="safety-1"><a class="doc-anchor" href="#safety-1">§</a>Safety</h5>
|
||
<p>Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.get" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#524-532">Source</a><h4 class="code-header">pub fn <a href="#method.get" class="fn">get</a>(
|
||
&self,
|
||
row: impl <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>>,
|
||
col: impl <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>>,
|
||
) -> <a class="enum" href="https://doc.rust-lang.org/1.84.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.reference.html">&T</a>></h4></section></summary><div class="docblock"><p>Access a certain element in the grid.
|
||
Returns <code>None</code> if an element beyond the grid bounds is tried to be accessed.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_mut" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#537-549">Source</a><h4 class="code-header">pub fn <a href="#method.get_mut" class="fn">get_mut</a>(
|
||
&mut self,
|
||
row: impl <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>>,
|
||
col: impl <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>>,
|
||
) -> <a class="enum" href="https://doc.rust-lang.org/1.84.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.reference.html">&mut T</a>></h4></section></summary><div class="docblock"><p>Mutable access to a certain element in the grid.
|
||
Returns <code>None</code> if an element beyond the grid bounds is tried to be accessed.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.size" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#554-556">Source</a><h4 class="code-header">pub fn <a href="#method.size" class="fn">size</a>(&self) -> (<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>, <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>)</h4></section></summary><div class="docblock"><p>Returns the size of the grid as a two element tuple.
|
||
First element are the number of rows and the second the columns.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.rows" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#560-562">Source</a><h4 class="code-header">pub fn <a href="#method.rows" class="fn">rows</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>Returns the number of rows of the grid.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.cols" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#566-568">Source</a><h4 class="code-header">pub fn <a href="#method.cols" class="fn">cols</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>Returns the number of columns of the grid.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.order" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#572-574">Source</a><h4 class="code-header">pub fn <a href="#method.order" class="fn">order</a>(&self) -> <a class="enum" href="enum.Order.html" title="enum grid::Order">Order</a></h4></section></summary><div class="docblock"><p>Returns the internal memory layout of the grid.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_empty" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#584-586">Source</a><h4 class="code-header">pub fn <a href="#method.is_empty" class="fn">is_empty</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if the grid contains no elements.
|
||
For example:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span>grid : Grid<u8> = <span class="macro">grid!</span>[];
|
||
<span class="macro">assert!</span>(grid.is_empty());</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.clear" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#591-595">Source</a><h4 class="code-header">pub fn <a href="#method.clear" class="fn">clear</a>(&mut self)</h4></section></summary><div class="docblock"><p>Clears the grid.</p>
|
||
<p>This doesn’t change the grid order.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.iter" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#613-615">Source</a><h4 class="code-header">pub fn <a href="#method.iter" class="fn">iter</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/1.84.0/core/slice/iter/struct.Iter.html" title="struct core::slice::iter::Iter">Iter</a><'_, T></h4></section></summary><div class="docblock"><p>Returns an iterator over the whole grid, starting from the first row and column.</p>
|
||
<p>The iteration order is dependant on the internal memory layout.
|
||
If you need a specific order, see <a href="struct.Grid.html#method.iter_rows" title="method grid::Grid::iter_rows"><code>iter_rows</code></a> or
|
||
<a href="struct.Grid.html#method.iter_cols" title="method grid::Grid::iter_cols"><code>iter_cols</code></a>.</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span>grid: Grid<u8> = <span class="macro">grid!</span>[[<span class="number">1</span>,<span class="number">2</span>][<span class="number">3</span>,<span class="number">4</span>]];
|
||
<span class="kw">let </span><span class="kw-2">mut </span>iter = grid.iter();
|
||
<span class="macro">assert_eq!</span>(iter.next(), <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">1</span>));
|
||
<span class="macro">assert_eq!</span>(iter.next(), <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">2</span>));
|
||
<span class="macro">assert_eq!</span>(iter.next(), <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">3</span>));
|
||
<span class="macro">assert_eq!</span>(iter.next(), <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">4</span>));
|
||
<span class="macro">assert_eq!</span>(iter.next(), <span class="prelude-val">None</span>);</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.iter_mut" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#629-631">Source</a><h4 class="code-header">pub fn <a href="#method.iter_mut" class="fn">iter_mut</a>(&mut self) -> <a class="struct" href="https://doc.rust-lang.org/1.84.0/core/slice/iter/struct.IterMut.html" title="struct core::slice::iter::IterMut">IterMut</a><'_, T></h4></section></summary><div class="docblock"><p>Returns an mutable iterator over the whole grid that allows modifying each value.</p>
|
||
<p>The iteration order is dependant on the internal memory layout.</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span><span class="kw-2">mut </span>grid: Grid<u8> = <span class="macro">grid!</span>[[<span class="number">1</span>,<span class="number">2</span>][<span class="number">3</span>,<span class="number">4</span>]];
|
||
<span class="kw">let </span><span class="kw-2">mut </span>iter = grid.iter_mut();
|
||
<span class="kw">let </span>next = iter.next();
|
||
<span class="macro">assert_eq!</span>(next, <span class="prelude-val">Some</span>(<span class="kw-2">&mut </span><span class="number">1</span>));
|
||
<span class="kw-2">*</span>next.unwrap() = <span class="number">10</span>;</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.iter_col" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#654-668">Source</a><h4 class="code-header">pub fn <a href="#method.iter_col" class="fn">iter_col</a>(&self, col: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>) -> <a class="struct" href="https://doc.rust-lang.org/1.84.0/core/iter/adapters/step_by/struct.StepBy.html" title="struct core::iter::adapters::step_by::StepBy">StepBy</a><<a class="struct" href="https://doc.rust-lang.org/1.84.0/core/slice/iter/struct.Iter.html" title="struct core::slice::iter::Iter">Iter</a><'_, T>></h4></section></summary><div class="docblock"><p>Returns an iterator over a column.</p>
|
||
<h5 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span>grid: Grid<u8> = <span class="macro">grid!</span>[[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>][<span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>]];
|
||
<span class="kw">let </span><span class="kw-2">mut </span>col_iter = grid.iter_col(<span class="number">1</span>);
|
||
<span class="macro">assert_eq!</span>(col_iter.next(), <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">2</span>));
|
||
<span class="macro">assert_eq!</span>(col_iter.next(), <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">4</span>));
|
||
<span class="macro">assert_eq!</span>(col_iter.next(), <span class="prelude-val">None</span>);</code></pre></div>
|
||
<h5 id="performance"><a class="doc-anchor" href="#performance">§</a>Performance</h5>
|
||
<p>This method will be significantly slower if the grid uses a row-major memory layout,
|
||
which is the default.</p>
|
||
<h5 id="panics-6"><a class="doc-anchor" href="#panics-6">§</a>Panics</h5>
|
||
<p>Panics if the col index is out of bounds.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.iter_col_mut" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#692-706">Source</a><h4 class="code-header">pub fn <a href="#method.iter_col_mut" class="fn">iter_col_mut</a>(&mut self, col: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>) -> <a class="struct" href="https://doc.rust-lang.org/1.84.0/core/iter/adapters/step_by/struct.StepBy.html" title="struct core::iter::adapters::step_by::StepBy">StepBy</a><<a class="struct" href="https://doc.rust-lang.org/1.84.0/core/slice/iter/struct.IterMut.html" title="struct core::slice::iter::IterMut">IterMut</a><'_, T>></h4></section></summary><div class="docblock"><p>Returns a mutable iterator over a column.</p>
|
||
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span><span class="kw-2">mut </span>grid: Grid<u8> = <span class="macro">grid!</span>[[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>][<span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>]];
|
||
<span class="kw">let </span><span class="kw-2">mut </span>col_iter = grid.iter_col_mut(<span class="number">1</span>);
|
||
<span class="kw">let </span>next = col_iter.next();
|
||
<span class="macro">assert_eq!</span>(next, <span class="prelude-val">Some</span>(<span class="kw-2">&mut </span><span class="number">2</span>));
|
||
<span class="kw-2">*</span>next.unwrap() = <span class="number">10</span>;
|
||
<span class="macro">assert_eq!</span>(grid[(<span class="number">0</span>, <span class="number">1</span>)], <span class="number">10</span>);</code></pre></div>
|
||
<h5 id="performance-1"><a class="doc-anchor" href="#performance-1">§</a>Performance</h5>
|
||
<p>This method will be significantly slower if the grid uses a row-major memory layout,
|
||
which is the default.</p>
|
||
<h5 id="panics-7"><a class="doc-anchor" href="#panics-7">§</a>Panics</h5>
|
||
<p>Panics if the col index is out of bounds.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.iter_row" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#729-743">Source</a><h4 class="code-header">pub fn <a href="#method.iter_row" class="fn">iter_row</a>(&self, row: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>) -> <a class="struct" href="https://doc.rust-lang.org/1.84.0/core/iter/adapters/step_by/struct.StepBy.html" title="struct core::iter::adapters::step_by::StepBy">StepBy</a><<a class="struct" href="https://doc.rust-lang.org/1.84.0/core/slice/iter/struct.Iter.html" title="struct core::slice::iter::Iter">Iter</a><'_, T>></h4></section></summary><div class="docblock"><p>Returns an iterator over a row.</p>
|
||
<h5 id="examples-2"><a class="doc-anchor" href="#examples-2">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span>grid: Grid<u8> = <span class="macro">grid!</span>[[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>][<span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>]];
|
||
<span class="kw">let </span><span class="kw-2">mut </span>col_iter = grid.iter_row(<span class="number">1</span>);
|
||
<span class="macro">assert_eq!</span>(col_iter.next(), <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">3</span>));
|
||
<span class="macro">assert_eq!</span>(col_iter.next(), <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">4</span>));
|
||
<span class="macro">assert_eq!</span>(col_iter.next(), <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">5</span>));
|
||
<span class="macro">assert_eq!</span>(col_iter.next(), <span class="prelude-val">None</span>);</code></pre></div>
|
||
<h5 id="performance-2"><a class="doc-anchor" href="#performance-2">§</a>Performance</h5>
|
||
<p>This method will be significantly slower if the grid uses a column-major memory layout.</p>
|
||
<h5 id="panics-8"><a class="doc-anchor" href="#panics-8">§</a>Panics</h5>
|
||
<p>Panics if the row index is out of bounds.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.iter_row_mut" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#765-779">Source</a><h4 class="code-header">pub fn <a href="#method.iter_row_mut" class="fn">iter_row_mut</a>(&mut self, row: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>) -> <a class="struct" href="https://doc.rust-lang.org/1.84.0/core/iter/adapters/step_by/struct.StepBy.html" title="struct core::iter::adapters::step_by::StepBy">StepBy</a><<a class="struct" href="https://doc.rust-lang.org/1.84.0/core/slice/iter/struct.IterMut.html" title="struct core::slice::iter::IterMut">IterMut</a><'_, T>></h4></section></summary><div class="docblock"><p>Returns a mutable iterator over a row.</p>
|
||
<h5 id="examples-3"><a class="doc-anchor" href="#examples-3">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span><span class="kw-2">mut </span>grid: Grid<u8> = <span class="macro">grid!</span>[[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>][<span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>]];
|
||
<span class="kw">let </span><span class="kw-2">mut </span>col_iter = grid.iter_row_mut(<span class="number">1</span>);
|
||
<span class="kw">let </span>next = col_iter.next();
|
||
<span class="kw-2">*</span>next.unwrap() = <span class="number">10</span>;
|
||
<span class="macro">assert_eq!</span>(grid[(<span class="number">1</span>, <span class="number">0</span>)], <span class="number">10</span>);</code></pre></div>
|
||
<h5 id="performance-3"><a class="doc-anchor" href="#performance-3">§</a>Performance</h5>
|
||
<p>This method will be significantly slower if the grid uses a column-major memory layout.</p>
|
||
<h5 id="panics-9"><a class="doc-anchor" href="#panics-9">§</a>Panics</h5>
|
||
<p>Panics if the row index is out of bounds.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.indexed_iter" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#804-812">Source</a><h4 class="code-header">pub fn <a href="#method.indexed_iter" class="fn">indexed_iter</a>(&self) -> impl <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a><Item = ((<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>, <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>), <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.reference.html">&T</a>)></h4></section></summary><div class="docblock"><p>Traverse the grid with row and column indexes.</p>
|
||
<p>The iteration order is dependent on the internal memory layout,
|
||
but the indexes will be accurate either way.</p>
|
||
<h5 id="examples-4"><a class="doc-anchor" href="#examples-4">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span>grid: Grid<u8> = <span class="macro">grid!</span>[[<span class="number">1</span>,<span class="number">2</span>][<span class="number">3</span>,<span class="number">4</span>]];
|
||
<span class="kw">let </span><span class="kw-2">mut </span>iter = grid.indexed_iter();
|
||
<span class="macro">assert_eq!</span>(iter.next(), <span class="prelude-val">Some</span>(((<span class="number">0</span>, <span class="number">0</span>), <span class="kw-2">&</span><span class="number">1</span>)));</code></pre></div>
|
||
<p>Or simply unpack in a <code>for</code> loop:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span>grid: Grid<u8> = <span class="macro">grid!</span>[[<span class="number">1</span>,<span class="number">2</span>][<span class="number">3</span>,<span class="number">4</span>]];
|
||
<span class="kw">for </span>((row, col), i) <span class="kw">in </span>grid.indexed_iter() {
|
||
<span class="macro">println!</span>(<span class="string">"value at row {row} and column {col} is: {i}"</span>);
|
||
}</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.indexed_iter_mut" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#844-856">Source</a><h4 class="code-header">pub fn <a href="#method.indexed_iter_mut" class="fn">indexed_iter_mut</a>(
|
||
&mut self,
|
||
) -> impl <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a><Item = ((<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>, <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>), <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.reference.html">&mut T</a>)></h4></section></summary><div class="docblock"><p>Traverse the grid with row and column indexes,
|
||
and mutable access to each element.</p>
|
||
<p>The iteration order is dependent on the internal memory layout,
|
||
but the indexes will be accurate either way.</p>
|
||
<h5 id="examples-5"><a class="doc-anchor" href="#examples-5">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span><span class="kw-2">mut </span>grid: Grid<u8> = <span class="macro">grid!</span>[[<span class="number">1</span>,<span class="number">2</span>][<span class="number">3</span>,<span class="number">4</span>]];
|
||
<span class="kw">let </span><span class="kw-2">mut </span>iter = grid.indexed_iter_mut();
|
||
<span class="macro">assert_eq!</span>(iter.next(), <span class="prelude-val">Some</span>(((<span class="number">0</span>, <span class="number">0</span>), <span class="kw-2">&mut </span><span class="number">1</span>)));</code></pre></div>
|
||
<p>Or simply unpack in a <code>for</code> loop:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span><span class="kw-2">mut </span>grid: Grid<u8> = <span class="macro">grid!</span>[[<span class="number">1</span>,<span class="number">2</span>][<span class="number">3</span>,<span class="number">4</span>]];
|
||
<span class="kw">for </span>((row, col), i) <span class="kw">in </span>grid.indexed_iter_mut() {
|
||
<span class="kw-2">*</span>i += <span class="number">1</span>;
|
||
<span class="macro">println!</span>(<span class="string">"value at row {row} and column {col} is: {i}"</span>);
|
||
}
|
||
|
||
<span class="macro">assert_eq!</span>(grid[(<span class="number">0</span>, <span class="number">0</span>)], <span class="number">2</span>);
|
||
<span class="macro">assert_eq!</span>(grid[(<span class="number">0</span>, <span class="number">1</span>)], <span class="number">3</span>);
|
||
<span class="macro">assert_eq!</span>(grid[(<span class="number">1</span>, <span class="number">0</span>)], <span class="number">4</span>);
|
||
<span class="macro">assert_eq!</span>(grid[(<span class="number">1</span>, <span class="number">1</span>)], <span class="number">5</span>);</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.push_row" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#892-911">Source</a><h4 class="code-header">pub fn <a href="#method.push_row" class="fn">push_row</a>(&mut self, row: <a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>)</h4></section></summary><div class="docblock"><p>Add a new row to the grid.</p>
|
||
<h5 id="examples-6"><a class="doc-anchor" href="#examples-6">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span><span class="kw-2">mut </span>grid: Grid<u8> = <span class="macro">grid!</span>[[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>][<span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>]];
|
||
<span class="kw">let </span>row = <span class="macro">vec!</span>[<span class="number">6</span>,<span class="number">7</span>,<span class="number">8</span>];
|
||
grid.push_row(row);
|
||
<span class="macro">assert_eq!</span>(grid.rows(), <span class="number">3</span>);
|
||
<span class="macro">assert_eq!</span>(grid[(<span class="number">2</span>, <span class="number">0</span>)], <span class="number">6</span>);
|
||
<span class="macro">assert_eq!</span>(grid[(<span class="number">2</span>, <span class="number">1</span>)], <span class="number">7</span>);
|
||
<span class="macro">assert_eq!</span>(grid[(<span class="number">2</span>, <span class="number">2</span>)], <span class="number">8</span>);</code></pre></div>
|
||
<p>Can also be used to init an empty grid:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span><span class="kw-2">mut </span>grid: Grid<u8> = <span class="macro">grid!</span>[];
|
||
<span class="kw">let </span>row = <span class="macro">vec!</span>[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>];
|
||
grid.push_row(row);
|
||
<span class="macro">assert_eq!</span>(grid.size(), (<span class="number">1</span>, <span class="number">3</span>));</code></pre></div>
|
||
<h5 id="performance-4"><a class="doc-anchor" href="#performance-4">§</a>Performance</h5>
|
||
<p>This method will be significantly slower if the grid uses a column-major memory layout.</p>
|
||
<h5 id="panics-10"><a class="doc-anchor" href="#panics-10">§</a>Panics</h5>
|
||
<p>Panics if:</p>
|
||
<ul>
|
||
<li>the grid is not empty and <code>row.len() != grid.cols()</code></li>
|
||
<li><code>row.len() == 0</code></li>
|
||
</ul>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.push_col" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#947-966">Source</a><h4 class="code-header">pub fn <a href="#method.push_col" class="fn">push_col</a>(&mut self, col: <a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>)</h4></section></summary><div class="docblock"><p>Add a new column to the grid.</p>
|
||
<h5 id="examples-7"><a class="doc-anchor" href="#examples-7">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span><span class="kw-2">mut </span>grid: Grid<u8> = <span class="macro">grid!</span>[[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>][<span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>]];
|
||
<span class="kw">let </span>col = <span class="macro">vec!</span>[<span class="number">4</span>,<span class="number">6</span>];
|
||
grid.push_col(col);
|
||
<span class="macro">assert_eq!</span>(grid.cols(), <span class="number">4</span>);
|
||
<span class="macro">assert_eq!</span>(grid[(<span class="number">0</span>, <span class="number">3</span>)], <span class="number">4</span>);
|
||
<span class="macro">assert_eq!</span>(grid[(<span class="number">1</span>, <span class="number">3</span>)], <span class="number">6</span>);</code></pre></div>
|
||
<p>Can also be used to init an empty grid:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span><span class="kw-2">mut </span>grid: Grid<u8> = <span class="macro">grid!</span>[];
|
||
<span class="kw">let </span>col = <span class="macro">vec!</span>[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>];
|
||
grid.push_col(col);
|
||
<span class="macro">assert_eq!</span>(grid.size(), (<span class="number">3</span>, <span class="number">1</span>));</code></pre></div>
|
||
<h5 id="performance-5"><a class="doc-anchor" href="#performance-5">§</a>Performance</h5>
|
||
<p>This method will be significantly slower if the grid uses a row-major memory layout,
|
||
which is the default.</p>
|
||
<h5 id="panics-11"><a class="doc-anchor" href="#panics-11">§</a>Panics</h5>
|
||
<p>Panics if:</p>
|
||
<ul>
|
||
<li>the grid is not empty and <code>col.len() != grid.rows()</code></li>
|
||
<li><code>col.len() == 0</code></li>
|
||
</ul>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.pop_row" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#982-998">Source</a><h4 class="code-header">pub fn <a href="#method.pop_row" class="fn">pop_row</a>(&mut self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>></h4></section></summary><div class="docblock"><p>Removes the last row from a grid and returns it, or None if it is empty.</p>
|
||
<h5 id="examples-8"><a class="doc-anchor" href="#examples-8">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span><span class="kw-2">mut </span>grid = <span class="macro">grid!</span>[[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>][<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>]];
|
||
<span class="macro">assert_eq!</span>[grid.pop_row(), <span class="prelude-val">Some</span>(<span class="macro">vec!</span>[<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>])];
|
||
<span class="macro">assert_eq!</span>[grid.pop_row(), <span class="prelude-val">Some</span>(<span class="macro">vec!</span>[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>])];
|
||
<span class="macro">assert_eq!</span>[grid.pop_row(), <span class="prelude-val">None</span>];</code></pre></div>
|
||
<h5 id="performance-6"><a class="doc-anchor" href="#performance-6">§</a>Performance</h5>
|
||
<p>This method will be significantly slower if the grid uses a column-major memory layout.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.remove_row" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#1015-1038">Source</a><h4 class="code-header">pub fn <a href="#method.remove_row" class="fn">remove_row</a>(&mut self, row_index: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>></h4></section></summary><div class="docblock"><p>Remove a Row at the index and return a vector of it.</p>
|
||
<h5 id="examples-9"><a class="doc-anchor" href="#examples-9">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span><span class="kw-2">mut </span>grid = <span class="macro">grid!</span>[[<span class="number">1</span>,<span class="number">2</span>][<span class="number">3</span>,<span class="number">4</span>][<span class="number">5</span>,<span class="number">6</span>]];
|
||
<span class="macro">assert_eq!</span>[grid.remove_row(<span class="number">1</span>), <span class="prelude-val">Some</span>(<span class="macro">vec!</span>[<span class="number">3</span>,<span class="number">4</span>])];
|
||
<span class="macro">assert_eq!</span>[grid.remove_row(<span class="number">0</span>), <span class="prelude-val">Some</span>(<span class="macro">vec!</span>[<span class="number">1</span>,<span class="number">2</span>])];
|
||
<span class="macro">assert_eq!</span>[grid.remove_row(<span class="number">0</span>), <span class="prelude-val">Some</span>(<span class="macro">vec!</span>[<span class="number">5</span>,<span class="number">6</span>])];
|
||
<span class="macro">assert_eq!</span>[grid.remove_row(<span class="number">0</span>), <span class="prelude-val">None</span>];</code></pre></div>
|
||
<h5 id="performance-7"><a class="doc-anchor" href="#performance-7">§</a>Performance</h5>
|
||
<p>This method will be significantly slower if the grid uses a column-major memory layout.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.pop_col" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#1059-1075">Source</a><h4 class="code-header">pub fn <a href="#method.pop_col" class="fn">pop_col</a>(&mut self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>></h4></section></summary><div class="docblock"><p>Removes the last column from a grid and returns it, or None if it is empty.</p>
|
||
<p>Note that this operation is much slower than the <code>pop_row()</code> because the memory layout
|
||
of <code>Grid</code> is row-major and removing a column requires a lot of move operations.</p>
|
||
<h5 id="examples-10"><a class="doc-anchor" href="#examples-10">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span><span class="kw-2">mut </span>grid = <span class="macro">grid!</span>[[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>][<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>]];
|
||
<span class="macro">assert_eq!</span>[grid.pop_col(), <span class="prelude-val">Some</span>(<span class="macro">vec!</span>[<span class="number">3</span>,<span class="number">6</span>])];
|
||
<span class="macro">assert_eq!</span>[grid.pop_col(), <span class="prelude-val">Some</span>(<span class="macro">vec!</span>[<span class="number">2</span>,<span class="number">5</span>])];
|
||
<span class="macro">assert_eq!</span>[grid.pop_col(), <span class="prelude-val">Some</span>(<span class="macro">vec!</span>[<span class="number">1</span>,<span class="number">4</span>])];
|
||
<span class="macro">assert_eq!</span>[grid.pop_col(), <span class="prelude-val">None</span>];</code></pre></div>
|
||
<h5 id="performance-8"><a class="doc-anchor" href="#performance-8">§</a>Performance</h5>
|
||
<p>This method will be significantly slower if the grid uses a row-major memory layout,
|
||
which is the default.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.remove_col" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#1094-1117">Source</a><h4 class="code-header">pub fn <a href="#method.remove_col" class="fn">remove_col</a>(&mut self, col_index: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>></h4></section></summary><div class="docblock"><p>Remove a column at the index and return a vector of it.</p>
|
||
<h5 id="examples-11"><a class="doc-anchor" href="#examples-11">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span><span class="kw-2">mut </span>grid = <span class="macro">grid!</span>[[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>,<span class="number">4</span>][<span class="number">5</span>,<span class="number">6</span>,<span class="number">7</span>,<span class="number">8</span>][<span class="number">9</span>,<span class="number">10</span>,<span class="number">11</span>,<span class="number">12</span>][<span class="number">13</span>,<span class="number">14</span>,<span class="number">15</span>,<span class="number">16</span>]];
|
||
<span class="macro">assert_eq!</span>[grid.remove_col(<span class="number">3</span>), <span class="prelude-val">Some</span>(<span class="macro">vec!</span>[<span class="number">4</span>,<span class="number">8</span>,<span class="number">12</span>,<span class="number">16</span>])];
|
||
<span class="macro">assert_eq!</span>[grid.remove_col(<span class="number">0</span>), <span class="prelude-val">Some</span>(<span class="macro">vec!</span>[<span class="number">1</span>,<span class="number">5</span>,<span class="number">9</span>,<span class="number">13</span>])];
|
||
<span class="macro">assert_eq!</span>[grid.remove_col(<span class="number">1</span>), <span class="prelude-val">Some</span>(<span class="macro">vec!</span>[<span class="number">3</span>,<span class="number">7</span>,<span class="number">11</span>,<span class="number">15</span>])];
|
||
<span class="macro">assert_eq!</span>[grid.remove_col(<span class="number">0</span>), <span class="prelude-val">Some</span>(<span class="macro">vec!</span>[<span class="number">2</span>,<span class="number">6</span>,<span class="number">10</span>,<span class="number">14</span>])];
|
||
<span class="macro">assert_eq!</span>[grid.remove_col(<span class="number">0</span>), <span class="prelude-val">None</span>];</code></pre></div>
|
||
<h5 id="performance-9"><a class="doc-anchor" href="#performance-9">§</a>Performance</h5>
|
||
<p>This method will be significantly slower if the grid uses a row-major memory layout,
|
||
which is the default.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.insert_row" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#1138-1166">Source</a><h4 class="code-header">pub fn <a href="#method.insert_row" class="fn">insert_row</a>(&mut self, index: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>, row: <a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>)</h4></section></summary><div class="docblock"><p>Insert a new row at the index and shifts all rows after down.</p>
|
||
<h5 id="examples-12"><a class="doc-anchor" href="#examples-12">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span><span class="kw-2">mut </span>grid = <span class="macro">grid!</span>[[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>][<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>]];
|
||
grid.insert_row(<span class="number">1</span>, <span class="macro">vec!</span>[<span class="number">7</span>,<span class="number">8</span>,<span class="number">9</span>]);
|
||
<span class="macro">assert_eq!</span>(grid, <span class="macro">grid!</span>[[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>][<span class="number">7</span>,<span class="number">8</span>,<span class="number">9</span>][<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>]]);</code></pre></div>
|
||
<h5 id="performance-10"><a class="doc-anchor" href="#performance-10">§</a>Performance</h5>
|
||
<p>This method will be significantly slower if the grid uses a column-major memory layout.</p>
|
||
<h5 id="panics-12"><a class="doc-anchor" href="#panics-12">§</a>Panics</h5>
|
||
<p>Panics if:</p>
|
||
<ul>
|
||
<li>the grid is not empty and <code>row.len() != grid.cols()</code>.</li>
|
||
<li>the index is greater than the number of rows</li>
|
||
</ul>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.insert_col" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#1191-1219">Source</a><h4 class="code-header">pub fn <a href="#method.insert_col" class="fn">insert_col</a>(&mut self, index: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>, col: <a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>)</h4></section></summary><div class="docblock"><p>Insert a new column at the index.</p>
|
||
<p>Important! Insertion of columns is a lot slower than the lines insertion.
|
||
This is because of the memory layout of the grid data structure.</p>
|
||
<h5 id="examples-13"><a class="doc-anchor" href="#examples-13">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span><span class="kw-2">mut </span>grid = <span class="macro">grid!</span>[[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>][<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>]];
|
||
grid.insert_col(<span class="number">1</span>, <span class="macro">vec!</span>[<span class="number">9</span>,<span class="number">9</span>]);
|
||
<span class="macro">assert_eq!</span>(grid, <span class="macro">grid!</span>[[<span class="number">1</span>,<span class="number">9</span>,<span class="number">2</span>,<span class="number">3</span>][<span class="number">4</span>,<span class="number">9</span>,<span class="number">5</span>,<span class="number">6</span>]])</code></pre></div>
|
||
<h5 id="performance-11"><a class="doc-anchor" href="#performance-11">§</a>Performance</h5>
|
||
<p>This method will be significantly slower if the grid uses a row-major memory layout,
|
||
which is the default.</p>
|
||
<h5 id="panics-13"><a class="doc-anchor" href="#panics-13">§</a>Panics</h5>
|
||
<p>Panics if:</p>
|
||
<ul>
|
||
<li>the grid is not empty and <code>col.len() != grid.rows()</code>.</li>
|
||
<li>the index is greater than the number of columns</li>
|
||
</ul>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.flatten" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#1234-1236">Source</a><h4 class="code-header">pub fn <a href="#method.flatten" class="fn">flatten</a>(&self) -> &<a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T></h4></section></summary><div class="docblock"><p>Returns a reference to the internal data structure of the grid.</p>
|
||
<p>The order of the elements depends on the internal memory layout, which is
|
||
row-major by default.</p>
|
||
<h5 id="examples-14"><a class="doc-anchor" href="#examples-14">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span>grid = <span class="macro">grid!</span>[[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>][<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>]];
|
||
<span class="kw">let </span>flat = grid.flatten();
|
||
<span class="macro">assert_eq!</span>(flat, <span class="kw-2">&</span><span class="macro">vec!</span>[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>,<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>]);</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.into_vec" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#1243-1245">Source</a><h4 class="code-header">pub fn <a href="#method.into_vec" class="fn">into_vec</a>(self) -> <a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T></h4></section></summary><div class="docblock"><p>Converts self into a vector without clones or allocation.</p>
|
||
<p>The order of the elements depends on the internal memory layout, which is
|
||
row-major by default.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.transpose" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#1250-1253">Source</a><h4 class="code-header">pub fn <a href="#method.transpose" class="fn">transpose</a>(&mut self)</h4></section></summary><div class="docblock"><p>Transpose the grid so that columns become rows in new grid.</p>
|
||
<p>This method changes the internal memory layout.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.flip_cols" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#1269-1287">Source</a><h4 class="code-header">pub fn <a href="#method.flip_cols" class="fn">flip_cols</a>(&mut self)</h4></section></summary><div class="docblock"><p>Flip (or mirrors) the columns.</p>
|
||
<h5 id="examples-15"><a class="doc-anchor" href="#examples-15">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span><span class="kw-2">mut </span>grid = <span class="macro">grid!</span>[[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>][<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>]];
|
||
grid.flip_cols();
|
||
<span class="macro">assert_eq!</span>(grid, <span class="macro">grid!</span>[[<span class="number">3</span>,<span class="number">2</span>,<span class="number">1</span>][<span class="number">6</span>,<span class="number">5</span>,<span class="number">4</span>]])</code></pre></div>
|
||
<h5 id="performance-12"><a class="doc-anchor" href="#performance-12">§</a>Performance</h5>
|
||
<p>This method will be significantly slower if the grid uses a column-major memory layout.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.flip_rows" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#1304-1322">Source</a><h4 class="code-header">pub fn <a href="#method.flip_rows" class="fn">flip_rows</a>(&mut self)</h4></section></summary><div class="docblock"><p>Flip (or mirrors) the rows.</p>
|
||
<h5 id="examples-16"><a class="doc-anchor" href="#examples-16">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span><span class="kw-2">mut </span>grid = <span class="macro">grid!</span>[[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>][<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>]];
|
||
grid.flip_rows();
|
||
<span class="macro">assert_eq!</span>(grid, <span class="macro">grid!</span>[[<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>][<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>]])</code></pre></div>
|
||
<h5 id="performance-13"><a class="doc-anchor" href="#performance-13">§</a>Performance</h5>
|
||
<p>This method will be significantly slower if the grid uses a row-major memory layout,
|
||
which is the default.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.rotate_left" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#1341-1344">Source</a><h4 class="code-header">pub fn <a href="#method.rotate_left" class="fn">rotate_left</a>(&mut self)</h4></section></summary><div class="docblock"><p>Rotate the grid 90° counter-clockwise.</p>
|
||
<p>This method changes the internal memory layout.</p>
|
||
<h5 id="examples-17"><a class="doc-anchor" href="#examples-17">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span><span class="kw-2">mut </span>grid = <span class="macro">grid!</span>[[<span class="number">1</span>,<span class="number">2</span>][<span class="number">3</span>,<span class="number">4</span>]];
|
||
grid.rotate_left();
|
||
<span class="macro">assert_eq!</span>(grid, <span class="macro">grid!</span>[[<span class="number">2</span>,<span class="number">4</span>][<span class="number">1</span>,<span class="number">3</span>]]);</code></pre></div>
|
||
<h5 id="performance-14"><a class="doc-anchor" href="#performance-14">§</a>Performance</h5>
|
||
<p>This method will be significantly slower if the grid initialy uses a column-major memory layout,
|
||
which is the default.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.rotate_right" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#1363-1366">Source</a><h4 class="code-header">pub fn <a href="#method.rotate_right" class="fn">rotate_right</a>(&mut self)</h4></section></summary><div class="docblock"><p>Rotate the grid 90° clockwise.</p>
|
||
<p>This method changes the internal memory layout.</p>
|
||
<h5 id="examples-18"><a class="doc-anchor" href="#examples-18">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span><span class="kw-2">mut </span>grid = <span class="macro">grid!</span>[[<span class="number">1</span>,<span class="number">2</span>][<span class="number">3</span>,<span class="number">4</span>]];
|
||
grid.rotate_right();
|
||
<span class="macro">assert_eq!</span>(grid, <span class="macro">grid!</span>[[<span class="number">3</span>,<span class="number">1</span>][<span class="number">4</span>,<span class="number">2</span>]]);</code></pre></div>
|
||
<h5 id="performance-15"><a class="doc-anchor" href="#performance-15">§</a>Performance</h5>
|
||
<p>This method will be significantly slower if the grid initialy uses a row-major memory layout,
|
||
which is the default.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.rotate_half" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#1384-1386">Source</a><h4 class="code-header">pub fn <a href="#method.rotate_half" class="fn">rotate_half</a>(&mut self)</h4></section></summary><div class="docblock"><p>Rotate the grid 180°.</p>
|
||
<p>This method <strong>doesn’t</strong> change the internal memory layout.</p>
|
||
<h5 id="examples-19"><a class="doc-anchor" href="#examples-19">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span><span class="kw-2">mut </span>grid = <span class="macro">grid!</span>[[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>][<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>]];
|
||
grid.rotate_half();
|
||
<span class="macro">assert_eq!</span>(grid, <span class="macro">grid!</span>[[<span class="number">6</span>,<span class="number">5</span>,<span class="number">4</span>][<span class="number">3</span>,<span class="number">2</span>,<span class="number">1</span>]]);</code></pre></div>
|
||
<h5 id="performance-16"><a class="doc-anchor" href="#performance-16">§</a>Performance</h5>
|
||
<p>The performances of this method is not affected by the internal memory layout.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.fill" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#1398-1403">Source</a><h4 class="code-header">pub fn <a href="#method.fill" class="fn">fill</a>(&mut self, value: T)<div class="where">where
|
||
T: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</div></h4></section></summary><div class="docblock"><p>Fills the grid with elements by cloning <code>value</code>.</p>
|
||
<h5 id="examples-20"><a class="doc-anchor" href="#examples-20">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span><span class="kw-2">mut </span>grid = <span class="macro">grid!</span>[[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>][<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>]];
|
||
grid.fill(<span class="number">7</span>);
|
||
<span class="macro">assert_eq!</span>(grid, <span class="macro">grid!</span>[[<span class="number">7</span>,<span class="number">7</span>,<span class="number">7</span>][<span class="number">7</span>,<span class="number">7</span>,<span class="number">7</span>]]);</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.fill_with" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#1422-1427">Source</a><h4 class="code-header">pub fn <a href="#method.fill_with" class="fn">fill_with</a><F>(&mut self, f: F)<div class="where">where
|
||
F: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>() -> T,</div></h4></section></summary><div class="docblock"><p>Fills the grid with elements returned by calling a closure repeatedly.</p>
|
||
<p>This method uses a closure to create new values. If you’d rather
|
||
<a href="https://doc.rust-lang.org/1.84.0/core/clone/trait.Clone.html" title="trait core::clone::Clone"><code>Clone</code></a> a given value, use <a href="struct.Grid.html#method.fill" title="method grid::Grid::fill"><code>fill</code></a>. If you want to use the <a href="https://doc.rust-lang.org/1.84.0/core/default/trait.Default.html" title="trait core::default::Default"><code>Default</code></a>
|
||
trait to generate values, you can pass <a href="https://doc.rust-lang.org/1.84.0/core/default/trait.Default.html#tymethod.default" title="associated function core::default::Default::default"><code>Default::default</code></a> as the
|
||
argument.</p>
|
||
<h5 id="examples-21"><a class="doc-anchor" href="#examples-21">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span><span class="kw-2">mut </span>grid = <span class="macro">grid!</span>[[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>][<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>]];
|
||
grid.fill_with(Default::default);
|
||
<span class="macro">assert_eq!</span>(grid, <span class="macro">grid!</span>[[<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>][<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>]]);</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.iter_rows" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#1444-1450">Source</a><h4 class="code-header">pub fn <a href="#method.iter_rows" class="fn">iter_rows</a>(&self) -> <a class="struct" href="struct.GridRowIter.html" title="struct grid::GridRowIter">GridRowIter</a><'_, T> <a href="#" class="tooltip" data-notable-ty="GridRowIter<'_, T>">ⓘ</a></h4></section></summary><div class="docblock"><p>Iterate over the rows of the grid. Each time an iterator over a single
|
||
row is returned.</p>
|
||
<p>An item in this iterator is equal to a call to <code>Grid.iter_row(row_index)</code>
|
||
of the corresponding row.</p>
|
||
<h5 id="examples-22"><a class="doc-anchor" href="#examples-22">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span><span class="kw-2">mut </span>grid = <span class="macro">grid!</span>[[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>][<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>]];
|
||
<span class="kw">let </span>sum_by_row: Vec<u8> = grid.iter_rows().map(|row| row.sum()).collect();
|
||
<span class="macro">assert_eq!</span>(sum_by_row, <span class="macro">vec!</span>[<span class="number">1</span>+<span class="number">2</span>+<span class="number">3</span>, <span class="number">4</span>+<span class="number">5</span>+<span class="number">6</span>])</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.iter_cols" class="method"><a class="src rightside" href="../src/grid/lib.rs.html#1467-1473">Source</a><h4 class="code-header">pub fn <a href="#method.iter_cols" class="fn">iter_cols</a>(&self) -> <a class="struct" href="struct.GridColIter.html" title="struct grid::GridColIter">GridColIter</a><'_, T> <a href="#" class="tooltip" data-notable-ty="GridColIter<'_, T>">ⓘ</a></h4></section></summary><div class="docblock"><p>Iterate over the columns of the grid. Each time an iterator over a single
|
||
column is returned.</p>
|
||
<p>An item in this iterator is equal to a call to <code>Grid.iter_col(col_index)</code>
|
||
of the corresponding column.</p>
|
||
<h5 id="examples-23"><a class="doc-anchor" href="#examples-23">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>grid::<span class="kw-2">*</span>;
|
||
<span class="kw">let </span><span class="kw-2">mut </span>grid = <span class="macro">grid!</span>[[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>][<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>]];
|
||
<span class="kw">let </span>sum_by_col: Vec<u8> = grid.iter_cols().map(|col| col.sum()).collect();
|
||
<span class="macro">assert_eq!</span>(sum_by_col, <span class="macro">vec!</span>[<span class="number">1</span>+<span class="number">4</span>, <span class="number">2</span>+<span class="number">5</span>, <span class="number">3</span>+<span class="number">6</span>])</code></pre></div>
|
||
</div></details></div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Clone-for-Grid%3CT%3E" class="impl"><a class="src rightside" href="../src/grid/lib.rs.html#1487-1496">Source</a><a href="#impl-Clone-for-Grid%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="struct.Grid.html" title="struct grid::Grid">Grid</a><T></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.clone" class="method trait-impl"><a class="src rightside" href="../src/grid/lib.rs.html#1488-1495">Source</a><a href="#method.clone" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/core/clone/trait.Clone.html#tymethod.clone" class="fn">clone</a>(&self) -> Self</h4></section></summary><div class='docblock'>Returns a copy of the value. <a href="https://doc.rust-lang.org/1.84.0/core/clone/trait.Clone.html#tymethod.clone">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.clone_from" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.84.0/src/core/clone.rs.html#174">Source</a></span><a href="#method.clone_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/core/clone/trait.Clone.html#method.clone_from" class="fn">clone_from</a>(&mut self, source: &Self)</h4></section></summary><div class='docblock'>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/1.84.0/core/clone/trait.Clone.html#method.clone_from">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-Grid%3CT%3E" class="impl"><a class="src rightside" href="../src/grid/lib.rs.html#1538-1577">Source</a><a href="#impl-Debug-for-Grid%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.Grid.html" title="struct grid::Grid">Grid</a><T></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a class="src rightside" href="../src/grid/lib.rs.html#1539-1576">Source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/1.84.0/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.84.0/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Default-for-Grid%3CT%3E" class="impl"><a class="src rightside" href="../src/grid/lib.rs.html#1476-1485">Source</a><a href="#impl-Default-for-Grid%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/default/trait.Default.html" title="trait core::default::Default">Default</a> for <a class="struct" href="struct.Grid.html" title="struct grid::Grid">Grid</a><T></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.default" class="method trait-impl"><a class="src rightside" href="../src/grid/lib.rs.html#1477-1484">Source</a><a href="#method.default" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/core/default/trait.Default.html#tymethod.default" class="fn">default</a>() -> Self</h4></section></summary><div class='docblock'>Returns the “default value” for a type. <a href="https://doc.rust-lang.org/1.84.0/core/default/trait.Default.html#tymethod.default">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3C%26Vec%3C%26Vec%3CT%3E%3E%3E-for-Grid%3CT%3E" class="impl"><a class="src rightside" href="../src/grid/lib.rs.html#1618-1631">Source</a><a href="#impl-From%3C%26Vec%3C%26Vec%3CT%3E%3E%3E-for-Grid%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><&<a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><&<a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>>> for <a class="struct" href="struct.Grid.html" title="struct grid::Grid">Grid</a><T></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-2" class="method trait-impl"><a class="src rightside" href="../src/grid/lib.rs.html#1620-1630">Source</a><a href="#method.from-2" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(vec: &<a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><&<a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>>) -> Self</h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3C%26Vec%3CVec%3CT%3E%3E%3E-for-Grid%3CT%3E" class="impl"><a class="src rightside" href="../src/grid/lib.rs.html#1606-1616">Source</a><a href="#impl-From%3C%26Vec%3CVec%3CT%3E%3E%3E-for-Grid%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><&<a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>>> for <a class="struct" href="struct.Grid.html" title="struct grid::Grid">Grid</a><T></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-1" class="method trait-impl"><a class="src rightside" href="../src/grid/lib.rs.html#1608-1615">Source</a><a href="#method.from-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(vec: &<a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>>) -> Self</h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3C(%26Vec%3CT%3E,+%26usize)%3E-for-Grid%3CT%3E" class="impl"><a class="src rightside" href="../src/grid/lib.rs.html#1645-1649">Source</a><a href="#impl-From%3C(%26Vec%3CT%3E,+%26usize)%3E-for-Grid%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><(&<a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>, &<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>)> for <a class="struct" href="struct.Grid.html" title="struct grid::Grid">Grid</a><T></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-5" class="method trait-impl"><a class="src rightside" href="../src/grid/lib.rs.html#1646-1648">Source</a><a href="#method.from-5" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(value: (&<a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>, &<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>)) -> Self</h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3C(%26Vec%3CT%3E,+usize)%3E-for-Grid%3CT%3E" class="impl"><a class="src rightside" href="../src/grid/lib.rs.html#1639-1643">Source</a><a href="#impl-From%3C(%26Vec%3CT%3E,+usize)%3E-for-Grid%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><(&<a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>, <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>)> for <a class="struct" href="struct.Grid.html" title="struct grid::Grid">Grid</a><T></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-4" class="method trait-impl"><a class="src rightside" href="../src/grid/lib.rs.html#1640-1642">Source</a><a href="#method.from-4" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(value: (&<a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>, <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>)) -> Self</h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3C(Vec%3CT%3E,+usize)%3E-for-Grid%3CT%3E" class="impl"><a class="src rightside" href="../src/grid/lib.rs.html#1633-1637">Source</a><a href="#impl-From%3C(Vec%3CT%3E,+usize)%3E-for-Grid%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><(<a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>, <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>)> for <a class="struct" href="struct.Grid.html" title="struct grid::Grid">Grid</a><T></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-3" class="method trait-impl"><a class="src rightside" href="../src/grid/lib.rs.html#1634-1636">Source</a><a href="#method.from-3" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(value: (<a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>, <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>)) -> Self</h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CVec%3CVec%3CT%3E%3E%3E-for-Grid%3CT%3E" class="impl"><a class="src rightside" href="../src/grid/lib.rs.html#1598-1604">Source</a><a href="#impl-From%3CVec%3CVec%3CT%3E%3E%3E-for-Grid%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><<a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>>> for <a class="struct" href="struct.Grid.html" title="struct grid::Grid">Grid</a><T></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="../src/grid/lib.rs.html#1600-1603">Source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(vec: <a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>>) -> Self</h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Hash-for-Grid%3CT%3E" class="impl"><a class="src rightside" href="../src/grid/lib.rs.html#1498-1506">Source</a><a href="#impl-Hash-for-Grid%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a>> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> for <a class="struct" href="struct.Grid.html" title="struct grid::Grid">Grid</a><T></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.hash" class="method trait-impl"><a class="src rightside" href="../src/grid/lib.rs.html#1500-1505">Source</a><a href="#method.hash" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/core/hash/trait.Hash.html#tymethod.hash" class="fn">hash</a><H: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>>(&self, state: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.reference.html">&mut H</a>)</h4></section></summary><div class='docblock'>Feeds this value into the given <a href="https://doc.rust-lang.org/1.84.0/core/hash/trait.Hasher.html" title="trait core::hash::Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/1.84.0/core/hash/trait.Hash.html#tymethod.hash">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.hash_slice" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.3.0">1.3.0</span> · <a class="src" href="https://doc.rust-lang.org/1.84.0/src/core/hash/mod.rs.html#235-237">Source</a></span><a href="#method.hash_slice" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/core/hash/trait.Hash.html#method.hash_slice" class="fn">hash_slice</a><H>(data: &[Self], state: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.reference.html">&mut H</a>)<div class="where">where
|
||
H: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>,
|
||
Self: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Feeds a slice of this type into the given <a href="https://doc.rust-lang.org/1.84.0/core/hash/trait.Hasher.html" title="trait core::hash::Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/1.84.0/core/hash/trait.Hash.html#method.hash_slice">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Index%3C(usize,+usize)%3E-for-Grid%3CT%3E" class="impl"><a class="src rightside" href="../src/grid/lib.rs.html#1508-1522">Source</a><a href="#impl-Index%3C(usize,+usize)%3E-for-Grid%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/ops/index/trait.Index.html" title="trait core::ops::index::Index">Index</a><(<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>, <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>)> for <a class="struct" href="struct.Grid.html" title="struct grid::Grid">Grid</a><T></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Output" class="associatedtype trait-impl"><a class="src rightside" href="../src/grid/lib.rs.html#1509">Source</a><a href="#associatedtype.Output" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.0/core/ops/index/trait.Index.html#associatedtype.Output" class="associatedtype">Output</a> = T</h4></section></summary><div class='docblock'>The returned type after indexing.</div></details><details class="toggle method-toggle" open><summary><section id="method.index" class="method trait-impl"><a class="src rightside" href="../src/grid/lib.rs.html#1512-1521">Source</a><a href="#method.index" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/core/ops/index/trait.Index.html#tymethod.index" class="fn">index</a>(&self, (row, col): (<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>, <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>)) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.reference.html">&T</a></h4></section></summary><div class='docblock'>Performs the indexing (<code>container[index]</code>) operation. <a href="https://doc.rust-lang.org/1.84.0/core/ops/index/trait.Index.html#tymethod.index">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-IndexMut%3C(usize,+usize)%3E-for-Grid%3CT%3E" class="impl"><a class="src rightside" href="../src/grid/lib.rs.html#1524-1536">Source</a><a href="#impl-IndexMut%3C(usize,+usize)%3E-for-Grid%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/ops/index/trait.IndexMut.html" title="trait core::ops::index::IndexMut">IndexMut</a><(<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>, <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>)> for <a class="struct" href="struct.Grid.html" title="struct grid::Grid">Grid</a><T></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.index_mut" class="method trait-impl"><a class="src rightside" href="../src/grid/lib.rs.html#1526-1535">Source</a><a href="#method.index_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/core/ops/index/trait.IndexMut.html#tymethod.index_mut" class="fn">index_mut</a>(&mut self, (row, col): (<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>, <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>)) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.reference.html">&mut T</a></h4></section></summary><div class='docblock'>Performs the mutable indexing (<code>container[index]</code>) operation. <a href="https://doc.rust-lang.org/1.84.0/core/ops/index/trait.IndexMut.html#tymethod.index_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-PartialEq-for-Grid%3CT%3E" class="impl"><a class="src rightside" href="../src/grid/lib.rs.html#1579-1594">Source</a><a href="#impl-PartialEq-for-Grid%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a>> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a> for <a class="struct" href="struct.Grid.html" title="struct grid::Grid">Grid</a><T></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.eq" class="method trait-impl"><a class="src rightside" href="../src/grid/lib.rs.html#1580-1593">Source</a><a href="#method.eq" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/core/cmp/trait.PartialEq.html#tymethod.eq" class="fn">eq</a>(&self, other: &Self) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>Tests for <code>self</code> and <code>other</code> values to be equal, and is used by <code>==</code>.</div></details><details class="toggle method-toggle" open><summary><section id="method.ne" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.84.0/src/core/cmp.rs.html#261">Source</a></span><a href="#method.ne" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/core/cmp/trait.PartialEq.html#method.ne" class="fn">ne</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.reference.html">&Rhs</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>Tests for <code>!=</code>. The default implementation is almost always sufficient,
|
||
and should not be overridden without very good reason.</div></details></div></details><section id="impl-Eq-for-Grid%3CT%3E" class="impl"><a class="src rightside" href="../src/grid/lib.rs.html#1596">Source</a><a href="#impl-Eq-for-Grid%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a>> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> for <a class="struct" href="struct.Grid.html" title="struct grid::Grid">Grid</a><T></h3></section></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-Grid%3CT%3E" class="impl"><a href="#impl-Freeze-for-Grid%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.Grid.html" title="struct grid::Grid">Grid</a><T></h3></section><section id="impl-RefUnwindSafe-for-Grid%3CT%3E" class="impl"><a href="#impl-RefUnwindSafe-for-Grid%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.Grid.html" title="struct grid::Grid">Grid</a><T><div class="where">where
|
||
T: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a>,</div></h3></section><section id="impl-Send-for-Grid%3CT%3E" class="impl"><a href="#impl-Send-for-Grid%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.Grid.html" title="struct grid::Grid">Grid</a><T><div class="where">where
|
||
T: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,</div></h3></section><section id="impl-Sync-for-Grid%3CT%3E" class="impl"><a href="#impl-Sync-for-Grid%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.Grid.html" title="struct grid::Grid">Grid</a><T><div class="where">where
|
||
T: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a>,</div></h3></section><section id="impl-Unpin-for-Grid%3CT%3E" class="impl"><a href="#impl-Unpin-for-Grid%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.Grid.html" title="struct grid::Grid">Grid</a><T><div class="where">where
|
||
T: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h3></section><section id="impl-UnwindSafe-for-Grid%3CT%3E" class="impl"><a href="#impl-UnwindSafe-for-Grid%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.Grid.html" title="struct grid::Grid">Grid</a><T><div class="where">where
|
||
T: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a>,</div></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.0/src/core/any.rs.html#138">Source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
|
||
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.84.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.0/src/core/any.rs.html#139">Source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/1.84.0/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.84.0/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.0/src/core/borrow.rs.html#209">Source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<div class="where">where
|
||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.0/src/core/borrow.rs.html#211">Source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.reference.html">&T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.84.0/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.0/src/core/borrow.rs.html#217">Source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<div class="where">where
|
||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.0/src/core/borrow.rs.html#218">Source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.reference.html">&mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.84.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-CloneToUninit-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.0/src/core/clone.rs.html#273">Source</a><a href="#impl-CloneToUninit-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/clone/trait.CloneToUninit.html" title="trait core::clone::CloneToUninit">CloneToUninit</a> for T<div class="where">where
|
||
T: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.clone_to_uninit" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.0/src/core/clone.rs.html#275">Source</a><a href="#method.clone_to_uninit" class="anchor">§</a><h4 class="code-header">unsafe fn <a href="https://doc.rust-lang.org/1.84.0/core/clone/trait.CloneToUninit.html#tymethod.clone_to_uninit" class="fn">clone_to_uninit</a>(&self, dst: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.pointer.html">*mut </a><a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u8.html">u8</a>)</h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>clone_to_uninit</code>)</span></div></span><div class='docblock'>Performs copy-assignment from <code>self</code> to <code>dst</code>. <a href="https://doc.rust-lang.org/1.84.0/core/clone/trait.CloneToUninit.html#tymethod.clone_to_uninit">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.0/src/core/convert/mod.rs.html#765">Source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-6" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.0/src/core/convert/mod.rs.html#768">Source</a><a href="#method.from-6" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
|
||
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.0/src/core/convert/mod.rs.html#748-750">Source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T<div class="where">where
|
||
U: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.0/src/core/convert/mod.rs.html#758">Source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
|
||
<p>That is, this conversion is whatever the implementation of
|
||
<code><a href="https://doc.rust-lang.org/1.84.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for U</code> chooses to do.</p>
|
||
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-ToOwned-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.0/src/alloc/borrow.rs.html#82-84">Source</a><a href="#impl-ToOwned-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.0/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> for T<div class="where">where
|
||
T: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Owned" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.0/src/alloc/borrow.rs.html#86">Source</a><a href="#associatedtype.Owned" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.0/alloc/borrow/trait.ToOwned.html#associatedtype.Owned" class="associatedtype">Owned</a> = T</h4></section></summary><div class='docblock'>The resulting type after obtaining ownership.</div></details><details class="toggle method-toggle" open><summary><section id="method.to_owned" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.0/src/alloc/borrow.rs.html#87">Source</a><a href="#method.to_owned" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/alloc/borrow/trait.ToOwned.html#tymethod.to_owned" class="fn">to_owned</a>(&self) -> T</h4></section></summary><div class='docblock'>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/1.84.0/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.clone_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.0/src/alloc/borrow.rs.html#91">Source</a><a href="#method.clone_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/alloc/borrow/trait.ToOwned.html#method.clone_into" class="fn">clone_into</a>(&self, target: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.reference.html">&mut T</a>)</h4></section></summary><div class='docblock'>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/1.84.0/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.0/src/core/convert/mod.rs.html#805-807">Source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T<div class="where">where
|
||
U: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.0/src/core/convert/mod.rs.html#809">Source</a><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.0/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.84.0/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.0/src/core/convert/mod.rs.html#812">Source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/1.84.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.0/src/core/convert/mod.rs.html#790-792">Source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T<div class="where">where
|
||
U: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.0/src/core/convert/mod.rs.html#794">Source</a><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.0/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.0/src/core/convert/mod.rs.html#797">Source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.0/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div><script type="text/json" id="notable-traits-data">{"GridColIter<'_, T>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.GridColIter.html\" title=\"struct grid::GridColIter\">GridColIter</a><'a, T></code></h3><pre><code><div class=\"where\">impl<'a, T> <a class=\"trait\" href=\"https://doc.rust-lang.org/1.84.0/core/iter/traits/iterator/trait.Iterator.html\" title=\"trait core::iter::traits::iterator::Iterator\">Iterator</a> for <a class=\"struct\" href=\"struct.GridColIter.html\" title=\"struct grid::GridColIter\">GridColIter</a><'a, T></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.84.0/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item\" class=\"associatedtype\">Item</a> = <a class=\"struct\" href=\"https://doc.rust-lang.org/1.84.0/core/iter/adapters/step_by/struct.StepBy.html\" title=\"struct core::iter::adapters::step_by::StepBy\">StepBy</a><<a class=\"struct\" href=\"https://doc.rust-lang.org/1.84.0/core/slice/iter/struct.Iter.html\" title=\"struct core::slice::iter::Iter\">Iter</a><'a, T>>;</div>","GridRowIter<'_, T>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.GridRowIter.html\" title=\"struct grid::GridRowIter\">GridRowIter</a><'a, T></code></h3><pre><code><div class=\"where\">impl<'a, T> <a class=\"trait\" href=\"https://doc.rust-lang.org/1.84.0/core/iter/traits/iterator/trait.Iterator.html\" title=\"trait core::iter::traits::iterator::Iterator\">Iterator</a> for <a class=\"struct\" href=\"struct.GridRowIter.html\" title=\"struct grid::GridRowIter\">GridRowIter</a><'a, T></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.84.0/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item\" class=\"associatedtype\">Item</a> = <a class=\"struct\" href=\"https://doc.rust-lang.org/1.84.0/core/iter/adapters/step_by/struct.StepBy.html\" title=\"struct core::iter::adapters::step_by::StepBy\">StepBy</a><<a class=\"struct\" href=\"https://doc.rust-lang.org/1.84.0/core/slice/iter/struct.Iter.html\" title=\"struct core::slice::iter::Iter\">Iter</a><'a, T>>;</div>"}</script></section></div></main></body></html> |