Sophie

Sophie

distrib > Mageia > 6 > x86_64 > media > core-updates > by-pkgid > fdedb3cf2140df9b6d419a2338ab1caa > files > 5408

rust-doc-1.25.0-1.mga6.x86_64.rpm

<!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="API documentation for the Rust `Location` struct in crate `std`.">
    <meta name="keywords" content="rust, rustlang, rust-lang, Location">

    <title>std::panic::Location - Rust</title>

    <link rel="stylesheet" type="text/css" href="../../normalize.css">
    <link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle">
    
    <link rel="stylesheet" type="text/css" href="../../dark.css">
    <link rel="stylesheet" type="text/css" href="../../main.css" id="themeStyle">
    <script src="../../storage.js"></script>
    

    <link rel="shortcut icon" href="https://doc.rust-lang.org/favicon.ico">
    
</head>
<body class="rustdoc struct">
    <!--[if lte IE 8]>
    <div class="warning">
        This old browser is unsupported and will most likely display funky
        things.
    </div>
    <![endif]-->

    

    <nav class="sidebar">
        <div class="sidebar-menu">&#9776;</div>
        <a href='../../std/index.html'><img src='https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png' alt='logo' width='100'></a>
        <p class='location'>Struct Location</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#methods">Methods</a><div class="sidebar-links"><a href="#method.file">file</a><a href="#method.line">line</a><a href="#method.column">column</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a></div></div><p class='location'><a href='../index.html'>std</a>::<wbr><a href='index.html'>panic</a></p><script>window.sidebarCurrent = {name: 'Location', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script></div>
    </nav>

    <div class="theme-picker">
        <button id="theme-picker" aria-label="Pick another theme!">
            <img src="../../brush.svg" width="18" alt="Pick another theme!">
        </button>
        <div id="theme-choices"></div>
    </div>
    <script src="../../theme.js"></script>
    <nav class="sub">
        <form class="search-form js-only">
            <div class="search-container">
                <input class="search-input" name="search"
                       autocomplete="off"
                       placeholder="Click or press ‘S’ to search, ‘?’ for more options…"
                       type="search">
            </div>
        </form>
    </nav>

    <section id='main' class="content">
<h1 class='fqn'><span class='in-band'>Struct <a href='../index.html'>std</a>::<wbr><a href='index.html'>panic</a>::<wbr><a class="struct" href=''>Location</a></span><span class='out-of-band'><span class='since' title='Stable since Rust version 1.10.0'>1.10.0</span><span id='render-detail'>
                   <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
                       [<span class='inner'>&#x2212;</span>]
                   </a>
               </span><a class='srclink' href='../../src/std/panicking.rs.html#263-267' title='goto source code'>[src]</a></span></h1>
<pre class='rust struct'>pub struct Location&lt;'a&gt; { /* fields omitted */ }</pre><div class='docblock'><p>A struct containing information about the location of a panic.</p>
<p>This structure is created by the <a href="../../std/panic/struct.PanicInfo.html#method.location"><code>location</code></a> method of <a href="../../std/panic/struct.PanicInfo.html"><code>PanicInfo</code></a>.</p>
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">panic</span>;

<span class="ident">panic</span>::<span class="ident">set_hook</span>(<span class="ident">Box</span>::<span class="ident">new</span>(<span class="op">|</span><span class="ident">panic_info</span><span class="op">|</span> {
    <span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">location</span>) <span class="op">=</span> <span class="ident">panic_info</span>.<span class="ident">location</span>() {
        <span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;panic occurred in file &#39;{}&#39; at line {}&quot;</span>, <span class="ident">location</span>.<span class="ident">file</span>(), <span class="ident">location</span>.<span class="ident">line</span>());
    } <span class="kw">else</span> {
        <span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;panic occurred but can&#39;t get location information...&quot;</span>);
    }
}));

<span class="macro">panic</span><span class="macro">!</span>(<span class="string">&quot;Normal panic&quot;</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Apanic%3B%0A%0Apanic%3A%3Aset_hook(Box%3A%3Anew(%7Cpanic_info%7C%20%7B%0A%20%20%20%20if%20let%20Some(location)%20%3D%20panic_info.location()%20%7B%0A%20%20%20%20%20%20%20%20println!(%22panic%20occurred%20in%20file%20'%7B%7D'%20at%20line%20%7B%7D%22%2C%20location.file()%2C%20location.line())%3B%0A%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20println!(%22panic%20occurred%20but%20can't%20get%20location%20information...%22)%3B%0A%20%20%20%20%7D%0A%7D))%3B%0A%0Apanic!(%22Normal%20panic%22)%3B%0A%7D">Run</a></pre>
</div>
                    <h2 id='methods' class='small-section-header'>
                      Methods<a href='#methods' class='anchor'></a>
                    </h2>
                <h3 id='impl' class='impl'><span class='in-band'><code>impl&lt;'a&gt; <a class="struct" href="../../std/panic/struct.Location.html" title="struct std::panic::Location">Location</a>&lt;'a&gt;</code><a href='#impl' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/std/panicking.rs.html#269-335' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.file' class="method"><span id='file.v' class='invisible'><code>pub fn <a href='#method.file' class='fnname'>file</a>(&amp;self) -&gt; &amp;<a class="primitive" href="../primitive.str.html">str</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/std/panicking.rs.html#288-290' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Returns the name of the source file from which the panic originated.</p>
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">panic</span>;

<span class="ident">panic</span>::<span class="ident">set_hook</span>(<span class="ident">Box</span>::<span class="ident">new</span>(<span class="op">|</span><span class="ident">panic_info</span><span class="op">|</span> {
    <span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">location</span>) <span class="op">=</span> <span class="ident">panic_info</span>.<span class="ident">location</span>() {
        <span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;panic occurred in file &#39;{}&#39;&quot;</span>, <span class="ident">location</span>.<span class="ident">file</span>());
    } <span class="kw">else</span> {
        <span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;panic occurred but can&#39;t get location information...&quot;</span>);
    }
}));

<span class="macro">panic</span><span class="macro">!</span>(<span class="string">&quot;Normal panic&quot;</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Apanic%3B%0A%0Apanic%3A%3Aset_hook(Box%3A%3Anew(%7Cpanic_info%7C%20%7B%0A%20%20%20%20if%20let%20Some(location)%20%3D%20panic_info.location()%20%7B%0A%20%20%20%20%20%20%20%20println!(%22panic%20occurred%20in%20file%20'%7B%7D'%22%2C%20location.file())%3B%0A%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20println!(%22panic%20occurred%20but%20can't%20get%20location%20information...%22)%3B%0A%20%20%20%20%7D%0A%7D))%3B%0A%0Apanic!(%22Normal%20panic%22)%3B%0A%7D">Run</a></pre>
</div><h4 id='method.line' class="method"><span id='line.v' class='invisible'><code>pub fn <a href='#method.line' class='fnname'>line</a>(&amp;self) -&gt; <a class="primitive" href="../primitive.u32.html">u32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/std/panicking.rs.html#310-312' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Returns the line number from which the panic originated.</p>
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">panic</span>;

<span class="ident">panic</span>::<span class="ident">set_hook</span>(<span class="ident">Box</span>::<span class="ident">new</span>(<span class="op">|</span><span class="ident">panic_info</span><span class="op">|</span> {
    <span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">location</span>) <span class="op">=</span> <span class="ident">panic_info</span>.<span class="ident">location</span>() {
        <span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;panic occurred at line {}&quot;</span>, <span class="ident">location</span>.<span class="ident">line</span>());
    } <span class="kw">else</span> {
        <span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;panic occurred but can&#39;t get location information...&quot;</span>);
    }
}));

<span class="macro">panic</span><span class="macro">!</span>(<span class="string">&quot;Normal panic&quot;</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Apanic%3B%0A%0Apanic%3A%3Aset_hook(Box%3A%3Anew(%7Cpanic_info%7C%20%7B%0A%20%20%20%20if%20let%20Some(location)%20%3D%20panic_info.location()%20%7B%0A%20%20%20%20%20%20%20%20println!(%22panic%20occurred%20at%20line%20%7B%7D%22%2C%20location.line())%3B%0A%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20println!(%22panic%20occurred%20but%20can't%20get%20location%20information...%22)%3B%0A%20%20%20%20%7D%0A%7D))%3B%0A%0Apanic!(%22Normal%20panic%22)%3B%0A%7D">Run</a></pre>
</div><h4 id='method.column' class="method"><span id='column.v' class='invisible'><code>pub fn <a href='#method.column' class='fnname'>column</a>(&amp;self) -&gt; <a class="primitive" href="../primitive.u32.html">u32</a></code></span><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.25'>1.25</div><a class='srclink' href='../../src/std/panicking.rs.html#332-334' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Returns the column from which the panic originated.</p>
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">panic</span>;

<span class="ident">panic</span>::<span class="ident">set_hook</span>(<span class="ident">Box</span>::<span class="ident">new</span>(<span class="op">|</span><span class="ident">panic_info</span><span class="op">|</span> {
    <span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">location</span>) <span class="op">=</span> <span class="ident">panic_info</span>.<span class="ident">location</span>() {
        <span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;panic occurred at column {}&quot;</span>, <span class="ident">location</span>.<span class="ident">column</span>());
    } <span class="kw">else</span> {
        <span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;panic occurred but can&#39;t get location information...&quot;</span>);
    }
}));

<span class="macro">panic</span><span class="macro">!</span>(<span class="string">&quot;Normal panic&quot;</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Apanic%3B%0A%0Apanic%3A%3Aset_hook(Box%3A%3Anew(%7Cpanic_info%7C%20%7B%0A%20%20%20%20if%20let%20Some(location)%20%3D%20panic_info.location()%20%7B%0A%20%20%20%20%20%20%20%20println!(%22panic%20occurred%20at%20column%20%7B%7D%22%2C%20location.column())%3B%0A%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20println!(%22panic%20occurred%20but%20can't%20get%20location%20information...%22)%3B%0A%20%20%20%20%7D%0A%7D))%3B%0A%0Apanic!(%22Normal%20panic%22)%3B%0A%7D">Run</a></pre>
</div></div>
            <h2 id='implementations' class='small-section-header'>
              Trait Implementations<a href='#implementations' class='anchor'></a>
            </h2>
        <h3 id='impl-Debug' class='impl'><span class='in-band'><code>impl&lt;'a&gt; <a class="trait" href="../../std/fmt/trait.Debug.html" title="trait std::fmt::Debug">Debug</a> for <a class="struct" href="../../std/panic/struct.Location.html" title="struct std::panic::Location">Location</a>&lt;'a&gt;</code><a href='#impl-Debug' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/std/panicking.rs.html#261' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.fmt' class="method"><span id='fmt.v' class='invisible'><code>fn <a href='../../std/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, __arg_0: &amp;mut <a class="struct" href="../../std/fmt/struct.Formatter.html" title="struct std::fmt::Formatter">Formatter</a>) -&gt; <a class="type" href="../../std/fmt/type.Result.html" title="type std::fmt::Result">Result</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/std/panicking.rs.html#261' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Formats the value using the given formatter. <a href="../../std/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></div></section>
    <section id='search' class="content hidden"></section>

    <section class="footer"></section>

    <aside id="help" class="hidden">
        <div>
            <h1 class="hidden">Help</h1>

            <div class="shortcuts">
                <h2>Keyboard Shortcuts</h2>

                <dl>
                    <dt><kbd>?</kbd></dt>
                    <dd>Show this help dialog</dd>
                    <dt><kbd>S</kbd></dt>
                    <dd>Focus the search field</dd>
                    <dt><kbd>↑</kbd></dt>
                    <dd>Move up in search results</dd>
                    <dt><kbd>↓</kbd></dt>
                    <dd>Move down in search results</dd>
                    <dt><kbd>↹</kbd></dt>
                    <dd>Switch tab</dd>
                    <dt><kbd>&#9166;</kbd></dt>
                    <dd>Go to active search result</dd>
                    <dt><kbd>+</kbd></dt>
                    <dd>Expand all sections</dd>
                    <dt><kbd>-</kbd></dt>
                    <dd>Collapse all sections</dd>
                </dl>
            </div>

            <div class="infos">
                <h2>Search Tricks</h2>

                <p>
                    Prefix searches with a type followed by a colon (e.g.
                    <code>fn:</code>) to restrict the search to a given type.
                </p>

                <p>
                    Accepted types are: <code>fn</code>, <code>mod</code>,
                    <code>struct</code>, <code>enum</code>,
                    <code>trait</code>, <code>type</code>, <code>macro</code>,
                    and <code>const</code>.
                </p>

                <p>
                    Search functions by type signature (e.g.
                    <code>vec -> usize</code> or <code>* -> vec</code>)
                </p>
            </div>
        </div>
    </aside>

    

    <script>
        window.rootPath = "../../";
        window.currentCrate = "std";
    </script>
    <script src="../../main.js"></script>
    <script defer src="../../search-index.js"></script>
</body>
</html>