multibody_dynamics 0.3.0

Multibody dynamics algorithms in Rust
Documentation
<!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="github crates-io docs-rs"><meta name="keywords" content="rust, rustlang, rust-lang, paste"><title>paste - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceSerif4-Regular-1f7d512b176f0f72.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceSerif4-Bold-124a1ca42af929b6.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-6827029ac823cab7.css" id="mainThemeStyle"><link rel="stylesheet" id="themeStyle" href="../static.files/light-ebce58d0a40c3431.css"><link rel="stylesheet" disabled href="../static.files/dark-f23faae4a2daf9a6.css"><link rel="stylesheet" disabled href="../static.files/ayu-8af5e100b21cd173.css"><script id="default-settings" ></script><script src="../static.files/storage-d43fa987303ecbbb.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-c55e1eb52e1886b4.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-13285aec31fa243e.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-16x16-8b506e7a72182f1c.png"><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc mod crate"><!--[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">&#9776;</button><a class="sidebar-logo" href="../paste/index.html"><div class="logo-container"><img class="rust-logo" src="../static.files/rust-logo-151179464ae7ed46.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../paste/index.html"><div class="logo-container"><img class="rust-logo" src="../static.files/rust-logo-151179464ae7ed46.svg" alt="logo"></div></a><h2 class="location"><a href="#">Crate paste</a></h2><div class="sidebar-elems"><ul class="block"><li class="version">Version 1.0.11</li><li><a id="all-types" href="all.html">All Items</a></li></ul><section><ul class="block"><li><a href="#macros">Macros</a></li></ul></section></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../static.files/wheel-5ec35bf9ca753509.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Crate <a class="mod" href="#">paste</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../src/paste/lib.rs.html#1-453">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p><a href="https://github.com/dtolnay/paste"><img src="https://img.shields.io/badge/github-8da0cb?style=for-the-badge&amp;labelColor=555555&amp;logo=github" alt="github" /></a> <a href="https://crates.io/crates/paste"><img src="https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&amp;labelColor=555555&amp;logo=rust" alt="crates-io" /></a> <a href="https://docs.rs/paste"><img src="https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&amp;labelColor=555555&amp;logo=docs.rs" alt="docs-rs" /></a></p>
<br>
<p>The nightly-only <a href="https://doc.rust-lang.org/std/macro.concat_idents.html"><code>concat_idents!</code></a> macro in the Rust standard library is
notoriously underpowered in that its concatenated identifiers can only refer to
existing items, they can never be used to define something new.</p>
<p>This crate provides a flexible way to paste together identifiers in a macro,
including using pasted identifiers to define new items.</p>
<p>This approach works with any Rust compiler 1.31+.</p>
<br>
<h2 id="pasting-identifiers"><a href="#pasting-identifiers">Pasting identifiers</a></h2>
<p>Within the <code>paste!</code> macro, identifiers inside <code>[&lt;</code>…<code>&gt;]</code> are pasted
together to form a single identifier.</p>

<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>paste::paste;

<span class="macro">paste! </span>{
    <span class="comment">// Defines a const called `QRST`.
    </span><span class="kw">const </span>[&lt;Q R S T&gt;]: <span class="kw-2">&amp;</span>str = <span class="string">&quot;success!&quot;</span>;
}

<span class="kw">fn </span>main() {
    <span class="macro">assert_eq!</span>(
        <span class="macro">paste! </span>{ [&lt;Q R S T&gt;].len() },
        <span class="number">8</span>,
    );
}</code></pre></div>
<p><br><br></p>
<h2 id="more-elaborate-example"><a href="#more-elaborate-example">More elaborate example</a></h2>
<p>The next example shows a macro that generates accessor methods for some
struct fields. It demonstrates how you might find it useful to bundle a
paste invocation inside of a macro_rules macro.</p>

<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>paste::paste;

<span class="macro">macro_rules! </span>make_a_struct_and_getters {
    (<span class="macro-nonterminal">$name</span>:ident { $(<span class="macro-nonterminal">$field</span>:ident),* }) =&gt; {
        <span class="comment">// Define a struct. This expands to:
        //
        //     pub struct S {
        //         a: String,
        //         b: String,
        //         c: String,
        //     }
        </span><span class="kw">pub struct </span><span class="macro-nonterminal">$name </span>{
            $(
                <span class="macro-nonterminal">$field</span>: String,
            )*
        }

        <span class="comment">// Build an impl block with getters. This expands to:
        //
        //     impl S {
        //         pub fn get_a(&amp;self) -&gt; &amp;str { &amp;self.a }
        //         pub fn get_b(&amp;self) -&gt; &amp;str { &amp;self.b }
        //         pub fn get_c(&amp;self) -&gt; &amp;str { &amp;self.c }
        //     }
        </span><span class="macro">paste! </span>{
            <span class="kw">impl </span><span class="macro-nonterminal">$name </span>{
                $(
                    <span class="kw">pub fn </span>[&lt;get_ <span class="macro-nonterminal">$field</span>&gt;](<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span>str {
                        <span class="kw-2">&amp;</span><span class="self">self</span>.<span class="macro-nonterminal">$field
                    </span>}
                )*
            }
        }
    }
}

<span class="macro">make_a_struct_and_getters!</span>(S { a, b, c });

<span class="kw">fn </span>call_some_getters(s: <span class="kw-2">&amp;</span>S) -&gt; bool {
    s.get_a() == s.get_b() &amp;&amp; s.get_c().is_empty()
}</code></pre></div>
<p><br><br></p>
<h2 id="case-conversion"><a href="#case-conversion">Case conversion</a></h2>
<p>Use <code>$var:lower</code> or <code>$var:upper</code> in the segment list to convert an
interpolated segment to lower- or uppercase as part of the paste. For
example, <code>[&lt;ld_ $reg:lower _expr&gt;]</code> would paste to <code>ld_bc_expr</code> if invoked
with $reg=<code>Bc</code>.</p>
<p>Use <code>$var:snake</code> to convert CamelCase input to snake_case.
Use <code>$var:camel</code> to convert snake_case to CamelCase.
These compose, so for example <code>$var:snake:upper</code> would give you SCREAMING_CASE.</p>
<p>The precise Unicode conversions are as defined by <a href="https://doc.rust-lang.org/std/primitive.str.html#method.to_lowercase"><code>str::to_lowercase</code></a> and
<a href="https://doc.rust-lang.org/std/primitive.str.html#method.to_uppercase"><code>str::to_uppercase</code></a>.</p>
<br>
<h2 id="pasting-documentation-strings"><a href="#pasting-documentation-strings">Pasting documentation strings</a></h2>
<p>Within the <code>paste!</code> macro, arguments to a #[doc …] attribute are
implicitly concatenated together to form a coherent documentation string.</p>

<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>paste::paste;

<span class="macro">macro_rules! </span>method_new {
    (<span class="macro-nonterminal">$ret</span>:ident) =&gt; {
        <span class="macro">paste! </span>{
            <span class="attr">#[doc = <span class="string">&quot;Create a new `&quot; </span><span class="macro-nonterminal">$ret </span><span class="string">&quot;` object.&quot;</span>]
            </span><span class="kw">pub fn </span>new() -&gt; <span class="macro-nonterminal">$ret </span>{ <span class="macro">todo!</span>() }
        }
    };
}

<span class="kw">pub struct </span>Paste {}

<span class="macro">method_new!</span>(Paste);  <span class="comment">// expands to #[doc = &quot;Create a new `Paste` object&quot;]</span></code></pre></div>
</div></details><h2 id="macros" class="small-section-header"><a href="#macros">Macros</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.paste.html" title="paste::paste macro">paste</a></div></div></div></section></div></main><div id="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="paste" data-themes="" data-resource-suffix="" data-rustdoc-version="1.67.1 (d5a82bbd2 2023-02-07)" data-search-js="search-444266647c4dba98.js" data-settings-js="settings-bebeae96e00e4617.js" data-settings-css="settings-af96d9e2fc13e081.css" ></div></body></html>