From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Brennan Vincent" Newsgroups: gmane.emacs.bugs Subject: bug#73279: [PATCH] Eglot: use immediate-mode eglot--request for :completionItem/resolve Date: Mon, 16 Sep 2024 13:06:55 -0400 Message-ID: <87y13r5xzk.fsf@taipei.mail-host-address-is-not-set> References: <87v7ywoh7m.fsf@taipei.mail-host-address-is-not-set> <86wmjbdehl.fsf@gnu.org> <8734lz7hn2.fsf@taipei.mail-host-address-is-not-set> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8808"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 73279@debbugs.gnu.org, Dmitry Gutov To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 16 19:08:14 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sqFCr-00026A-Dk for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 16 Sep 2024 19:08:11 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sqFCb-000167-Bv; Mon, 16 Sep 2024 13:07:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sqFCY-0000yG-Bu for bug-gnu-emacs@gnu.org; Mon, 16 Sep 2024 13:07:50 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sqFCX-0000J4-VI for bug-gnu-emacs@gnu.org; Mon, 16 Sep 2024 13:07:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=gyHq6nRivO2lNa2htSt6oLgmahULg8eFgfR78ucZIfQ=; b=paa2yLTTfQKxsXgjR8/uPJ4UbtSj4Z97Z8QvFCoZgvKzAWUWmwHQGnUYjfWXL2WxT4xtqu+WNdHkWgnE+PVl+YeP+0fMtbzQAHVG/l0WdMPBw5s9DHqpApBOqWRNdj28g3keXvfCFJbBut2o9BHb4eNfaGnIw77qPBrvOVp9Myjk8zaF1bF6x3ouKnfEhj97WlNXQha7qMD2gu7YrSTpAjatlB7j1nfPyWpSqJuOpJLTCyvn865D6Gxx6r0rf2sC0YjsEWAPRBIB3ksm4hysUhzqtGA3r+QyEyv9MhWZWBIjpIjzX5+KWvLvcmkur971Ip9en6Bo2xFiR3OPDbV8dA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sqFCk-0003pT-4f for bug-gnu-emacs@gnu.org; Mon, 16 Sep 2024 13:08:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Brennan Vincent" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 16 Sep 2024 17:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73279 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 73279-submit@debbugs.gnu.org id=B73279.172650645914667 (code B ref 73279); Mon, 16 Sep 2024 17:08:02 +0000 Original-Received: (at 73279) by debbugs.gnu.org; 16 Sep 2024 17:07:39 +0000 Original-Received: from localhost ([127.0.0.1]:53180 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqFCN-0003oV-4v for submit@debbugs.gnu.org; Mon, 16 Sep 2024 13:07:39 -0400 Original-Received: from smtp.umanwizard.com ([54.203.248.109]:29613) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqFCL-0003oE-Cc for 73279@debbugs.gnu.org; Mon, 16 Sep 2024 13:07:37 -0400 Original-Received: from localhost ([108.6.22.48]) by smtp.umanwizard.com ; 16 Sep 2024 17:06:58 +0000 X-Fes-Received-For: 73279@debbugs.gnu.org X-Fes-Received-From: In-Reply-To: X-Fes-Encrypted: true X-Fes-Ehlo-Domain: localhost X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:291899 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Jo=C3=A3o T=C3=A1vora writes: > On Mon, Sep 16, 2024 at 4:50=E2=80=AFPM Jo=C3=A3o T=C3=A1vora wrote: >> >> On Mon, Sep 16, 2024 at 4:40=E2=80=AFPM Jo=C3=A3o T=C3=A1vora wrote: >> > >> > On Mon, Sep 16, 2024 at 4:17=E2=80=AFPM Brennan Vincent wrote: >> > >> > > As for the regression: yes, it's a regression from 29.4, and in fact= I >> > > have bisected to the commit that regressed it: >> > > a8c1559a663d9bc21776e33303251e244f86f0d7 >> > >> > Oh alright, that clears it up. It was an oversight indeed, so I think >> > your patch is TRT. I'll install it in emacs-30. >> >> Actually, not so fast. The code before that allegedly broken commit >> _also_ sent outstanding changes to the server before resolving >> (via the advice that was then removed). Not according to my testing. And, taking a look at the old code: (advice-add #'jsonrpc-request :before (cl-function (lambda (_proc _method _params &key deferred &allow-other-keys) (when (and eglot--managed-mode deferred) (eglot--signal-textDocument/didChange)))) '((name . eglot--signal-textDocument/didChange))) It seems that we are only sending the changes if the function is called with the :deferred flag. The function was NOT called with the :deferred flag at the site in question, which as of 093a36 (parent of a8c1559) looked like this: (jsonrpc-request server :completionItem/resolve lsp-comp :cancel-on-input t) >> >> So I must be missing something, and must investigate more >> closely. > > Brennan, can you provide an excerpt of the Eglot event log > (M-x eglot-events-buffer) for your MRE recipe before and > after a8c1559a663d9bc21776e33303251e244f86f0d7? > Sure. See attachments. They are a bit long because of the huge doc strings rust-analyzer includes, but you should get the idea by searching for textDocument/completion. Note that in BEFORE, we send textDocument/completion, immediately followed = by completionItem/resolve. In AFTER, we send textDocument/completion, then textDocument/didChange, then completionItem/resolve. --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename=BEFORE Content-Transfer-Encoding: quoted-printable Content-Description: Before a8c1559 [internal] Mon Sep 16 12:52:54 2024: (:message "Running language server: rust-analyzer") [client-request] (id:1) Mon Sep 16 12:52:54 2024: (:jsonrpc "2.0" :id 1 :method "initialize" :params (:processId 1665562 :clientInfo (:name "Eglot") :rootPath "/home/brennan/test_rust/" :rootUri "file:///home/brennan= /test_rust" :initializationOptions #s(hash-table size 1 test eql rehash-siz= e 1.5 rehash-threshold 0.8125 data ()) :capabilities (:workspace (:applyEdit t :executeCommand (:dynamicRegistration :json-false) :workspaceEdit (:documentChanges t) :didChangeWatchedFiles (:dynamicRegistration t) :symbol (:dynamicRegistration :json-false) :configuration t :workspaceFolders t) :textDocument (:synchronization (:dynamicRegistration :json-false :willSave t :willSaveWaitUntil t :didS= ave t) :completion (:dynamicRegistration :json-false :completionItem (:snippetSupport :json-false :deprecatedSupport t :resolveSupport (:properties ["documentation" "details" "additionalTextEdits"]) :tagSupport (:valueSet [1])) :contextSupport t) :hover (:dynamicRegistration :json-false :contentFormat ["plaintext"]) :signatureHelp (:dynamicRegistration :json-false :signatureInformation (:parameterInformation (:labelOffsetSupport t) :activeParameterSupport t)) :references (:dynamicRegistration :json-false) :definition (:dynamicRegistration :json-false :linkSupport t) :declaration (:dynamicRegistration :json-false :linkSupport t) :implementation (:dynamicRegistration :json-false :linkSupport t) :typeDefinition (:dynamicRegistration :json-false :linkSupport t) :documentSymbol (:dynamicRegistration :json-false :hierarchicalDocumentSymbolSupport t := symbolKind (:valueSet [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24= 25 26])) :documentHighlight (:dynamicRegistration :json-false) :codeAction (:dynamicRegistration :json-false :codeActionLiteralSupport (:codeActionKind (:valueSet ["quickfix" "refactor" "refactor.extract" "refactor.inline" "refactor= .rewrite" "source" "source.organizeImports"])) :isPreferredSupport t) :formatting (:dynamicRegistration :json-false) :rangeFormatting (:dynamicRegistration :json-false) :rename (:dynamicRegistration :json-false) :inlayHint (:dynamicRegistration :json-false) :publishDiagnostics (:relatedInformation :json-false :codeDescriptionSupport :json-false :ta= gSupport (:valueSet [1 2]))) :window (:workDoneProgress t) :general (:positionEncodings ["utf-32" "utf-8" "utf-16"]) :experimental #s(hash-table size 1 test eql rehash-size 1.5 rehash= -threshold 0.8125 data ())) :workspaceFolders [(:uri "file:///home/brennan/test_rust" :name "~/test_rust/")])) [server-reply] (id:1) Mon Sep 16 12:52:54 2024: (:jsonrpc "2.0" :id 1 :result (:capabilities (:positionEncoding "utf-32" :textDocumentSync (:openClose t :change 2 :save nil) :selectionRangeProvider t :hoverProvider t :completionProvider (:resolveProvider t :triggerCharacters [":" "." "'" "("] :completionItem (:labelDetailsSupport :json-false)) :signatureHelpProvider (:triggerCharacters ["(" "," "<"]) :definitionProvider t :typeDefinitionProvider t :implementationPro= vider t :referencesProvider t :documentHighlightProvider t :documentSymbolP= rovider t :workspaceSymbolProvider t :codeActionProvider (:codeActionKinds ["" "quickfix" "refactor" "refactor.extract" "refactor.inline" "r= efactor.rewrite"] :resolveProvider t) :codeLensProvider (:resolveProvider t) :documentFormattingProvider t :documentRangeFormattingProvider :js= on-false :documentOnTypeFormattingProvider (:firstTriggerCharacter "=3D" :moreTriggerCharacter ["." ">" "{" "("]) :renameProvider (:prepareProvider t) :foldingRangeProvider t :declarationProvider t :workspace (:workspaceFolders (:supported t :changeNotifications t) :fileOperations (:willRename (:filters [(:scheme "file" :pattern (:glob "**/*.rs" :matches "file")) (:scheme "file" :pattern (:glob "**" :matches "folder"))]))) :callHierarchyProvider t :semanticTokensProvider (:legend (:tokenTypes ["comment" "decorator" "enumMember" "enum" "function" "interface" "keyw= ord" "macro" "method" "namespace" "number" "operator" "parameter" "property= " "string" "struct" "typeParameter" "variable" "angle" "arithmetic" "attrib= uteBracket" "attribute" "bitwise" "boolean" "brace" "bracket" "builtinAttri= bute" "builtinType" "character" "colon" "comma" "comparison" "constParamete= r" "const" "deriveHelper" "derive" "dot" "escapeSequence" "formatSpecifier"= "generic" "invalidEscapeSequence" "label" "lifetime" "logical" "macroBang"= "parenthesis" "procMacro" "punctuation" "selfKeyword" "selfTypeKeyword" "s= emicolon" "static" "toolModule" "typeAlias" "union" "unresolvedReference"] :tokenModifiers ["async" "documentation" "declaration" "static" "defaultLibrary" "assoc= iated" "attribute" "callable" "constant" "consuming" "controlFlow" "crateRo= ot" "injected" "intraDocLink" "library" "macro" "mutable" "procMacro" "publ= ic" "reference" "trait" "unsafe"]) :range t :full (:delta t)) :inlayHintProvider (:resolveProvider t) :experimental (:externalDocs t :hoverRange t :joinLines t :matchingBrace t :move= Item t :onEnter t :openCargoToml t :parentModule t :runnables (:kinds ["cargo"]) :ssr t :workspaceSymbolScopeKindFiltering t)) :serverInfo (:name "rust-analyzer" :version "1.81.0 (eeb90cda 2024-09-04)"))) [client-notification] Mon Sep 16 12:52:54 2024: (:jsonrpc "2.0" :method "initialized" :params #s(hash-table size 1 test eql= rehash-size 1.5 rehash-threshold 0.8125 data ())) [client-notification] Mon Sep 16 12:52:54 2024: (:jsonrpc "2.0" :method "textDocument/didOpen" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs" :version 0 :language= Id "rust-ts" :text "struct S {\n x: T\n}\n\nimpl S> {\n= }\n\nfn main() {}\n"))) [client-notification] Mon Sep 16 12:52:54 2024: (:jsonrpc "2.0" :method "workspace/didChangeConfiguration" :params (:settings #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshol= d 0.8125 data ()))) [client-request] (id:2) Mon Sep 16 12:52:54 2024: (:jsonrpc "2.0" :id 2 :method "textDocument/inlayHint" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :range (:start (:line 0 :character 0) :end (:line 8 :character 0)))) [server-request] (id:0) Mon Sep 16 12:52:54 2024: (:jsonrpc "2.0" :id 0 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Fetching")) [client-reply] (id:0) Mon Sep 16 12:52:54 2024: (:jsonrpc "2.0" :id 0 :result nil) [server-notification] Mon Sep 16 12:52:54 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Fetching" :value (:kind "begin" :title "Fetching" :cancellable :json-false))) [server-request] (id:1) Mon Sep 16 12:52:54 2024: (:jsonrpc "2.0" :id 1 :method "workspace/configuration" :params (:items [(:section "rust-analyzer")])) [client-reply] (id:1) Mon Sep 16 12:52:54 2024: (:jsonrpc "2.0" :id 1 :result [nil]) [server-reply] (id:2) Mon Sep 16 12:52:54 2024: (:jsonrpc "2.0" :id 2 :result []) [server-notification] Mon Sep 16 12:52:54 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Fetching" :value (:kind "report" :cancellable :json-false :message "metadata"))) [server-request] (id:2) Mon Sep 16 12:52:54 2024: (:jsonrpc "2.0" :id 2 :method "client/registerCapability" :params (:registrations [(:id "workspace/didChangeWatchedFiles" :method "workspace/didChangeWat= chedFiles" :registerOptions (:watchers [(:globPattern "/home/brennan/test_rust/**/*.rs") (:globPattern "/home/brennan/test_rust/**/Cargo.{toml,lock}") (:globPattern "/home/brennan/test_rust/**/rust-analyzer.toml") (:globPattern "/home/brennan/.config/rust-analyzer/rust-analyzer.toml") (:globPattern "/home/brennan/test_rust/rust-analyzer.toml") (:globPattern "/home/brennan/test_rust/Cargo.toml")]))])) [client-reply] (id:2) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 2 :result nil) [server-request] (id:3) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 3 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Building CrateGraph")) [client-reply] (id:3) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 3 :result nil) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Building CrateGraph" :value (:kind "begin" :title "Building CrateGraph" :cancellable :json-false))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Building CrateGraph" :value (:kind "end"))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Fetching" :value (:kind "end"))) [server-request] (id:4) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 4 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Roots Scanned")) [client-reply] (id:4) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 4 :result nil) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "begin" :title "Roots Scanned" :cancellable :json-false :message= "0/3" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/alloc" :percentage 0))) [server-request] (id:5) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 5 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Fetching")) [client-reply] (id:5) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 5 :result nil) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Fetching" :value (:kind "begin" :title "Fetching" :cancellable :json-false))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/core" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/backtrace" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/panic_abort" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/panic_unwind" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/portable-simd" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/proc_macro" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/profiler_builtins" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/rtstartup" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/rustc-std-workspace-alloc" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/rustc-std-workspace-core" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/rustc-std-workspace-std" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/std" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/stdarch" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/sysroot" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/test" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/unwind" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "1/3" :percentage 33)= )) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "1/3: " :percentage 3= 3))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "1/3: " :percentage 3= 3))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "1/3: src" :percentag= e 33))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "2/3" :percentage 66)= )) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "end" :message "3/3"))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Fetching" :value (:kind "report" :cancellable :json-false :message "metadata"))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Fetching" :value (:kind "end"))) [server-request] (id:6) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 6 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Fetching")) [client-reply] (id:6) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 6 :result nil) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Fetching" :value (:kind "begin" :title "Fetching" :cancellable :json-false))) [server-request] (id:7) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 7 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Indexing")) [client-reply] (id:7) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 7 :result nil) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "begin" :title "Indexing" :cancellable :json-false :percentage 0= ))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:uri "file:///home/brennan/test_rust/src/main.rs" :diagnostics [] :version 0)) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "0/1 (test_rust)" :pe= rcentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :percentage 100))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "end"))) [server-request] (id:8) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 8 :method "window/workDoneProgress/create" :params (:token "rust-analyzer/flycheck/0")) [client-reply] (id:8) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 8 :result nil) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rust-analyzer/flycheck/0" :value (:kind "begin" :title "cargo check" :cancellable t))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:uri "file:///home/brennan/test_rust/src/main.rs" :diagnostics [(:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :severity 1 :code "E0412" :codeDescription (:href "https://doc.rust-lang.org/error-index.html#E0412") :source "rustc" :message "cannot find type `HashSet` in this scope\nnot= found in this scope" :relatedInformation [(:location (:uri "file:///home/brennan/test_rust/src/main.rs" :range (:start (:line 0 :character 0) :end (:line 0 :character 0))) :message "consider importing this struct: `use std::collections::Hash= Set;\n\n`")] :data (:rendered "error[E0412]: cannot find type `HashSet` in this scope\n --= > src/main.rs:5:11\n |\n5 | impl S> {\n | ^^^^^^^= not found in this scope\n |\nhelp: consider importing this struct\n |\n1= + use std::collections::HashSet;\n |\n\n")) (:range (:start (:line 0 :character 0) :end (:line 0 :character 0)) :severity 4 :code "E0412" :codeDescription (:href "https://doc.rust-lang.org/error-index.html#E0412") :source "rustc" :message "consider importing this struct: `use std::col= lections::HashSet;\n\n`" :relatedInformation [(:location (:uri "file:///home/brennan/test_rust/src/main.rs" :range (:start (:line 4 :character 10) :end (:line 4 :character 17))) :message "original diagnostic")])] :version 0)) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rust-analyzer/flycheck/0" :value (:kind "end"))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Fetching" :value (:kind "report" :cancellable :json-false :message "metadata"))) [server-request] (id:9) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 9 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Building CrateGraph")) [client-reply] (id:9) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 9 :result nil) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Building CrateGraph" :value (:kind "begin" :title "Building CrateGraph" :cancellable :json-false))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Building CrateGraph" :value (:kind "end"))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Fetching" :value (:kind "end"))) [server-request] (id:10) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 10 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Building build-artifacts")) [client-reply] (id:10) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 10 :result nil) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Building build-artifacts" :value (:kind "begin" :title "Building build-artifacts" :cancellable :json-fal= se))) [server-request] (id:11) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 11 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Indexing")) [client-reply] (id:11) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 11 :result nil) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "begin" :title "Indexing" :cancellable :json-false :percentage 0= ))) [server-request] (id:12) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 12 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Loading proc-macros")) [client-reply] (id:12) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 12 :result nil) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Loading proc-macros" :value (:kind "begin" :title "Loading proc-macros" :cancellable :json-false))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Loading proc-macros" :value (:kind "end"))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "5/12 (core + 2 more)= " :percentage 41))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "end"))) [server-request] (id:13) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 13 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Indexing")) [client-reply] (id:13) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 13 :result nil) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "begin" :title "Indexing" :cancellable :json-false :percentage 0= ))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "5/12 (core + 2 more)= " :percentage 41))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "6/12 (core + 1 more)= " :percentage 50))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "7/12 (core)" :percen= tage 58))) [server-request] (id:14) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 14 :method "window/workDoneProgress/create" :params (:token "rust-analyzer/flycheck/0")) [client-reply] (id:14) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 14 :result nil) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rust-analyzer/flycheck/0" :value (:kind "begin" :title "cargo check" :cancellable t))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:uri "file:///home/brennan/test_rust/src/main.rs" :diagnostics [(:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :severity 1 :code "E0412" :codeDescription (:href "https://doc.rust-lang.org/error-index.html#E0412") :source "rustc" :message "cannot find type `HashSet` in this scope\nnot= found in this scope" :relatedInformation [(:location (:uri "file:///home/brennan/test_rust/src/main.rs" :range (:start (:line 0 :character 0) :end (:line 0 :character 0))) :message "consider importing this struct: `use std::collections::Hash= Set;\n\n`")] :data (:rendered "error[E0412]: cannot find type `HashSet` in this scope\n --= > src/main.rs:5:11\n |\n5 | impl S> {\n | ^^^^^^^= not found in this scope\n |\nhelp: consider importing this struct\n |\n1= + use std::collections::HashSet;\n |\n\n")) (:range (:start (:line 0 :character 0) :end (:line 0 :character 0)) :severity 4 :code "E0412" :codeDescription (:href "https://doc.rust-lang.org/error-index.html#E0412") :source "rustc" :message "consider importing this struct: `use std::col= lections::HashSet;\n\n`" :relatedInformation [(:location (:uri "file:///home/brennan/test_rust/src/main.rs" :range (:start (:line 4 :character 10) :end (:line 4 :character 17))) :message "original diagnostic")])] :version 0)) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rust-analyzer/flycheck/0" :value (:kind "end"))) [client-request] (id:3) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 3 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 0 :character 0))) [client-request] (id:4) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 4 :method "textDocument/hover" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 0 :character 0))) [client-request] (id:5) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 5 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 0 :character 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Building build-artifacts" :value (:kind "report" :cancellable :json-false :message "building proc-macros= : test_rust"))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Building build-artifacts" :value (:kind "report" :cancellable :json-false :message "building proc-macros= : test_rust"))) [server-request] (id:15) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 15 :method "client/registerCapability" :params (:registrations [(:id "workspace/didChangeWatchedFiles" :method "workspace/didChangeWat= chedFiles" :registerOptions (:watchers [(:globPattern "/home/brennan/test_rust/**/*.rs") (:globPattern "/home/brennan/test_rust/**/Cargo.{toml,lock}") (:globPattern "/home/brennan/test_rust/**/rust-analyzer.toml") (:globPattern "/home/brennan/.config/rust-analyzer/rust-analyzer.toml") (:globPattern "/home/brennan/test_rust/rust-analyzer.toml") (:globPattern "/home/brennan/test_rust/Cargo.toml")]))])) [client-reply] (id:15) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 15 :result nil) [server-request] (id:16) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 16 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Building CrateGraph")) [client-reply] (id:16) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 16 :result nil) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Building CrateGraph" :value (:kind "begin" :title "Building CrateGraph" :cancellable :json-false))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Building CrateGraph" :value (:kind "end"))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Building build-artifacts" :value (:kind "end"))) [server-reply] (id:3) ERROR Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 3 :error (:code -32801 :message "content modified")) [internal] (id:3) ERROR Mon Sep 16 12:52:55 2024: (:message "error ignored, status set (content modified)" :id 3 :error -3280= 1) [server-reply] (id:4) ERROR Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 4 :error (:code -32801 :message "content modified")) [internal] (id:4) ERROR Mon Sep 16 12:52:55 2024: (:message "error ignored, status set (content modified)" :id 4 :error -3280= 1) [server-reply] (id:5) ERROR Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 5 :error (:code -32801 :message "content modified")) [internal] (id:5) ERROR Mon Sep 16 12:52:55 2024: (:message "error ignored, status set (content modified)" :id 5 :error -3280= 1) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "end"))) [server-request] (id:17) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 17 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Roots Scanned")) [client-reply] (id:17) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 17 :result nil) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "begin" :title "Roots Scanned" :cancellable :json-false :message= "0/3" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/alloc" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/core" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/backtrace" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/panic_abort" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/panic_unwind" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/portable-simd" :percentage 0))) [server-request] (id:18) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 18 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Loading proc-macros")) [client-reply] (id:18) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 18 :result nil) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Loading proc-macros" :value (:kind "begin" :title "Loading proc-macros" :cancellable :json-false))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Loading proc-macros" :value (:kind "end"))) [server-request] (id:19) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 19 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Indexing")) [client-reply] (id:19) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 19 :result nil) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "begin" :title "Indexing" :cancellable :json-false :percentage 0= ))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "4/12 (core + 3 more)= " :percentage 33))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "end"))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/proc_macro" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/profiler_builtins" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/rtstartup" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/rustc-std-workspace-alloc" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/rustc-std-workspace-core" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/rustc-std-workspace-std" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/std" :percentage 0))) [server-request] (id:20) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 20 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Indexing")) [client-reply] (id:20) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 20 :result nil) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "begin" :title "Indexing" :cancellable :json-false :percentage 0= ))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "5/12 (core + 2 more)= " :percentage 41))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "6/12 (core + 1 more)= " :percentage 50))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/stdarch" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "7/12 (core)" :percen= tage 58))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/sysroot" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/test" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/unwind" :percentage 0))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "1/3" :percentage 33)= )) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "1/3: " :percentage 3= 3))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "1/3: " :percentage 3= 3))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "1/3: src" :percentag= e 33))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "2/3" :percentage 66)= )) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "end" :message "3/3"))) [server-request] (id:21) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 21 :method "window/workDoneProgress/create" :params (:token "rust-analyzer/flycheck/0")) [client-reply] (id:21) Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :id 21 :result nil) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rust-analyzer/flycheck/0" :value (:kind "begin" :title "cargo check" :cancellable t))) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:uri "file:///home/brennan/test_rust/src/main.rs" :diagnostics [(:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :severity 1 :code "E0412" :codeDescription (:href "https://doc.rust-lang.org/error-index.html#E0412") :source "rustc" :message "cannot find type `HashSet` in this scope\nnot= found in this scope" :relatedInformation [(:location (:uri "file:///home/brennan/test_rust/src/main.rs" :range (:start (:line 0 :character 0) :end (:line 0 :character 0))) :message "consider importing this struct: `use std::collections::Hash= Set;\n\n`")] :data (:rendered "error[E0412]: cannot find type `HashSet` in this scope\n --= > src/main.rs:5:11\n |\n5 | impl S> {\n | ^^^^^^^= not found in this scope\n |\nhelp: consider importing this struct\n |\n1= + use std::collections::HashSet;\n |\n\n")) (:range (:start (:line 0 :character 0) :end (:line 0 :character 0)) :severity 4 :code "E0412" :codeDescription (:href "https://doc.rust-lang.org/error-index.html#E0412") :source "rustc" :message "consider importing this struct: `use std::col= lections::HashSet;\n\n`" :relatedInformation [(:location (:uri "file:///home/brennan/test_rust/src/main.rs" :range (:start (:line 4 :character 10) :end (:line 4 :character 17))) :message "original diagnostic")])] :version 0)) [server-notification] Mon Sep 16 12:52:55 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rust-analyzer/flycheck/0" :value (:kind "end"))) [server-notification] Mon Sep 16 12:52:56 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :percentage 66))) [server-notification] Mon Sep 16 12:52:56 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "8/12 (alloc)" :perce= ntage 66))) [server-notification] Mon Sep 16 12:52:56 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :percentage 75))) [server-notification] Mon Sep 16 12:52:56 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "9/12 (std)" :percent= age 75))) [server-notification] Mon Sep 16 12:52:56 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :percentage 83))) [server-notification] Mon Sep 16 12:52:56 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "10/12 (proc_macro)" = :percentage 83))) [server-notification] Mon Sep 16 12:52:56 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :percentage 91))) [server-notification] Mon Sep 16 12:52:56 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "11/12 (test_rust)" := percentage 91))) [server-notification] Mon Sep 16 12:52:56 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :percentage 100))) [server-notification] Mon Sep 16 12:52:56 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "end"))) [server-request] (id:22) Mon Sep 16 12:52:56 2024: (:jsonrpc "2.0" :id 22 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Indexing")) [client-reply] (id:22) Mon Sep 16 12:52:56 2024: (:jsonrpc "2.0" :id 22 :result nil) [server-notification] Mon Sep 16 12:52:56 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "begin" :title "Indexing" :cancellable :json-false :percentage 0= ))) [server-notification] Mon Sep 16 12:52:56 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :percentage 66))) [server-notification] Mon Sep 16 12:52:56 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :percentage 75))) [server-notification] Mon Sep 16 12:52:56 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :percentage 83))) [server-notification] Mon Sep 16 12:52:56 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :percentage 91))) [server-notification] Mon Sep 16 12:52:56 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "11/12 (test_rust)" := percentage 91))) [server-notification] Mon Sep 16 12:52:56 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :percentage 100))) [server-notification] Mon Sep 16 12:52:56 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "end"))) [client-request] (id:6) Mon Sep 16 12:52:57 2024: (:jsonrpc "2.0" :id 6 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 23))) [client-request] (id:7) Mon Sep 16 12:52:57 2024: (:jsonrpc "2.0" :id 7 :method "textDocument/hover" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 23))) [client-request] (id:8) Mon Sep 16 12:52:57 2024: (:jsonrpc "2.0" :id 8 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 23))) [server-reply] (id:6) Mon Sep 16 12:52:57 2024: (:jsonrpc "2.0" :id 6 :result nil) [server-reply] (id:7) Mon Sep 16 12:52:57 2024: (:jsonrpc "2.0" :id 7 :result nil) [server-reply] (id:8) Mon Sep 16 12:52:57 2024: (:jsonrpc "2.0" :id 8 :result nil) [client-request] (id:9) Mon Sep 16 12:52:58 2024: (:jsonrpc "2.0" :id 9 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 17))) [client-request] (id:10) Mon Sep 16 12:52:58 2024: (:jsonrpc "2.0" :id 10 :method "textDocument/hover" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 17))) [client-request] (id:11) Mon Sep 16 12:52:58 2024: (:jsonrpc "2.0" :id 11 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 17))) [server-reply] (id:9) Mon Sep 16 12:52:58 2024: (:jsonrpc "2.0" :id 9 :result (:signatures [(:label "struct S" :parameters [(:label [9 10])] :activeParameter 0)] :activeSignature 0 :activeParameter 0)) [server-reply] (id:10) Mon Sep 16 12:52:58 2024: (:jsonrpc "2.0" :id 10 :result nil) [server-reply] (id:11) Mon Sep 16 12:52:58 2024: (:jsonrpc "2.0" :id 11 :result nil) [client-request] (id:12) Mon Sep 16 12:52:59 2024: (:jsonrpc "2.0" :id 12 :method "textDocument/completion" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 17) :context (:triggerKind 1))) [server-reply] (id:12) Mon Sep 16 12:52:59 2024: (:jsonrpc "2.0" :id 12 :result (:isIncomplete t :items [(:label "HashSet (use std::collections::HashSet)" :kind 22 :detail "Ha= shSet<{unknown}, {unknown}>" :documentation (:kind "markdown" :value "A [hash set] implemented as a `HashMap` whe= re the value is `()`.\n\nAs with the [`HashMap`] type, a `HashSet` requires= that the elements\nimplement the [`Eq`] and [`Hash`] traits. This can freq= uently be achieved by\nusing `#[derive(PartialEq, Eq, Hash)]`. If you imple= ment these yourself,\nit is important that the following property holds:\n\= n```text\nk1 =3D=3D k2 -> hash(k1) =3D=3D hash(k2)\n```\n\nIn other words, = if two keys are equal, their hashes must be equal.\nViolating this property= is a logic error.\n\nIt is also a logic error for a key to be modified in = such a way that the key's\nhash, as determined by the [`Hash`] trait, or it= s equality, as determined by\nthe [`Eq`] trait, changes while it is in the = map. This is normally only\npossible through [`Cell`], [`RefCell`], global = state, I/O, or unsafe code.\n\nThe behavior resulting from either logic err= or is not specified, but will\nbe encapsulated to the `HashSet` that observ= ed the logic error and not\nresult in undefined behavior. This could includ= e panics, incorrect results,\naborts, memory leaks, and non-termination.\n\= n# Examples\n\n```rust\nuse std::collections::HashSet;\n// Type inference l= ets us omit an explicit type signature (which\n// would be `HashSet= ` in this example).\nlet mut books =3D HashSet::new();\n\n// Add some books= .\nbooks.insert(\"A Dance With Dragons\".to_string());\nbooks.insert(\"To K= ill a Mockingbird\".to_string());\nbooks.insert(\"The Odyssey\".to_string()= );\nbooks.insert(\"The Great Gatsby\".to_string());\n\n// Check for a speci= fic one.\nif !books.contains(\"The Winds of Winter\") {\n println!(\"We = have {} books, but The Winds of Winter ain't one.\",\n books.le= n());\n}\n\n// Remove a book.\nbooks.remove(\"The Odyssey\");\n\n// Iterate= over everything.\nfor book in &books {\n println!(\"{book}\");\n}\n```\= n\nThe easiest way to use `HashSet` with a custom type is to derive\n[`Eq`]= and [`Hash`]. We must also derive [`PartialEq`],\nwhich is required if [`E= q`] is derived.\n\n```rust\nuse std::collections::HashSet;\n#[derive(Hash, = Eq, PartialEq, Debug)]\nstruct Viking {\n name: String,\n power: usiz= e,\n}\n\nlet mut vikings =3D HashSet::new();\n\nvikings.insert(Viking { nam= e: \"Einar\".to_string(), power: 9 });\nvikings.insert(Viking { name: \"Ein= ar\".to_string(), power: 9 });\nvikings.insert(Viking { name: \"Olaf\".to_s= tring(), power: 4 });\nvikings.insert(Viking { name: \"Harald\".to_string()= , power: 8 });\n\n// Use derived implementation to print the vikings.\nfor = x in &vikings {\n println!(\"{x:?}\");\n}\n```\n\nA `HashSet` with a kno= wn list of items can be initialized from an array:\n\n```rust\nuse std::col= lections::HashSet;\n\nlet viking_names =3D HashSet::from([\"Einar\", \"Olaf= \", \"Harald\"]);\n```\n\n[hash set]: crate::collections#use-the-set-varian= t-of-any-of-these-maps-when\n[`HashMap`]: crate::collections::HashMap\n[`Re= fCell`]: crate::cell::RefCell\n[`Cell`]: crate::cell::Cell") :deprecated :json-false :sortText "fffffff0" :filterText "HashSet" :t= extEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "HashSet") :additionalTextEdits [] :data (:position (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 17)) :imports [(:full_import_path "std::collections::HashSet" :imported_name "Hash= Set")] :version 0)) (:label "self::" :kind 14 :deprecated :json-false :preselect t :sortTe= xt "ffffffef" :filterText "self::" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "self::") :additionalTextEdits []) (:label "crate::" :kind 14 :deprecated :json-false :preselect t :sortT= ext "ffffffef" :filterText "crate::" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "crate::") :additionalTextEdits []) (:label "Self" :kind 12 :detail "S<{unknown}>" :deprecated :json-false= :preselect t :sortText "ffffffef" :filterText "Self" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Self") :additionalTextEdits []) (:label "T" :kind 25 :deprecated :json-false :preselect t :sortText "f= fffffef" :filterText "T" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "T") :additionalTextEdits []) (:label "S" :kind 22 :detail "S<{unknown}>" :deprecated :json-false :p= reselect t :sortText "ffffffef" :filterText "S" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "S") :additionalTextEdits []) (:label "panic!" :kind 3 :detail "macro_rules! panic" :deprecated :jso= n-false :preselect t :sortText "ffffffef" :filterText "panic!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "panic!") :additionalTextEdits []) (:label "println!" :kind 3 :detail "macro_rules! println" :documentati= on (:kind "markdown" :value "Prints to the standard output, with a newli= ne.\n\nOn all platforms, the newline is the LINE FEED character (`\\n`/`U+0= 00A`) alone\n(no additional CARRIAGE RETURN (`\\r`/`U+000D`)).\n\nThis macr= o uses the same syntax as [`format!`], but writes to the standard output in= stead.\nSee [`std::fmt`] for more information.\n\nThe `println!` macro will= lock the standard output on each call. If you call\n`println!` within a ho= t loop, this behavior may be the bottleneck of the loop.\nTo avoid this, lo= ck stdout with [`io::stdout().lock()`][lock]:\n```rust\nuse std::io::{stdou= t, Write};\n\nlet mut lock =3D stdout().lock();\nwriteln!(lock, \"hello wor= ld\").unwrap();\n```\n\nUse `println!` only for the primary output of your = program. Use\n[`eprintln!`] instead to print error and progress messages.\n= \nSee [the formatting documentation in `std::fmt`](../std/fmt/index.html)\n= for details of the macro argument syntax.\n\n[`std::fmt`]: crate::fmt\n[`ep= rintln!`]: crate::eprintln\n[lock]: crate::io::Stdout\n\n# Panics\n\nPanics= if writing to [`io::stdout`] fails.\n\nWriting to non-blocking stdout can = cause an error, which will lead\nthis macro to panic.\n\n[`io::stdout`]: cr= ate::io::stdout\n\n# Examples\n\n```rust\nprintln!(); // prints just a newl= ine\nprintln!(\"hello there!\");\nprintln!(\"format {} arguments\", \"some\= ");\nlet local_variable =3D \"some\";\nprintln!(\"format {local_variable} a= rguments\");\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "println!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "println!") :additionalTextEdits []) (:label "debug_assert_eq!" :kind 3 :detail "macro_rules! debug_assert_= eq" :documentation (:kind "markdown" :value "Asserts that two expressions are equal to e= ach other.\n\nOn panic, this macro will print the values of the expressions= with their\ndebug representations.\n\nUnlike [`assert_eq!`], `debug_assert= _eq!` statements are only enabled in non\noptimized builds by default. An o= ptimized build will not execute\n`debug_assert_eq!` statements unless `-C d= ebug-assertions` is passed to the\ncompiler. This makes `debug_assert_eq!` = useful for checks that are too\nexpensive to be present in a release build = but may be helpful during\ndevelopment. The result of expanding `debug_asse= rt_eq!` is always type checked.\n\n# Examples\n\n```rust\nlet a =3D 3;\nlet= b =3D 1 + 2;\ndebug_assert_eq!(a, b);\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "debug_assert_eq!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "debug_assert_eq!") :additionalTextEdits []) (:label "include_str!" :kind 3 :detail "macro_rules! include_str" :doc= umentation (:kind "markdown" :value "Includes a UTF-8 encoded file as a string.\= n\nThe file is located relative to the current file (similarly to how\nmodu= les are found). The provided path is interpreted in a platform-specific\nwa= y at compile time. So, for instance, an invocation with a Windows path\ncon= taining backslashes `\\` would not compile correctly on Unix.\n\nThis macro= will yield an expression of type `&'static str` which is the\ncontents of = the file.\n\n# Examples\n\nAssume there are two files in the same directory= with the following\ncontents:\n\nFile 'spanish.in':\n\n```text\nadi=C3=B3s= \n```\n\nFile 'main.rs':\n\n```rust\nfn main() {\n let my_str =3D includ= e_str!(\"spanish.in\");\n assert_eq!(my_str, \"adi=C3=B3s\\n\");\n pr= int!(\"{my_str}\");\n}\n```\n\nCompiling 'main.rs' and running the resultin= g binary will print \"adi=C3=B3s\".") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "include_str!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "include_str!") :additionalTextEdits []) (:label "concat!" :kind 3 :detail "macro_rules! concat" :documentation (:kind "markdown" :value "Concatenates literals into a static string = slice.\n\nThis macro takes any number of comma-separated literals, yielding= an\nexpression of type `&'static str` which represents all of the literals= \nconcatenated left-to-right.\n\nInteger and floating point literals are [s= tringified](core::stringify) in order to be\nconcatenated.\n\n# Examples\n\= n```rust\nlet s =3D concat!(\"test\", 10, 'b', true);\nassert_eq!(s, \"test= 10btrue\");\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "concat!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "concat!") :additionalTextEdits []) (:label "format!" :kind 3 :detail "macro_rules! format" :documentation (:kind "markdown" :value "Creates a `String` using interpolation of r= untime expressions.\n\nThe first argument `format!` receives is a format st= ring. This must be a string\nliteral. The power of the formatting string is= in the `{}`s contained.\nAdditional parameters passed to `format!` replace= the `{}`s within the\nformatting string in the order given unless named or= positional parameters\nare used.\n\nSee [the formatting syntax documentati= on in `std::fmt`](../std/fmt/index.html)\nfor details.\n\nA common use for = `format!` is concatenation and interpolation of strings.\nThe same conventi= on is used with [`print!`] and [`write!`] macros,\ndepending on the intende= d destination of the string; all these macros internally use [`format_args!= `].\n\nTo convert a single value to a string, use the [`to_string`] method.= This\nwill use the [`Display`] formatting trait.\n\nTo concatenate literal= s into a `&'static str`, use the [`concat!`] macro.\n\n[`print!`]: ../std/m= acro.print.html\n[`write!`]: core::write\n[`format_args!`]: core::format_ar= gs\n[`to_string`]: crate::string::ToString\n[`Display`]: core::fmt::Display= \n[`concat!`]: core::concat\n\n# Panics\n\n`format!` panics if a formatting= trait implementation returns an error.\nThis indicates an incorrect implem= entation\nsince `fmt::Write for String` never returns an error itself.\n\n#= Examples\n\n```rust\nformat!(\"test\"); // =3D= > \"test\"\nformat!(\"hello {}\", \"world!\"); // =3D> \"hell= o world!\"\nformat!(\"x =3D {}, y =3D {val}\", 10, val =3D 30); // =3D> \"= x =3D 10, y =3D 30\"\nlet (x, y) =3D (1, 2);\nformat!(\"{x} + {y} =3D 3\");= // =3D> \"1 + 2 =3D 3\"\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "format!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "format!") :additionalTextEdits []) (:label "stringify!" :kind 3 :detail "macro_rules! stringify" :documen= tation (:kind "markdown" :value "Stringifies its arguments.\n\nThis macro wi= ll yield an expression of type `&'static str` which is the\nstringification= of all the tokens passed to the macro. No restrictions\nare placed on the = syntax of the macro invocation itself.\n\nNote that the expanded results of= the input tokens may change in the\nfuture. You should be careful if you r= ely on the output.\n\n# Examples\n\n```rust\nlet one_plus_one =3D stringify= !(1 + 1);\nassert_eq!(one_plus_one, \"1 + 1\");\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "stringify!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "stringify!") :additionalTextEdits []) (:label "assert_ne!" :kind 3 :detail "macro_rules! assert_ne" :documen= tation (:kind "markdown" :value "Asserts that two expressions are not equal = to each other (using [`PartialEq`]).\n\nOn panic, this macro will print the= values of the expressions with their\ndebug representations.\n\nLike [`ass= ert!`], this macro has a second form, where a custom\npanic message can be = provided.\n\n# Examples\n\n```rust\nlet a =3D 3;\nlet b =3D 2;\nassert_ne!(= a, b);\n\nassert_ne!(a, b, \"we are testing that the values are not equal\"= );\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "assert_ne!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "assert_ne!") :additionalTextEdits []) (:label "dbg!" :kind 3 :detail "macro_rules! dbg" :documentation (:kind "markdown" :value "Prints and returns the value of a given exp= ression for quick and dirty\ndebugging.\n\nAn example:\n\n```rust\nlet a = =3D 2;\nlet b =3D dbg!(a * 2) + 1;\n// ^-- prints: [src/main.rs:2:9] a= * 2 =3D 4\nassert_eq!(b, 5);\n```\n\nThe macro works by using the `Debug` = implementation of the type of\nthe given expression to print the value to [= stderr] along with the\nsource location of the macro invocation as well as = the source code\nof the expression.\n\nInvoking the macro on an expression = moves and takes ownership of it\nbefore returning the evaluated expression = unchanged. If the type\nof the expression does not implement `Copy` and you= don't want\nto give up ownership, you can instead borrow with `dbg!(&expr)= `\nfor some expression `expr`.\n\nThe `dbg!` macro works exactly the same i= n release builds.\nThis is useful when debugging issues that only occur in = release\nbuilds or when debugging in release mode is significantly faster.\= n\nNote that the macro is intended as a debugging tool and therefore you\ns= hould avoid having uses of it in version control for long periods\n(other t= han in tests and similar).\nDebug output from production code is better don= e with other facilities\nsuch as the [`debug!`] macro from the [`log`] crat= e.\n\n# Stability\n\nThe exact output printed by this macro should not be r= elied upon\nand is subject to future changes.\n\n# Panics\n\nPanics if writ= ing to `io::stderr` fails.\n\n# Further examples\n\nWith a method call:\n\n= ```rust\nfn foo(n: usize) {\n if let Some(_) =3D dbg!(n.checked_sub(4)) = {\n // ...\n }\n}\n\nfoo(3)\n```\n\nThis prints to [stderr]:\n\n`= ``text,ignore\n[src/main.rs:2:22] n.checked_sub(4) =3D None\n```\n\nNaive f= actorial implementation:\n\n```rust\nfn factorial(n: u32) -> u32 {\n if = dbg!(n <=3D 1) {\n dbg!(1)\n } else {\n dbg!(n * factorial= (n - 1))\n }\n}\n\ndbg!(factorial(4));\n```\n\nThis prints to [stderr]:\= n\n```text,ignore\n[src/main.rs:2:8] n <=3D 1 =3D false\n[src/main.rs:2:8] = n <=3D 1 =3D false\n[src/main.rs:2:8] n <=3D 1 =3D false\n[src/main.rs:2:8]= n <=3D 1 =3D true\n[src/main.rs:3:9] 1 =3D 1\n[src/main.rs:7:9] n * factor= ial(n - 1) =3D 2\n[src/main.rs:7:9] n * factorial(n - 1) =3D 6\n[src/main.r= s:7:9] n * factorial(n - 1) =3D 24\n[src/main.rs:9:1] factorial(4) =3D 24\n= ```\n\nThe `dbg!(..)` macro moves the input:\n\n```rust\n/// A wrapper arou= nd `usize` which importantly is not Copyable.\n#[derive(Debug)]\nstruct NoC= opy(usize);\n\nlet a =3D NoCopy(42);\nlet _ =3D dbg!(a); // <-- `a` is move= d here.\nlet _ =3D dbg!(a); // <-- `a` is moved again; error!\n```\n\nYou c= an also use `dbg!()` without a value to just print the\nfile and line whene= ver it's reached.\n\nFinally, if you want to `dbg!(..)` multiple values, it= will treat them as\na tuple (and return it, too):\n\n```rust\nassert_eq!(d= bg!(1usize, 2u32), (1, 2));\n```\n\nHowever, a single argument with a trail= ing comma will still not be treated\nas a tuple, following the convention o= f ignoring trailing commas in macro\ninvocations. You can use a 1-tuple dir= ectly if you need one:\n\n```rust\nassert_eq!(1, dbg!(1u32,)); // trailing = comma ignored\nassert_eq!((1,), dbg!((1u32,))); // 1-tuple\n```\n\n[stderr]= : https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)\n[= `debug!`]: https://docs.rs/log/*/log/macro.debug.html\n[`log`]: https://cra= tes.io/crates/log") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "dbg!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "dbg!") :additionalTextEdits []) (:label "vec!" :kind 3 :detail "macro_rules! vec" :documentation (:kind "markdown" :value "Creates a [`Vec`] containing the arguments.= \n\n`vec!` allows `Vec`s to be defined with the same syntax as array expres= sions.\nThere are two forms of this macro:\n\n- Create a [`Vec`] containing= a given list of elements:\n\n```rust\nlet v =3D vec![1, 2, 3];\nassert_eq!= (v[0], 1);\nassert_eq!(v[1], 2);\nassert_eq!(v[2], 3);\n```\n\n- Create a [= `Vec`] from a given element and size:\n\n```rust\nlet v =3D vec![1; 3];\nas= sert_eq!(v, [1, 1, 1]);\n```\n\nNote that unlike array expressions this syn= tax supports all elements\nwhich implement [`Clone`] and the number of elem= ents doesn't have to be\na constant.\n\nThis will use `clone` to duplicate = an expression, so one should be careful\nusing this with types having a non= standard `Clone` implementation. For\nexample, `vec![Rc::new(1); 5]` will c= reate a vector of five references\nto the same boxed integer value, not fiv= e references pointing to independently\nboxed integers.\n\nAlso, note that = `vec![expr; 0]` is allowed, and produces an empty vector.\nThis will still = evaluate `expr`, however, and immediately drop the resulting value, so\nbe = mindful of side effects.\n\n[`Vec`]: crate::vec::Vec") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "vec!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "vec!") :additionalTextEdits []) (:label "include!" :kind 3 :detail "macro_rules! include" :documentati= on (:kind "markdown" :value "Parses a file as an expression or an item a= ccording to the context.\n\n**Warning**: For multi-file Rust projects, the = `include!` macro is probably not what you\nare looking for. Usually, multi-= file Rust projects use\n[modules](https://doc.rust-lang.org/reference/items= /modules.html). Multi-file projects and\nmodules are explained in the Rust-= by-Example book\n[here](https://doc.rust-lang.org/rust-by-example/mod/split= .html) and the module system is\nexplained in the Rust Book\n[here](https:/= /doc.rust-lang.org/book/ch07-02-defining-modules-to-control-scope-and-priva= cy.html).\n\nThe included file is placed in the surrounding code\n[unhygien= ically](https://doc.rust-lang.org/reference/macros-by-example.html#hygiene)= . If\nthe included file is parsed as an expression and variables or functio= ns share names across\nboth files, it could result in variables or function= s being different from what the\nincluded file expected.\n\nThe included fi= le is located relative to the current file (similarly to how modules are\nf= ound). The provided path is interpreted in a platform-specific way at compi= le time. So,\nfor instance, an invocation with a Windows path containing ba= ckslashes `\\` would not\ncompile correctly on Unix.\n\n# Uses\n\nThe `incl= ude!` macro is primarily used for two purposes. It is used to include\ndocu= mentation that is written in a separate file and it is used to include [bui= ld artifacts\nusually as a result from the `build.rs`\nscript](https://doc.= rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-scrip= t).\n\nWhen using the `include` macro to include stretches of documentation= , remember that the\nincluded file still needs to be a valid Rust syntax. I= t is also possible to\nuse the [`include_str`] macro as `#![doc =3D include= _str!(\"...\")]` (at the module level) or\n`#[doc =3D include_str!(\"...\")= ]` (at the item level) to include documentation from a plain\ntext or markd= own file.\n\n# Examples\n\nAssume there are two files in the same directory= with the following contents:\n\nFile 'monkeys.in':\n\n```rust\n['=F0=9F=99= =88', '=F0=9F=99=8A', '=F0=9F=99=89']\n .iter()\n .cycle()\n .take= (6)\n .collect::()\n```\n\nFile 'main.rs':\n\n```rust\nfn main()= {\n let my_string =3D include!(\"monkeys.in\");\n assert_eq!(\"=F0= =9F=99=88=F0=9F=99=8A=F0=9F=99=89=F0=9F=99=88=F0=9F=99=8A=F0=9F=99=89\", my= _string);\n println!(\"{my_string}\");\n}\n```\n\nCompiling 'main.rs' an= d running the resulting binary will print\n\"=F0=9F=99=88=F0=9F=99=8A=F0=9F= =99=89=F0=9F=99=88=F0=9F=99=8A=F0=9F=99=89\".") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "include!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "include!") :additionalTextEdits []) (:label "print!" :kind 3 :detail "macro_rules! print" :documentation (:kind "markdown" :value "Prints to the standard output.\n\nEquivalen= t to the [`println!`] macro except that a newline is not printed at\nthe en= d of the message.\n\nNote that stdout is frequently line-buffered by defaul= t so it may be\nnecessary to use [`io::stdout().flush()`][flush] to ensure = the output is emitted\nimmediately.\n\nThe `print!` macro will lock the sta= ndard output on each call. If you call\n`print!` within a hot loop, this be= havior may be the bottleneck of the loop.\nTo avoid this, lock stdout with = [`io::stdout().lock()`][lock]:\n```rust\nuse std::io::{stdout, Write};\n\nl= et mut lock =3D stdout().lock();\nwrite!(lock, \"hello world\").unwrap();\n= ```\n\nUse `print!` only for the primary output of your program. Use\n[`epr= int!`] instead to print error and progress messages.\n\nSee [the formatting= documentation in `std::fmt`](../std/fmt/index.html)\nfor details of the ma= cro argument syntax.\n\n[flush]: crate::io::Write::flush\n[`println!`]: cra= te::println\n[`eprint!`]: crate::eprint\n[lock]: crate::io::Stdout\n\n# Pan= ics\n\nPanics if writing to `io::stdout()` fails.\n\nWriting to non-blockin= g stdout can cause an error, which will lead\nthis macro to panic.\n\n# Exa= mples\n\n```rust\nuse std::io::{self, Write};\n\nprint!(\"this \");\nprint!= (\"will \");\nprint!(\"be \");\nprint!(\"on \");\nprint!(\"the \");\nprint!= (\"same \");\nprint!(\"line \");\n\nio::stdout().flush().unwrap();\n\nprint= !(\"this string has a newline, why not choose println! instead?\\n\");\n\ni= o::stdout().flush().unwrap();\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "print!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "print!") :additionalTextEdits []) (:label "write!" :kind 3 :detail "macro_rules! write" :documentation (:kind "markdown" :value "Writes formatted data into a buffer.\n\nThi= s macro accepts a 'writer', a format string, and a list of arguments. Argum= ents will be\nformatted according to the specified format string and the re= sult will be passed to the writer.\nThe writer may be any value with a `wri= te_fmt` method; generally this comes from an\nimplementation of either the = [`fmt::Write`] or the [`io::Write`] trait. The macro\nreturns whatever the = `write_fmt` method returns; commonly a [`fmt::Result`], or an\n[`io::Result= `].\n\nSee [`std::fmt`] for more information on the format string syntax.\n= \n[`std::fmt`]: ../std/fmt/index.html\n[`fmt::Write`]: crate::fmt::Write\n[= `io::Write`]: ../std/io/trait.Write.html\n[`fmt::Result`]: crate::fmt::Resu= lt\n[`io::Result`]: ../std/io/type.Result.html\n\n# Examples\n\n```rust\nus= e std::io::Write;\n\nfn main() -> std::io::Result<()> {\n let mut w =3D = Vec::new();\n write!(&mut w, \"test\")?;\n write!(&mut w, \"formatted= {}\", \"arguments\")?;\n\n assert_eq!(w, b\"testformatted arguments\");= \n Ok(())\n}\n```\n\nA module can import both `std::fmt::Write` and `std= ::io::Write` and call `write!` on objects\nimplementing either, as objects = do not typically implement both. However, the module must\navoid conflict b= etween the trait names, such as by importing them as `_` or otherwise renam= ing\nthem:\n\n```rust\nuse std::fmt::Write as _;\nuse std::io::Write as _;\= n\nfn main() -> Result<(), Box> {\n let mut s =3D= String::new();\n let mut v =3D Vec::new();\n\n write!(&mut s, \"{} {= }\", \"abc\", 123)?; // uses fmt::Write::write_fmt\n write!(&mut v, \"s = =3D {:?}\", s)?; // uses io::Write::write_fmt\n assert_eq!(v, b\"s =3D \= \\"abc 123\\\"\");\n Ok(())\n}\n```\n\nIf you also need the trait names = themselves, such as to implement one or both on your types,\nimport the con= taining module and then name them with a prefix:\n\n```rust\nuse std::fmt::= {self, Write as _};\nuse std::io::{self, Write as _};\n\nstruct Example;\n\= nimpl fmt::Write for Example {\n fn write_str(&mut self, _s: &str) -> co= re::fmt::Result {\n unimplemented!();\n }\n}\n```\n\nNote: This = macro can be used in `no_std` setups as well.\nIn a `no_std` setup you are = responsible for the implementation details of the components.\n\n```rust\nu= se core::fmt::Write;\n\nstruct Example;\n\nimpl Write for Example {\n fn= write_str(&mut self, _s: &str) -> core::fmt::Result {\n unimplemen= ted!();\n }\n}\n\nlet mut m =3D Example{};\nwrite!(&mut m, \"Hello World= \").expect(\"Not written\");\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "write!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "write!") :additionalTextEdits []) (:label "line!" :kind 3 :detail "macro_rules! line" :documentation (:kind "markdown" :value "Expands to the line number on which it was = invoked.\n\nWith [`column!`] and [`file!`], these macros provide debugging = information for\ndevelopers about the location within the source.\n\nThe ex= panded expression has type `u32` and is 1-based, so the first line\nin each= file evaluates to 1, the second to 2, etc. This is consistent\nwith error = messages by common compilers or popular editors.\nThe returned line is *not= necessarily* the line of the `line!` invocation itself,\nbut rather the fi= rst macro invocation leading up to the invocation\nof the `line!` macro.\n\= n# Examples\n\n```rust\nlet current_line =3D line!();\nprintln!(\"defined o= n line: {current_line}\");\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "line!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "line!") :additionalTextEdits []) (:label "debug_assert!" :kind 3 :detail "macro_rules! debug_assert" :d= ocumentation (:kind "markdown" :value "Asserts that a boolean expression is `true`= at runtime.\n\nThis will invoke the [`panic!`] macro if the provided expre= ssion cannot be\nevaluated to `true` at runtime.\n\nLike [`assert!`], this = macro also has a second version, where a custom panic\nmessage can be provi= ded.\n\n# Uses\n\nUnlike [`assert!`], `debug_assert!` statements are only e= nabled in non\noptimized builds by default. An optimized build will not exe= cute\n`debug_assert!` statements unless `-C debug-assertions` is passed to = the\ncompiler. This makes `debug_assert!` useful for checks that are too\ne= xpensive to be present in a release build but may be helpful during\ndevelo= pment. The result of expanding `debug_assert!` is always type checked.\n\nA= n unchecked assertion allows a program in an inconsistent state to keep\nru= nning, which might have unexpected consequences but does not introduce\nuns= afety as long as this only happens in safe code. The performance cost\nof a= ssertions, however, is not measurable in general. Replacing [`assert!`]\nwi= th `debug_assert!` is thus only encouraged after thorough profiling, and\nm= ore importantly, only in safe code!\n\n# Examples\n\n```rust\n// the panic = message for these assertions is the stringified value of the\n// expression= given.\ndebug_assert!(true);\n\nfn some_expensive_computation() -> bool { = true } // a very simple function\ndebug_assert!(some_expensive_computation(= ));\n\n// assert with a custom message\nlet x =3D true;\ndebug_assert!(x, \= "x wasn't true!\");\n\nlet a =3D 3; let b =3D 27;\ndebug_assert!(a + b =3D= =3D 30, \"a =3D {}, b =3D {}\", a, b);\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "debug_assert!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "debug_assert!") :additionalTextEdits []) (:label "include_bytes!" :kind 3 :detail "macro_rules! include_bytes" = :documentation (:kind "markdown" :value "Includes a file as a reference to a byte ar= ray.\n\nThe file is located relative to the current file (similarly to how\= nmodules are found). The provided path is interpreted in a platform-specifi= c\nway at compile time. So, for instance, an invocation with a Windows path= \ncontaining backslashes `\\` would not compile correctly on Unix.\n\nThis = macro will yield an expression of type `&'static [u8; N]` which is\nthe con= tents of the file.\n\n# Examples\n\nAssume there are two files in the same = directory with the following\ncontents:\n\nFile 'spanish.in':\n\n```text\na= di=C3=B3s\n```\n\nFile 'main.rs':\n\n```rust\nfn main() {\n let bytes = =3D include_bytes!(\"spanish.in\");\n assert_eq!(bytes, b\"adi\\xc3\\xb3= s\\n\");\n print!(\"{}\", String::from_utf8_lossy(bytes));\n}\n```\n\nCo= mpiling 'main.rs' and running the resulting binary will print \"adi=C3=B3s\= ".") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "include_bytes!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "include_bytes!") :additionalTextEdits []) (:label "env!" :kind 3 :detail "macro_rules! env" :documentation (:kind "markdown" :value "Inspects an environment variable at compile= time.\n\nThis macro will expand to the value of the named environment vari= able at\ncompile time, yielding an expression of type `&'static str`. Use\n= [`std::env::var`] instead if you want to read the value at runtime.\n\n[`st= d::env::var`]: ../std/env/fn.var.html\n\nIf the environment variable is not= defined, then a compilation error\nwill be emitted. To not emit a compile = error, use the [`option_env!`]\nmacro instead. A compilation error will als= o be emitted if the\nenvironment variable is not a vaild Unicode string.\n\= n# Examples\n\n```rust\nlet path: &'static str =3D env!(\"PATH\");\nprintln= !(\"the $PATH variable at the time of compiling was: {path}\");\n```\n\nYou= can customize the error message by passing a string as the second\nparamet= er:\n\n```rust\nlet doc: &'static str =3D env!(\"documentation\", \"what's = that?!\");\n```\n\nIf the `documentation` environment variable is not defin= ed, you'll get\nthe following error:\n\n```text\nerror: what's that?!\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "env!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "env!") :additionalTextEdits []) (:label "try!" :kind 3 :detail "macro_rules! r#try" :documentation (:kind "markdown" :value "Unwraps a result or propagates its error.\n= \nThe [`?` operator][propagating-errors] was added to replace `try!`\nand s= hould be used instead. Furthermore, `try` is a reserved word\nin Rust 2018,= so if you must use it, you will need to use the\n[raw-identifier syntax][r= is]: `r#try`.\n\n[propagating-errors]: https://doc.rust-lang.org/book/ch09-= 02-recoverable-errors-with-result.html#a-shortcut-for-propagating-errors-th= e--operator\n[ris]: https://doc.rust-lang.org/nightly/rust-by-example/compa= tibility/raw_identifiers.html\n\n`try!` matches the given [`Result`]. In ca= se of the `Ok` variant, the\nexpression has the value of the wrapped value.= \n\nIn case of the `Err` variant, it retrieves the inner error. `try!` then= \nperforms conversion using `From`. This provides automatic conversion\nbet= ween specialized errors and more general ones. The resulting\nerror is then= immediately returned.\n\nBecause of the early return, `try!` can only be u= sed in functions that\nreturn [`Result`].\n\n# Examples\n\n```rust\nuse std= ::io;\nuse std::fs::File;\nuse std::io::prelude::*;\n\nenum MyError {\n = FileWriteError\n}\n\nimpl From for MyError {\n fn from(e: io:= :Error) -> MyError {\n MyError::FileWriteError\n }\n}\n\n// The p= referred method of quick returning Errors\nfn write_to_file_question() -> R= esult<(), MyError> {\n let mut file =3D File::create(\"my_best_friends.t= xt\")?;\n file.write_all(b\"This is a list of my best friends.\")?;\n = Ok(())\n}\n\n// The previous method of quick returning Errors\nfn write_to= _file_using_try() -> Result<(), MyError> {\n let mut file =3D r#try!(Fil= e::create(\"my_best_friends.txt\"));\n r#try!(file.write_all(b\"This is = a list of my best friends.\"));\n Ok(())\n}\n\n// This is equivalent to:= \nfn write_to_file_using_match() -> Result<(), MyError> {\n let mut file= =3D r#try!(File::create(\"my_best_friends.txt\"));\n match file.write_a= ll(b\"This is a list of my best friends.\") {\n Ok(v) =3D> v,\n = Err(e) =3D> return Err(From::from(e)),\n }\n Ok(())\n}\n```") :deprecated t :preselect t :sortText "ffffffef" :filterText "try!" :t= extEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "r#try!") :additionalTextEdits [] :tags [1]) (:label "file!" :kind 3 :detail "macro_rules! file" :documentation (:kind "markdown" :value "Expands to the file name in which it was in= voked.\n\nWith [`line!`] and [`column!`], these macros provide debugging in= formation for\ndevelopers about the location within the source.\n\nThe expa= nded expression has type `&'static str`, and the returned file\nis not the = invocation of the `file!` macro itself, but rather the\nfirst macro invocat= ion leading up to the invocation of the `file!`\nmacro.\n\n# Examples\n\n``= `rust\nlet this_file =3D file!();\nprintln!(\"defined in file: {this_file}\= ");\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "file!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "file!") :additionalTextEdits []) (:label "thread_local!" :kind 3 :detail "macro_rules! thread_local" :d= ocumentation (:kind "markdown" :value "Declare a new thread local storage key of t= ype [`std::thread::LocalKey`].\n\n# Syntax\n\nThe macro wraps any number of= static declarations and makes them thread local.\nPublicity and attributes= for each static are allowed. Example:\n\n```rust\nuse std::cell::{Cell, Re= fCell};\n\nthread_local! {\n pub static FOO: Cell =3D Cell::new(1);= \n\n static BAR: RefCell> =3D RefCell::new(vec![1.0, 2.0]);\n}\= n\nassert_eq!(FOO.get(), 1);\nBAR.with_borrow(|v| assert_eq!(v[1], 2.0));\n= ```\n\nNote that only shared references (`&T`) to the inner data may be obt= ained, so a\ntype such as [`Cell`] or [`RefCell`] is typically used to allo= w mutating access.\n\nThis macro supports a special `const {}` syntax that = can be used\nwhen the initialization expression can be evaluated as a const= ant.\nThis can enable a more efficient thread local implementation that\nca= n avoid lazy initialization. For types that do not\n[need to be dropped][cr= ate::mem::needs_drop], this can enable an\neven more efficient implementati= on that does not need to\ntrack any additional state.\n\n```rust\nuse std::= cell::RefCell;\n\nthread_local! {\n pub static FOO: RefCell> = =3D const { RefCell::new(Vec::new()) };\n}\n\nFOO.with_borrow(|v| assert_eq= !(v.len(), 0));\n```\n\nSee [`LocalKey` documentation][`std::thread::LocalK= ey`] for more\ninformation.\n\n[`std::thread::LocalKey`]: crate::thread::Lo= calKey") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "thread_local!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "thread_local!") :additionalTextEdits []) (:label "assert!" :kind 3 :detail "macro_rules! assert" :documentation (:kind "markdown" :value "Asserts that a boolean expression is `true`= at runtime.\n\nThis will invoke the [`panic!`] macro if the provided expre= ssion cannot be\nevaluated to `true` at runtime.\n\n# Uses\n\nAssertions ar= e always checked in both debug and release builds, and cannot\nbe disabled.= See [`debug_assert!`] for assertions that are not enabled in\nrelease buil= ds by default.\n\nUnsafe code may rely on `assert!` to enforce run-time inv= ariants that, if\nviolated could lead to unsafety.\n\nOther use-cases of `a= ssert!` include testing and enforcing run-time\ninvariants in safe code (wh= ose violation cannot result in unsafety).\n\n# Custom Messages\n\nThis macr= o has a second form, where a custom panic message can\nbe provided with or = without arguments for formatting. See [`std::fmt`]\nfor syntax for this for= m. Expressions used as format arguments will only\nbe evaluated if the asse= rtion fails.\n\n[`std::fmt`]: ../std/fmt/index.html\n\n# Examples\n\n```rus= t\n// the panic message for these assertions is the stringified value of th= e\n// expression given.\nassert!(true);\n\nfn some_computation() -> bool { = true } // a very simple function\n\nassert!(some_computation());\n\n// asse= rt with a custom message\nlet x =3D true;\nassert!(x, \"x wasn't true!\");\= n\nlet a =3D 3; let b =3D 27;\nassert!(a + b =3D=3D 30, \"a =3D {}, b =3D {= }\", a, b);\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "assert!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "assert!") :additionalTextEdits []) (:label "column!" :kind 3 :detail "macro_rules! column" :documentation (:kind "markdown" :value "Expands to the column number at which it wa= s invoked.\n\nWith [`line!`] and [`file!`], these macros provide debugging = information for\ndevelopers about the location within the source.\n\nThe ex= panded expression has type `u32` and is 1-based, so the first column\nin ea= ch line evaluates to 1, the second to 2, etc. This is consistent\nwith erro= r messages by common compilers or popular editors.\nThe returned column is = *not necessarily* the line of the `column!` invocation itself,\nbut rather = the first macro invocation leading up to the invocation\nof the `column!` m= acro.\n\n# Examples\n\n```rust\nlet current_col =3D column!();\nprintln!(\"= defined on column: {current_col}\");\n```\n\n`column!` counts Unicode code = points, not bytes or graphemes. As a result, the first two\ninvocations ret= urn the same value, but the third does not.\n\n```rust\nlet a =3D (\"foobar= \", column!()).1;\nlet b =3D (\"=E4=BA=BA=E4=B9=8B=E5=88=9D=E6=80=A7=E6=9C= =AC=E5=96=84\", column!()).1;\nlet c =3D (\"f=CC=85o=CC=85o=CC=85b=CC=85a= =CC=85r=CC=85\", column!()).1; // Uses combining overline (U+0305)\n\nasser= t_eq!(a, b);\nassert_ne!(b, c);\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "column!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "column!") :additionalTextEdits []) (:label "unreachable!" :kind 3 :detail "macro_rules! unreachable" :doc= umentation (:kind "markdown" :value "Indicates unreachable code.\n\nThis is usef= ul any time that the compiler can't determine that some code is unreachable= . For\nexample:\n\n* Match arms with guard conditions.\n* Loops that dynami= cally terminate.\n* Iterators that dynamically terminate.\n\nIf the determi= nation that the code is unreachable proves incorrect, the\nprogram immediat= ely terminates with a [`panic!`].\n\nThe unsafe counterpart of this macro i= s the [`unreachable_unchecked`] function, which\nwill cause undefined behav= ior if the code is reached.\n\n[`unreachable_unchecked`]: crate::hint::unre= achable_unchecked\n\n# Panics\n\nThis will always [`panic!`] because `unrea= chable!` is just a shorthand for `panic!` with a\nfixed, specific message.\= n\nLike `panic!`, this macro has a second form for displaying custom values= .\n\n# Examples\n\nMatch arms:\n\n```rust\nfn foo(x: Option) {\n ma= tch x {\n Some(n) if n >=3D 0 =3D> println!(\"Some(Non-negative)\"),= \n Some(n) if n < 0 =3D> println!(\"Some(Negative)\"),\n Som= e(_) =3D> unreachable!(), // compile error if commented out\n = None =3D> println!(\"None\")\n }\n}\n```\n\nIterators:\= n\n```rust\nfn divide_by_three(x: u32) -> u32 { // one of the poorest imple= mentations of x/3\n for i in 0.. {\n if 3*i < i { panic!(\"u32 ov= erflow\"); }\n if x < 3*i { return i-1; }\n }\n unreachable!(\= "The loop should always return\");\n}\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "unreachable!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "unreachable!") :additionalTextEdits []) (:label "eprintln!" :kind 3 :detail "macro_rules! eprintln" :documenta= tion (:kind "markdown" :value "Prints to the standard error, with a newlin= e.\n\nEquivalent to the [`println!`] macro, except that output goes to\n[`i= o::stderr`] instead of [`io::stdout`]. See [`println!`] for\nexample usage.= \n\nUse `eprintln!` only for error and progress messages. Use `println!`\ni= nstead for the primary output of your program.\n\nSee [the formatting docum= entation in `std::fmt`](../std/fmt/index.html)\nfor details of the macro ar= gument syntax.\n\n[`io::stderr`]: crate::io::stderr\n[`io::stdout`]: crate:= :io::stdout\n[`println!`]: crate::println\n\n# Panics\n\nPanics if writing = to `io::stderr` fails.\n\nWriting to non-blocking stderr can cause an error= , which will lead\nthis macro to panic.\n\n# Examples\n\n```rust\neprintln!= (\"Error: Could not complete task\");\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "eprintln!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "eprintln!") :additionalTextEdits []) (:label "unimplemented!" :kind 3 :detail "macro_rules! unimplemented" = :documentation (:kind "markdown" :value "Indicates unimplemented code by panicking w= ith a message of \"not implemented\".\n\nThis allows your code to type-chec= k, which is useful if you are prototyping or\nimplementing a trait that req= uires multiple methods which you don't plan to use all of.\n\nThe differenc= e between `unimplemented!` and [`todo!`] is that while `todo!`\nconveys an = intent of implementing the functionality later and the message is \"not yet= \nimplemented\", `unimplemented!` makes no such claims. Its message is \"no= t implemented\".\n\nAlso, some IDEs will mark `todo!`s.\n\n# Panics\n\nThis= will always [`panic!`] because `unimplemented!` is just a shorthand for `p= anic!` with a\nfixed, specific message.\n\nLike `panic!`, this macro has a = second form for displaying custom values.\n\n[`todo!`]: crate::todo\n\n# Ex= amples\n\nSay we have a trait `Foo`:\n\n```rust\ntrait Foo {\n fn bar(&s= elf) -> u8;\n fn baz(&self);\n fn qux(&self) -> Result;\n}\n= ```\n\nWe want to implement `Foo` for 'MyStruct', but for some reason it on= ly makes sense\nto implement the `bar()` function. `baz()` and `qux()` will= still need to be defined\nin our implementation of `Foo`, but we can use `= unimplemented!` in their definitions\nto allow our code to compile.\n\nWe s= till want to have our program stop running if the unimplemented methods are= \nreached.\n\n```rust\nstruct MyStruct;\n\nimpl Foo for MyStruct {\n fn = bar(&self) -> u8 {\n 1 + 1\n }\n\n fn baz(&self) {\n //= It makes no sense to `baz` a `MyStruct`, so we have no logic here\n = // at all.\n // This will display \"thread 'main' panicked at 'not = implemented'\".\n unimplemented!();\n }\n\n fn qux(&self) -> R= esult {\n // We have some logic here,\n // We can ad= d a message to unimplemented! to display our omission.\n // This wil= l display:\n // \"thread 'main' panicked at 'not implemented: MyStru= ct isn't quxable'\".\n unimplemented!(\"MyStruct isn't quxable\");\n= }\n}\n\nfn main() {\n let s =3D MyStruct;\n s.bar();\n}\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "unimplemented!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "unimplemented!") :additionalTextEdits []) (:label "cfg!" :kind 3 :detail "macro_rules! cfg" :documentation (:kind "markdown" :value "Evaluates boolean combinations of configura= tion flags at compile-time.\n\nIn addition to the `#[cfg]` attribute, this = macro is provided to allow\nboolean expression evaluation of configuration = flags. This frequently\nleads to less duplicated code.\n\nThe syntax given = to this macro is the same syntax as the [`cfg`]\nattribute.\n\n`cfg!`, unli= ke `#[cfg]`, does not remove any code and only evaluates to true or false. = For\nexample, all blocks in an if/else expression need to be valid when `cf= g!` is used for\nthe condition, regardless of what `cfg!` is evaluating.\n\= n[`cfg`]: ../reference/conditional-compilation.html#the-cfg-attribute\n\n# = Examples\n\n```rust\nlet my_directory =3D if cfg!(windows) {\n \"windows= -specific-directory\"\n} else {\n \"unix-directory\"\n};\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "cfg!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "cfg!") :additionalTextEdits []) (:label "todo!" :kind 3 :detail "macro_rules! todo" :documentation (:kind "markdown" :value "Indicates unfinished code.\n\nThis can be u= seful if you are prototyping and just\nwant a placeholder to let your code = pass type analysis.\n\nThe difference between [`unimplemented!`] and `todo!= ` is that while `todo!` conveys\nan intent of implementing the functionalit= y later and the message is \"not yet\nimplemented\", `unimplemented!` makes= no such claims. Its message is \"not implemented\".\n\nAlso, some IDEs wil= l mark `todo!`s.\n\n# Panics\n\nThis will always [`panic!`] because `todo!`= is just a shorthand for `panic!` with a\nfixed, specific message.\n\nLike = `panic!`, this macro has a second form for displaying custom values.\n\n# E= xamples\n\nHere's an example of some in-progress code. We have a trait `Foo= `:\n\n```rust\ntrait Foo {\n fn bar(&self) -> u8;\n fn baz(&self);\n = fn qux(&self) -> Result;\n}\n```\n\nWe want to implement `Foo` = on one of our types, but we also want to work on\njust `bar()` first. In or= der for our code to compile, we need to implement\n`baz()` and `qux()`, so = we can use `todo!`:\n\n```rust\nstruct MyStruct;\n\nimpl Foo for MyStruct {= \n fn bar(&self) -> u8 {\n 1 + 1\n }\n\n fn baz(&self) {\n = // Let's not worry about implementing baz() for now\n todo!()= ;\n }\n\n fn qux(&self) -> Result {\n // We can add a= message to todo! to display our omission.\n // This will display:\n= // \"thread 'main' panicked at 'not yet implemented: MyStruct is no= t yet quxable'\".\n todo!(\"MyStruct is not yet quxable\");\n }\n= }\n\nfn main() {\n let s =3D MyStruct;\n s.bar();\n\n // We aren't= even using baz() or qux(), so this is fine.\n}\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "todo!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "todo!") :additionalTextEdits []) (:label "module_path!" :kind 3 :detail "macro_rules! module_path" :doc= umentation (:kind "markdown" :value "Expands to a string that represents the cur= rent module path.\n\nThe current module path can be thought of as the hiera= rchy of modules\nleading back up to the crate root. The first component of = the path\nreturned is the name of the crate currently being compiled.\n\n# = Examples\n\n```rust\nmod test {\n pub fn foo() {\n assert!(module= _path!().ends_with(\"test\"));\n }\n}\n\ntest::foo();\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "module_path!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "module_path!") :additionalTextEdits []) (:label "option_env!" :kind 3 :detail "macro_rules! option_env" :docum= entation (:kind "markdown" :value "Optionally inspects an environment variable= at compile time.\n\nIf the named environment variable is present at compil= e time, this will\nexpand into an expression of type `Option<&'static str>`= whose value is\n`Some` of the value of the environment variable. If the en= vironment\nvariable is not present, then this will expand to `None`. See\n[= `Option`][Option] for more information on this type. Use\n[`std::env::v= ar`] instead if you want to read the value at runtime.\n\n[`std::env::var`]= : ../std/env/fn.var.html\n\nA compile time error is never emitted when usin= g this macro regardless\nof whether the environment variable is present or = not.\nTo emit a compile error if the environment variable is not present,\n= use the [`env!`] macro instead.\n\n# Examples\n\n```rust\nlet key: Option<&= 'static str> =3D option_env!(\"SECRET_KEY\");\nprintln!(\"the secret key mi= ght be: {key:?}\");\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "option_env!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "option_env!") :additionalTextEdits []) (:label "writeln!" :kind 3 :detail "macro_rules! writeln" :documentati= on (:kind "markdown" :value "Write formatted data into a buffer, with a = newline appended.\n\nOn all platforms, the newline is the LINE FEED charact= er (`\\n`/`U+000A`) alone\n(no additional CARRIAGE RETURN (`\\r`/`U+000D`).= \n\nFor more information, see [`write!`]. For information on the format str= ing syntax, see\n[`std::fmt`].\n\n[`std::fmt`]: ../std/fmt/index.html\n\n# = Examples\n\n```rust\nuse std::io::{Write, Result};\n\nfn main() -> Result<(= )> {\n let mut w =3D Vec::new();\n writeln!(&mut w)?;\n writeln!(&= mut w, \"test\")?;\n writeln!(&mut w, \"formatted {}\", \"arguments\")?;= \n\n assert_eq!(&w[..], \"\\ntest\\nformatted arguments\\n\".as_bytes())= ;\n Ok(())\n}\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "writeln!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "writeln!") :additionalTextEdits []) (:label "assert_eq!" :kind 3 :detail "macro_rules! assert_eq" :documen= tation (:kind "markdown" :value "Asserts that two expressions are equal to e= ach other (using [`PartialEq`]).\n\nOn panic, this macro will print the val= ues of the expressions with their\ndebug representations.\n\nLike [`assert!= `], this macro has a second form, where a custom\npanic message can be prov= ided.\n\n# Examples\n\n```rust\nlet a =3D 3;\nlet b =3D 1 + 2;\nassert_eq!(= a, b);\n\nassert_eq!(a, b, \"we are testing addition with {} and {}\", a, b= );\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "assert_eq!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "assert_eq!") :additionalTextEdits []) (:label "compile_error!" :kind 3 :detail "macro_rules! compile_error" = :documentation (:kind "markdown" :value "Causes compilation to fail with the given e= rror message when encountered.\n\nThis macro should be used when a crate us= es a conditional compilation strategy to provide\nbetter error messages for= erroneous conditions. It's the compiler-level form of [`panic!`],\nbut emi= ts an error during *compilation* rather than at *runtime*.\n\n# Examples\n\= nTwo such examples are macros and `#[cfg]` environments.\n\nEmit a better c= ompiler error if a macro is passed invalid values. Without the final branch= ,\nthe compiler would still emit an error, but the error's message would no= t mention the two\nvalid values.\n\n```rust\nmacro_rules! give_me_foo_or_ba= r {\n (foo) =3D> {};\n (bar) =3D> {};\n ($x:ident) =3D> {\n = compile_error!(\"This macro only accepts `foo` or `bar`\");\n }\n}\n\ng= ive_me_foo_or_bar!(neither);\n// ^ will fail at compile time with message \= "This macro only accepts `foo` or `bar`\"\n```\n\nEmit a compiler error if = one of a number of features isn't available.\n\n```rust\n#[cfg(not(any(feat= ure =3D \"foo\", feature =3D \"bar\")))]\ncompile_error!(\"Either feature \= \\"foo\\\" or \\\"bar\\\" must be enabled for this crate.\");\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "compile_error!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "compile_error!") :additionalTextEdits []) (:label "matches!" :kind 3 :detail "macro_rules! matches" :documentati= on (:kind "markdown" :value "Returns whether the given expression matche= s the provided pattern.\n\nThe pattern syntax is exactly the same as found = in a match arm. The optional if guard can be\nused to add additional checks= that must be true for the matched value, otherwise this macro will\nreturn= `false`.\n\nWhen testing that a value matches a pattern, it's generally pr= eferable to use\n[`assert_matches!`] as it will print the debug representat= ion of the value if the assertion\nfails.\n\n# Examples\n\n```rust\nlet foo= =3D 'f';\nassert!(matches!(foo, 'A'..=3D'Z' | 'a'..=3D'z'));\n\nlet bar = =3D Some(4);\nassert!(matches!(bar, Some(x) if x > 2));\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "matches!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "matches!") :additionalTextEdits []) (:label "format_args!" :kind 3 :detail "macro_rules! format_args" :doc= umentation (:kind "markdown" :value "Constructs parameters for the other string-= formatting macros.\n\nThis macro functions by taking a formatting string li= teral containing\n`{}` for each additional argument passed. `format_args!` = prepares the\nadditional parameters to ensure the output can be interpreted= as a string\nand canonicalizes the arguments into a single type. Any value= that implements\nthe [`Display`] trait can be passed to `format_args!`, as= can any\n[`Debug`] implementation be passed to a `{:?}` within the formatt= ing string.\n\nThis macro produces a value of type [`fmt::Arguments`]. This= value can be\npassed to the macros within [`std::fmt`] for performing usef= ul redirection.\nAll other formatting macros ([`format!`], [`write!`], [`pr= intln!`], etc) are\nproxied through this one. `format_args!`, unlike its de= rived macros, avoids\nheap allocations.\n\nYou can use the [`fmt::Arguments= `] value that `format_args!` returns\nin `Debug` and `Display` contexts as = seen below. The example also shows\nthat `Debug` and `Display` format to th= e same thing: the interpolated\nformat string in `format_args!`.\n\n```rust= \nlet debug =3D format!(\"{:?}\", format_args!(\"{} foo {:?}\", 1, 2));\nle= t display =3D format!(\"{}\", format_args!(\"{} foo {:?}\", 1, 2));\nassert= _eq!(\"1 foo 2\", display);\nassert_eq!(display, debug);\n```\n\nSee [the f= ormatting documentation in `std::fmt`](../std/fmt/index.html)\nfor details = of the macro argument syntax, and further information.\n\n[`Display`]: crat= e::fmt::Display\n[`Debug`]: crate::fmt::Debug\n[`fmt::Arguments`]: crate::f= mt::Arguments\n[`std::fmt`]: ../std/fmt/index.html\n[`format!`]: ../std/mac= ro.format.html\n[`println!`]: ../std/macro.println.html\n\n# Examples\n\n``= `rust\nuse std::fmt;\n\nlet s =3D fmt::format(format_args!(\"hello {}\", \"= world\"));\nassert_eq!(s, format!(\"hello {}\", \"world\"));\n```\n\n# Life= time limitation\n\nExcept when no formatting arguments are used,\nthe produ= ced `fmt::Arguments` value borrows temporary values,\nwhich means it can on= ly be used within the same expression\nand cannot be stored for later use.\= nThis is a known limitation, see [#92698](https://github.com/rust-lang/rust= /issues/92698).") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "format_args!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "format_args!") :additionalTextEdits []) (:label "is_x86_feature_detected!" :kind 3 :detail "macro_rules! is_x8= 6_feature_detected" :documentation (:kind "markdown" :value "A macro to test at *runtime* whether a CPU = feature is available on\nx86/x86-64 platforms.\n\nThis macro is provided in= the standard library and will detect at runtime\nwhether the specified CPU= feature is detected. This does **not** resolve at\ncompile time unless the= specified feature is already enabled for the entire\ncrate. Runtime detect= ion currently relies mostly on the `cpuid` instruction.\n\nThis macro only = takes one argument which is a string literal of the feature\nbeing tested f= or. The feature names supported are the lowercase versions of\nthe ones def= ined by Intel in [their documentation][docs].\n\n## Supported arguments\n\n= This macro supports the same names that `#[target_feature]` supports. Unlik= e\n`#[target_feature]`, however, this macro does not support names separate= d\nwith a comma. Instead testing for multiple features must be done through= \nseparate macro invocations for now.\n\nSupported arguments are:\n\n* `\"a= es\"`\n* `\"pclmulqdq\"`\n* `\"rdrand\"`\n* `\"rdseed\"`\n* `\"tsc\"`\n* `\= "mmx\"`\n* `\"sse\"`\n* `\"sse2\"`\n* `\"sse3\"`\n* `\"ssse3\"`\n* `\"sse4.= 1\"`\n* `\"sse4.2\"`\n* `\"sse4a\"`\n* `\"sha\"`\n* `\"avx\"`\n* `\"avx2\"`= \n* `\"avx512f\"`\n* `\"avx512cd\"`\n* `\"avx512er\"`\n* `\"avx512pf\"`\n* = `\"avx512bw\"`\n* `\"avx512dq\"`\n* `\"avx512vl\"`\n* `\"avx512ifma\"`\n* `= \"avx512vbmi\"`\n* `\"avx512vpopcntdq\"`\n* `\"avx512vbmi2\"`\n* `\"gfni\"`= \n* `\"vaes\"`\n* `\"vpclmulqdq\"`\n* `\"avx512vnni\"`\n* `\"avx512bitalg\"= `\n* `\"avx512bf16\"`\n* `\"avx512vp2intersect\"`\n* `\"avx512fp16\"`\n* `\= "f16c\"`\n* `\"fma\"`\n* `\"bmi1\"`\n* `\"bmi2\"`\n* `\"abm\"`\n* `\"lzcnt\= "`\n* `\"tbm\"`\n* `\"popcnt\"`\n* `\"fxsr\"`\n* `\"xsave\"`\n* `\"xsaveopt= \"`\n* `\"xsaves\"`\n* `\"xsavec\"`\n* `\"cmpxchg16b\"`\n* `\"adx\"`\n* `\"= rtm\"`\n* `\"movbe\"`\n* `\"ermsb\"`\n\n[docs]: https://software.intel.com/= sites/landingpage/IntrinsicsGuide") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "is_x86_feature_detected!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "is_x86_feature_detected!") :additionalTextEdits []) (:label "eprint!" :kind 3 :detail "macro_rules! eprint" :documentation (:kind "markdown" :value "Prints to the standard error.\n\nEquivalent= to the [`print!`] macro, except that output goes to\n[`io::stderr`] instea= d of [`io::stdout`]. See [`print!`] for\nexample usage.\n\nUse `eprint!` on= ly for error and progress messages. Use `print!`\ninstead for the primary o= utput of your program.\n\n[`io::stderr`]: crate::io::stderr\n[`io::stdout`]= : crate::io::stdout\n\nSee [the formatting documentation in `std::fmt`](../= std/fmt/index.html)\nfor details of the macro argument syntax.\n\n# Panics\= n\nPanics if writing to `io::stderr` fails.\n\nWriting to non-blocking stde= rr can cause an error, which will lead\nthis macro to panic.\n\n# Examples\= n\n```rust\neprint!(\"Error: Could not complete task\");\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "eprint!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "eprint!") :additionalTextEdits []) (:label "debug_assert_ne!" :kind 3 :detail "macro_rules! debug_assert_= ne" :documentation (:kind "markdown" :value "Asserts that two expressions are not equal = to each other.\n\nOn panic, this macro will print the values of the express= ions with their\ndebug representations.\n\nUnlike [`assert_ne!`], `debug_as= sert_ne!` statements are only enabled in non\noptimized builds by default. = An optimized build will not execute\n`debug_assert_ne!` statements unless `= -C debug-assertions` is passed to the\ncompiler. This makes `debug_assert_n= e!` useful for checks that are too\nexpensive to be present in a release bu= ild but may be helpful during\ndevelopment. The result of expanding `debug_= assert_ne!` is always type checked.\n\n# Examples\n\n```rust\nlet a =3D 3;\= nlet b =3D 2;\ndebug_assert_ne!(a, b);\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "debug_assert_ne!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "debug_assert_ne!") :additionalTextEdits []) (:label "std" :kind 9 :documentation (:kind "markdown" :value "# The Rust Standard Library\n\nThe Rust Sta= ndard Library is the foundation of portable Rust software, a\nset of minima= l and battle-tested shared abstractions for the [broader Rust\necosystem][c= rates.io]. It offers core types, like [`Vec`] and\n[`Option`], librar= y-defined [operations on language\nprimitives](#primitives), [standard macr= os](#macros), [I/O] and\n[multithreading], among [many other things][other]= .\n\n`std` is available to all Rust crates by default. Therefore, the\nstan= dard library can be accessed in [`use`] statements through the path\n`std`,= as in [`use std::env`].\n\n# How to read this documentation\n\nIf you alre= ady know the name of what you are looking for, the fastest way to\nfind it = is to use the sea= rch\nbar at the top of the page.\n\nOtherwise, you may want to jump to = one of these useful sections:\n\n* [`std::*` modules](#modules)\n* [Primiti= ve types](#primitives)\n* [Standard macros](#macros)\n* [The Rust Prelude]\= n\nIf this is your first time, the documentation for the standard library i= s\nwritten to be casually perused. Clicking on interesting things should\ng= enerally lead you to interesting places. Still, there are important bits\ny= ou don't want to miss, so read on for a tour of the standard library and\ni= ts documentation!\n\nOnce you are familiar with the contents of the standar= d library you may\nbegin to find the verbosity of the prose distracting. At= this stage in your\ndevelopment you may want to press the `[-]` button nea= r the top of the\npage to collapse it into a more skimmable view.\n\nWhile = you are looking at that `[-]` button also notice the `source`\nlink. Rust's= API documentation comes with the source code and you are\nencouraged to re= ad it. The standard library source is generally high\nquality and a peek be= hind the curtains is often enlightening.\n\n# What is in the standard libra= ry documentation?\n\nFirst of all, The Rust Standard Library is divided int= o a number of focused\nmodules, [all listed further down this page](#module= s). These modules are\nthe bedrock upon which all of Rust is forged, and th= ey have mighty names\nlike [`std::slice`] and [`std::cmp`]. Modules' docume= ntation typically\nincludes an overview of the module along with examples, = and are a smart\nplace to start familiarizing yourself with the library.\n\= nSecond, implicit methods on [primitive types] are documented here. This ca= n\nbe a source of confusion for two reasons:\n\n1. While primitives are imp= lemented by the compiler, the standard library\n implements methods direc= tly on the primitive types (and it is the only\n library that does so), w= hich are [documented in the section on\n primitives](#primitives).\n2. Th= e standard library exports many modules *with the same name as\n primitiv= e types*. These define additional items related to the primitive\n type, = but not the all-important methods.\n\nSo for example there is a [page for t= he primitive type\n`i32`](primitive::i32) that lists all the methods that c= an be called on\n32-bit integers (very useful), and there is a [page for th= e module\n`std::i32`] that documents the constant values [`MIN`] and [`MAX`= ] (rarely\nuseful).\n\nNote the documentation for the primitives [`str`] an= d [`[T]`][prim@slice] (also\ncalled 'slice'). Many method calls on [`String= `] and [`Vec`] are actually\ncalls to methods on [`str`] and [`[T]`][pri= m@slice] respectively, via [deref\ncoercions][deref-coercions].\n\nThird, t= he standard library defines [The Rust Prelude], a small collection\nof item= s - mostly traits - that are imported into every module of every\ncrate. Th= e traits in the prelude are pervasive, making the prelude\ndocumentation a = good entry point to learning about the library.\n\nAnd finally, the standar= d library exports a number of standard macros, and\n[lists them on this pag= e](#macros) (technically, not all of the standard\nmacros are defined by th= e standard library - some are defined by the\ncompiler - but they are docum= ented here the same). Like the prelude, the\nstandard macros are imported b= y default into all crates.\n\n# Contributing changes to the documentation\n= \nCheck out the Rust contribution guidelines [here](\nhttps://rustc-dev-gui= de.rust-lang.org/contributing.html#writing-documentation).\nThe source for = this documentation can be found on\n[GitHub](https://github.com/rust-lang/r= ust).\nTo contribute changes, make sure you read the guidelines first, then= submit\npull-requests for your suggested changes.\n\nContributions are app= reciated! If you see a part of the docs that can be\nimproved, submit a PR,= or chat with us first on [Discord][rust-discord]\n#docs.\n\n# A Tour of Th= e Rust Standard Library\n\nThe rest of this crate documentation is dedicate= d to pointing out notable\nfeatures of The Rust Standard Library.\n\n## Con= tainers and collections\n\nThe [`option`] and [`result`] modules define opt= ional and error-handling\ntypes, [`Option`] and [`Result`]. The [`= iter`] module defines\nRust's iterator trait, [`Iterator`], which works wit= h the [`for`] loop to\naccess collections.\n\nThe standard library exposes = three common ways to deal with contiguous\nregions of memory:\n\n* [`Vec= `] - A heap-allocated *vector* that is resizable at runtime.\n* [`[T; N]`][= prim@array] - An inline *array* with a fixed size at compile time.\n* [`[T]= `][prim@slice] - A dynamically sized *slice* into any other kind of contigu= ous\n storage, whether heap-allocated or not.\n\nSlices can only be handle= d through some kind of *pointer*, and as such come\nin many flavors such as= :\n\n* `&[T]` - *shared slice*\n* `&mut [T]` - *mutable slice*\n* [`Box<[T]= >`][owned slice] - *owned slice*\n\n[`str`], a UTF-8 string slice, is a pri= mitive type, and the standard library\ndefines many methods for it. Rust [`= str`]s are typically accessed as\nimmutable references: `&str`. Use the own= ed [`String`] for building and\nmutating strings.\n\nFor converting to stri= ngs use the [`format!`] macro, and for converting from\nstrings use the [`F= romStr`] trait.\n\nData may be shared by placing it in a reference-counted = box or the [`Rc`]\ntype, and if further contained in a [`Cell`] or [`RefCel= l`], may be mutated\nas well as shared. Likewise, in a concurrent setting i= t is common to pair an\natomically-reference-counted box, [`Arc`], with a [= `Mutex`] to get the same\neffect.\n\nThe [`collections`] module defines map= s, sets, linked lists and other\ntypical collection types, including the co= mmon [`HashMap`].\n\n## Platform abstractions and I/O\n\nBesides basi= c data types, the standard library is largely concerned with\nabstracting o= ver differences in common platforms, most notably Windows and\nUnix derivat= ives.\n\nCommon types of I/O, including [files], [TCP], and [UDP], are defi= ned in\nthe [`io`], [`fs`], and [`net`] modules.\n\nThe [`thread`] module c= ontains Rust's threading abstractions. [`sync`]\ncontains further primitive= shared memory types, including [`atomic`] and\n[`mpsc`], which contains th= e channel types for message passing.\n\n# Use before and after `main()`\n\n= Many parts of the standard library are expected to work before and after `m= ain()`;\nbut this is not guaranteed or ensured by tests. It is recommended = that you write your own tests\nand run them on each platform you wish to su= pport.\nThis means that use of `std` before/after main, especially of featu= res that interact with the\nOS or global state, is exempted from stability = and portability guarantees and instead only\nprovided on a best-effort basi= s. Nevertheless bug reports are appreciated.\n\nOn the other hand `core` an= d `alloc` are most likely to work in such environments with\nthe caveat tha= t any hookable behavior such as panics, oom handling or allocators will als= o\ndepend on the compatibility of the hooks.\n\nSome features may also beha= ve differently outside main, e.g. stdio could become unbuffered,\nsome pani= cs might turn into aborts, backtraces might not get symbolicated or similar= .\n\nNon-exhaustive list of known limitations:\n\n- after-main use of threa= d-locals, which also affects additional features:\n - [`thread::current()`= ]\n - [`thread::scope()`]\n - [`sync::mpsc`]\n- before-main stdio file de= scriptors are not guaranteed to be open on unix platforms\n\n\n[I/O]: io\n[= `MIN`]: i32::MIN\n[`MAX`]: i32::MAX\n[page for the module `std::i32`]: crat= e::i32\n[TCP]: net::TcpStream\n[The Rust Prelude]: prelude\n[UDP]: net::Udp= Socket\n[`Arc`]: sync::Arc\n[owned slice]: boxed\n[`Cell`]: cell::Cell\n[`F= romStr`]: str::FromStr\n[`HashMap`]: collections::HashMap\n[`Mutex`]:= sync::Mutex\n[`Option`]: option::Option\n[`Rc`]: rc::Rc\n[`RefCell`]: c= ell::RefCell\n[`Result`]: result::Result\n[`Vec`]: vec::Vec\n[`ato= mic`]: sync::atomic\n[`for`]: ../book/ch03-05-control-flow.html#looping-thr= ough-a-collection-with-for\n[`str`]: prim@str\n[`mpsc`]: sync::mpsc\n[`std:= :cmp`]: cmp\n[`std::slice`]: mod@slice\n[`use std::env`]: env/index.html\n[= `use`]: ../book/ch07-02-defining-modules-to-control-scope-and-privacy.html\= n[crates.io]: https://crates.io\n[deref-coercions]: ../book/ch15-02-deref.h= tml#implicit-deref-coercions-with-functions-and-methods\n[files]: fs::File\= n[multithreading]: thread\n[other]: #what-is-in-the-standard-library-docume= ntation\n[primitive types]: ../book/ch03-02-data-types.html\n[rust-discord]= : https://discord.gg/rust-lang\n[array]: prim@array\n[slice]: prim@slice") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "std" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "std") :additionalTextEdits []) (:label "core" :kind 9 :documentation (:kind "markdown" :value "# The Rust Core Library\n\nThe Rust Core Li= brary is the dependency-free[^free] foundation of [The\nRust Standard Libra= ry](../std/index.html). It is the portable glue\nbetween the language and i= ts libraries, defining the intrinsic and\nprimitive building blocks of all = Rust code. It links to no\nupstream libraries, no system libraries, and no = libc.\n\n[^free]: Strictly speaking, there are some symbols which are neede= d but\n they aren't always necessary.\n\nThe core library is *minim= al*: it isn't even aware of heap allocation,\nnor does it provide concurren= cy or I/O. These things require\nplatform integration, and this library is = platform-agnostic.\n\n# How to use the core library\n\nPlease note that all= of these details are currently not considered stable.\n\nThis library is b= uilt on the assumption of a few existing symbols:\n\n* `memcpy`, `memmove`,= `memset`, `memcmp`, `bcmp`, `strlen` - These are core memory routines\n w= hich are generated by Rust codegen backends. Additionally, this library can= make explicit\n calls to `strlen`. Their signatures are the same as found= in C, but there are extra\n assumptions about their semantics: For `memcp= y`, `memmove`, `memset`, `memcmp`, and `bcmp`, if\n the `n` parameter is 0= , the function is assumed to not be UB, even if the pointers are NULL or\n = dangling. (Note that making extra assumptions about these functions is com= mon among compilers:\n [clang](https://reviews.llvm.org/D86993) and [GCC](= https://gcc.gnu.org/onlinedocs/gcc/Standards.html#C-Language) do the same.)= \n These functions are often provided by the system libc, but can also be = provided by the\n [compiler-builtins crate](https://crates.io/crates/compi= ler_builtins).\n Note that the library does not guarantee that it will alw= ays make these assumptions, so Rust\n user code directly calling the C fun= ctions should follow the C specification! The advice for\n Rust user code = is to call the functions provided by this library instead (such as\n `ptr:= :copy`).\n\n* Panic handler - This function takes one argument, a `&panic::= PanicInfo`. It is up to consumers of this core\n library to define this pa= nic function; it is only required to never\n return. You should mark your = implementation using `#[panic_handler]`.\n\n* `rust_eh_personality` - is us= ed by the failure mechanisms of the\n compiler. This is often mapped to G= CC's personality function, but crates\n which do not trigger a panic can = be assured that this function is never\n called. The `lang` attribute is = called `eh_personality`.") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "core" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "core") :additionalTextEdits []) (:label "u32" :kind 22 :detail "u32" :deprecated :json-false :preselec= t t :sortText "ffffffef" :filterText "u32" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "u32") :additionalTextEdits []) (:label "bool" :kind 22 :detail "bool" :deprecated :json-false :presel= ect t :sortText "ffffffef" :filterText "bool" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "bool") :additionalTextEdits []) (:label "u8" :kind 22 :detail "u8" :deprecated :json-false :preselect = t :sortText "ffffffef" :filterText "u8" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "u8") :additionalTextEdits []) (:label "isize" :kind 22 :detail "isize" :deprecated :json-false :pres= elect t :sortText "ffffffef" :filterText "isize" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "isize") :additionalTextEdits []) (:label "u16" :kind 22 :detail "u16" :deprecated :json-false :preselec= t t :sortText "ffffffef" :filterText "u16" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "u16") :additionalTextEdits []) (:label "u64" :kind 22 :detail "u64" :deprecated :json-false :preselec= t t :sortText "ffffffef" :filterText "u64" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "u64") :additionalTextEdits []) (:label "u128" :kind 22 :detail "u128" :deprecated :json-false :presel= ect t :sortText "ffffffef" :filterText "u128" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "u128") :additionalTextEdits []) (:label "f32" :kind 22 :detail "f32" :deprecated :json-false :preselec= t t :sortText "ffffffef" :filterText "f32" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "f32") :additionalTextEdits []) (:label "i128" :kind 22 :detail "i128" :deprecated :json-false :presel= ect t :sortText "ffffffef" :filterText "i128" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "i128") :additionalTextEdits []) (:label "i16" :kind 22 :detail "i16" :deprecated :json-false :preselec= t t :sortText "ffffffef" :filterText "i16" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "i16") :additionalTextEdits []) (:label "str" :kind 22 :detail "str" :deprecated :json-false :preselec= t t :sortText "ffffffef" :filterText "str" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "str") :additionalTextEdits []) (:label "i64" :kind 22 :detail "i64" :deprecated :json-false :preselec= t t :sortText "ffffffef" :filterText "i64" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "i64") :additionalTextEdits []) (:label "char" :kind 22 :detail "char" :deprecated :json-false :presel= ect t :sortText "ffffffef" :filterText "char" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "char") :additionalTextEdits []) (:label "f128" :kind 22 :detail "f128" :deprecated :json-false :presel= ect t :sortText "ffffffef" :filterText "f128" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "f128") :additionalTextEdits []) (:label "f64" :kind 22 :detail "f64" :deprecated :json-false :preselec= t t :sortText "ffffffef" :filterText "f64" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "f64") :additionalTextEdits []) (:label "f16" :kind 22 :detail "f16" :deprecated :json-false :preselec= t t :sortText "ffffffef" :filterText "f16" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "f16") :additionalTextEdits []) (:label "i32" :kind 22 :detail "i32" :deprecated :json-false :preselec= t t :sortText "ffffffef" :filterText "i32" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "i32") :additionalTextEdits []) (:label "i8" :kind 22 :detail "i8" :deprecated :json-false :preselect = t :sortText "ffffffef" :filterText "i8" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "i8") :additionalTextEdits []) (:label "usize" :kind 22 :detail "usize" :deprecated :json-false :pres= elect t :sortText "ffffffef" :filterText "usize" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "usize") :additionalTextEdits []) (:label "AsMut" :kind 8 :documentation (:kind "markdown" :value "Used to do a cheap mutable-to-mutable refer= ence conversion.\n\nThis trait is similar to [`AsRef`] but used for convert= ing between mutable\nreferences. If you need to do a costly conversion it i= s better to\nimplement [`From`] with type `&mut T` or write a custom functi= on.\n\n**Note: This trait must not fail**. If the conversion can fail, use = a\ndedicated method which returns an [`Option`] or a [`Result`].\n= \n# Generic Implementations\n\n`AsMut` auto-dereferences if the inner type = is a mutable reference\n(e.g.: `foo.as_mut()` will work the same if `foo` h= as type `&mut Foo` or `&mut &mut Foo`).\n\nNote that due to historic reason= s, the above currently does not hold generally for all\n[mutably dereferenc= eable types], e.g. `foo.as_mut()` will *not* work the same as\n`Box::new(fo= o).as_mut()`. Instead, many smart pointers provide an `as_mut` implementati= on which\nsimply returns a reference to the [pointed-to value] (but do not = perform a cheap\nreference-to-reference conversion for that value). However= , [`AsMut::as_mut`] should not be\nused for the sole purpose of mutable der= eferencing; instead ['`Deref` coercion'] can be used:\n\n[mutably dereferen= ceable types]: core::ops::DerefMut\n[pointed-to value]: core::ops::Deref::T= arget\n['`Deref` coercion']: core::ops::DerefMut#mutable-deref-coercion\n\n= ```rust\nlet mut x =3D Box::new(5i32);\n// Avoid this:\n// let y: &mut i32 = =3D x.as_mut();\n// Better just write:\nlet y: &mut i32 =3D &mut x;\n```\n\= nTypes which implement [`DerefMut`] should consider to add an implementatio= n of `AsMut` as\nfollows:\n\n[`DerefMut`]: core::ops::DerefMut\n\n```rus= t\nimpl AsMut for SomeType\nwhere\n ::Target: A= sMut,\n{\n fn as_mut(&mut self) -> &mut T {\n self.deref_mut()= .as_mut()\n }\n}\n```\n\n# Reflexivity\n\nIdeally, `AsMut` would be refl= exive, i.e. there would be an `impl AsMut for T`\nwith [`as_m= ut`] simply returning its argument unchanged.\nSuch a blanket implementatio= n is currently *not* provided due to technical restrictions of\nRust's type= system (it would be overlapping with another existing blanket implementati= on for\n`&mut T where T: AsMut` which allows `AsMut` to auto-dereference= , see \"Generic\nImplementations\" above).\n\n[`as_mut`]: AsMut::as_mut\n\n= A trivial implementation of `AsMut for T` must be added explicitly for a= particular type `T`\nwhere needed or desired. Note, however, that not all = types from `std` contain such an\nimplementation, and those cannot be added= by external code due to orphan rules.\n\n# Examples\n\nUsing `AsMut` as tr= ait bound for a generic function, we can accept all mutable references that= \ncan be converted to type `&mut T`. Unlike [dereference], which has a sing= le [target type],\nthere can be multiple implementations of `AsMut` for a t= ype. In particular, `Vec` implements\nboth `AsMut>` and `AsMut<[T= ]>`.\n\nIn the following, the example functions `caesar` and `null_terminat= e` provide a generic\ninterface which work with any type that can be conver= ted by cheap mutable-to-mutable conversion\ninto a byte slice (`[u8]`) or b= yte vector (`Vec`), respectively.\n\n[dereference]: core::ops::DerefMut= \n[target type]: core::ops::Deref::Target\n\n```rust\nstruct Document {\n = info: String,\n content: Vec,\n}\n\nimpl AsMut for D= ocument\nwhere\n Vec: AsMut,\n{\n fn as_mut(&mut self) -> &mut= T {\n self.content.as_mut()\n }\n}\n\nfn caesar>(= data: &mut T, key: u8) {\n for byte in data.as_mut() {\n *byte = =3D byte.wrapping_add(key);\n }\n}\n\nfn null_terminate= >>(data: &mut T) {\n // Using a non-generic inner function, which contai= ns most of the\n // functionality, helps to minimize monomorphization ov= erhead.\n fn doit(data: &mut Vec) {\n let len =3D data.len();= \n if len =3D=3D 0 || data[len-1] !=3D 0 {\n data.push(0)= ;\n }\n }\n doit(data.as_mut());\n}\n\nfn main() {\n let mu= t v: Vec =3D vec![1, 2, 3];\n caesar(&mut v, 5);\n assert_eq!(v, = [6, 7, 8]);\n null_terminate(&mut v);\n assert_eq!(v, [6, 7, 8, 0]);\= n let mut doc =3D Document {\n info: String::from(\"Example\"),\n= content: vec![17, 19, 8],\n };\n caesar(&mut doc, 1);\n as= sert_eq!(doc.content, [18, 20, 9]);\n null_terminate(&mut doc);\n ass= ert_eq!(doc.content, [18, 20, 9, 0]);\n}\n```\n\nNote, however, that APIs d= on't need to be generic. In many cases taking a `&mut [u8]` or\n`&mut Vec`, for example, is the better choice (callers need to pass the correct ty= pe then).") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "AsMut" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "AsMut") :additionalTextEdits []) (:label "AsRef" :kind 8 :documentation (:kind "markdown" :value "Used to do a cheap reference-to-reference c= onversion.\n\nThis trait is similar to [`AsMut`] which is used for converti= ng between mutable references.\nIf you need to do a costly conversion it is= better to implement [`From`] with type\n`&T` or write a custom function.\n= \n# Relation to `Borrow`\n\n`AsRef` has the same signature as [`Borrow`], b= ut [`Borrow`] is different in a few aspects:\n\n- Unlike `AsRef`, [`Borrow`= ] has a blanket impl for any `T`, and can be used to accept either\n a ref= erence or a value. (See also note on `AsRef`'s reflexibility below.)\n- [`B= orrow`] also requires that [`Hash`], [`Eq`] and [`Ord`] for a borrowed valu= e are\n equivalent to those of the owned value. For this reason, if you wa= nt to\n borrow only a single field of a struct you can implement `AsRef`, = but not [`Borrow`].\n\n**Note: This trait must not fail**. If the conversio= n can fail, use a\ndedicated method which returns an [`Option`] or a [`R= esult`].\n\n# Generic Implementations\n\n`AsRef` auto-dereferences if= the inner type is a reference or a mutable reference\n(e.g.: `foo.as_ref()= ` will work the same if `foo` has type `&mut Foo` or `&&mut Foo`).\n\nNote = that due to historic reasons, the above currently does not hold generally f= or all\n[dereferenceable types], e.g. `foo.as_ref()` will *not* work the sa= me as\n`Box::new(foo).as_ref()`. Instead, many smart pointers provide an `a= s_ref` implementation which\nsimply returns a reference to the [pointed-to = value] (but do not perform a cheap\nreference-to-reference conversion for t= hat value). However, [`AsRef::as_ref`] should not be\nused for the sole pur= pose of dereferencing; instead ['`Deref` coercion'] can be used:\n\n[derefe= renceable types]: core::ops::Deref\n[pointed-to value]: core::ops::Deref::T= arget\n['`Deref` coercion']: core::ops::Deref#deref-coercion\n\n```rust\nle= t x =3D Box::new(5i32);\n// Avoid this:\n// let y: &i32 =3D x.as_ref();\n//= Better just write:\nlet y: &i32 =3D &x;\n```\n\nTypes which implement [`De= ref`] should consider implementing `AsRef` as follows:\n\n[`Deref`]: cor= e::ops::Deref\n\n```rust\nimpl AsRef for SomeType\nwhere\n T: ?Siz= ed,\n ::Target: AsRef,\n{\n fn as_ref(&self) ->= &T {\n self.deref().as_ref()\n }\n}\n```\n\n# Reflexivity\n\nIde= ally, `AsRef` would be reflexive, i.e. there would be an `impl A= sRef for T`\nwith [`as_ref`] simply returning its argument unchanged.\nS= uch a blanket implementation is currently *not* provided due to technical r= estrictions of\nRust's type system (it would be overlapping with another ex= isting blanket implementation for\n`&T where T: AsRef` which allows `AsR= ef` to auto-dereference, see \"Generic Implementations\"\nabove).\n\n[`as_r= ef`]: AsRef::as_ref\n\nA trivial implementation of `AsRef for T` must be= added explicitly for a particular type `T`\nwhere needed or desired. Note,= however, that not all types from `std` contain such an\nimplementation, an= d those cannot be added by external code due to orphan rules.\n\n# Examples= \n\nBy using trait bounds we can accept arguments of different types as lon= g as they can be\nconverted to the specified type `T`.\n\nFor example: By c= reating a generic function that takes an `AsRef` we express that we\nw= ant to accept all references that can be converted to [`&str`] as an argume= nt.\nSince both [`String`] and [`&str`] implement `AsRef` we can accep= t both as input argument.\n\n[`&str`]: primitive@str\n[`Borrow`]: crate::bo= rrow::Borrow\n[`Eq`]: crate::cmp::Eq\n[`Ord`]: crate::cmp::Ord\n[`String`]:= ../../std/string/struct.String.html\n\n```rust\nfn is_hello>= (s: T) {\n assert_eq!(\"hello\", s.as_ref());\n}\n\nlet s =3D \"hello\";\= nis_hello(s);\n\nlet s =3D \"hello\".to_string();\nis_hello(s);\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "AsRef" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "AsRef") :additionalTextEdits []) (:label "Box" :kind 22 :detail "Box<{unknown}, {unknown}>" :documentat= ion (:kind "markdown" :value "A pointer type that uniquely owns a heap al= location of type `T`.\n\nSee the [module-level documentation](../../std/box= ed/index.html) for more.") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Box" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Box") :additionalTextEdits []) (:label "Clone" :kind 8 :documentation (:kind "markdown" :value "A common trait for the ability to explicitl= y duplicate an object.\n\nDiffers from [`Copy`] in that [`Copy`] is implici= t and an inexpensive bit-wise copy, while\n`Clone` is always explicit and m= ay or may not be expensive. In order to enforce\nthese characteristics, Rus= t does not allow you to reimplement [`Copy`], but you\nmay reimplement `Clo= ne` and run arbitrary code.\n\nSince `Clone` is more general than [`Copy`],= you can automatically make anything\n[`Copy`] be `Clone` as well.\n\n## De= rivable\n\nThis trait can be used with `#[derive]` if all fields are `Clone= `. The `derive`d\nimplementation of [`Clone`] calls [`clone`] on each field= .\n\n[`clone`]: Clone::clone\n\nFor a generic struct, `#[derive]` implement= s `Clone` conditionally by adding bound `Clone` on\ngeneric parameters.\n\n= ```rust\n// `derive` implements Clone for Reading when T is Clone.\n#[de= rive(Clone)]\nstruct Reading {\n frequency: T,\n}\n```\n\n## How can = I implement `Clone`?\n\nTypes that are [`Copy`] should have a trivial imple= mentation of `Clone`. More formally:\nif `T: Copy`, `x: T`, and `y: &T`, th= en `let x =3D y.clone();` is equivalent to `let x =3D *y;`.\nManual impleme= ntations should be careful to uphold this invariant; however, unsafe code\n= must not rely on it to ensure memory safety.\n\nAn example is a generic str= uct holding a function pointer. In this case, the\nimplementation of `Clone= ` cannot be `derive`d, but can be implemented as:\n\n```rust\nstruct Genera= te(fn() -> T);\n\nimpl Copy for Generate {}\n\nimpl Clone for G= enerate {\n fn clone(&self) -> Self {\n *self\n }\n}\n```\n= \nIf we `derive`:\n\n```rust\n#[derive(Copy, Clone)]\nstruct Generate(fn= () -> T);\n```\n\nthe auto-derived implementations will have unnecessary `T= : Copy` and `T: Clone` bounds:\n\n```rust\n\n// Automatically derived\nimpl= Copy for Generate { }\n\n// Automatically derived\nimpl Clone for Generate {\n fn clone(&self) -> Generate {\n = Generate(Clone::clone(&self.0))\n }\n}\n```\n\nThe bounds are unnecessar= y because clearly the function itself should be\ncopy- and cloneable even i= f its return type is not:\n\n```rust\n#[derive(Copy, Clone)]\nstruct Genera= te(fn() -> T);\n\nstruct NotCloneable;\n\nfn generate_not_cloneable() ->= NotCloneable {\n NotCloneable\n}\n\nGenerate(generate_not_cloneable).cl= one(); // error: trait bounds were not satisfied\n// Note: With the manual = implementations the above line will compile.\n```\n\n## Additional implemen= tors\n\nIn addition to the [implementors listed below][impls],\nthe followi= ng types also implement `Clone`:\n\n* Function item types (i.e., the distin= ct types defined for each function)\n* Function pointer types (e.g., `fn() = -> i32`)\n* Closure types, if they capture no value from the environment\n = or if all such captured values implement `Clone` themselves.\n Note that = variables captured by shared reference always implement `Clone`\n (even if= the referent doesn't),\n while variables captured by mutable reference ne= ver implement `Clone`.\n\n[impls]: #implementors") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Clone" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Clone") :additionalTextEdits []) (:label "Copy" :kind 8 :documentation (:kind "markdown" :value "Types whose values can be duplicated simply= by copying bits.\n\nBy default, variable bindings have 'move semantics.' I= n other\nwords:\n\n```rust\n#[derive(Debug)]\nstruct Foo;\n\nlet x =3D Foo;= \n\nlet y =3D x;\n\n// `x` has moved into `y`, and so cannot be used\n\n// = println!(\"{x:?}\"); // error: use of moved value\n```\n\nHowever, if a typ= e implements `Copy`, it instead has 'copy semantics':\n\n```rust\n// We can= derive a `Copy` implementation. `Clone` is also required, as it's\n// a su= pertrait of `Copy`.\n#[derive(Debug, Copy, Clone)]\nstruct Foo;\n\nlet x = =3D Foo;\n\nlet y =3D x;\n\n// `y` is a copy of `x`\n\nprintln!(\"{x:?}\");= // A-OK!\n```\n\nIt's important to note that in these two examples, the on= ly difference is whether you\nare allowed to access `x` after the assignmen= t. Under the hood, both a copy and a move\ncan result in bits being copied = in memory, although this is sometimes optimized away.\n\n## How can I imple= ment `Copy`?\n\nThere are two ways to implement `Copy` on your type. The si= mplest is to use `derive`:\n\n```rust\n#[derive(Copy, Clone)]\nstruct MyStr= uct;\n```\n\nYou can also implement `Copy` and `Clone` manually:\n\n```rust= \nstruct MyStruct;\n\nimpl Copy for MyStruct { }\n\nimpl Clone for MyStruct= {\n fn clone(&self) -> MyStruct {\n *self\n }\n}\n```\n\nTher= e is a small difference between the two: the `derive` strategy will also pl= ace a `Copy`\nbound on type parameters, which isn't always desired.\n\n## W= hat's the difference between `Copy` and `Clone`?\n\nCopies happen implicitl= y, for example as part of an assignment `y =3D x`. The behavior of\n`Copy` = is not overloadable; it is always a simple bit-wise copy.\n\nCloning is an = explicit action, `x.clone()`. The implementation of [`Clone`] can\nprovide = any type-specific behavior necessary to duplicate values safely. For exampl= e,\nthe implementation of [`Clone`] for [`String`] needs to copy the pointe= d-to string\nbuffer in the heap. A simple bitwise copy of [`String`] values= would merely copy the\npointer, leading to a double free down the line. Fo= r this reason, [`String`] is [`Clone`]\nbut not `Copy`.\n\n[`Clone`] is a s= upertrait of `Copy`, so everything which is `Copy` must also implement\n[`C= lone`]. If a type is `Copy` then its [`Clone`] implementation only needs to= return `*self`\n(see the example above).\n\n## When can my type be `Copy`?= \n\nA type can implement `Copy` if all of its components implement `Copy`. = For example, this\nstruct can be `Copy`:\n\n```rust\n#[derive(Copy, Clone)]= \nstruct Point {\n x: i32,\n y: i32,\n}\n```\n\nA struct can be `Copy`,= and [`i32`] is `Copy`, therefore `Point` is eligible to be `Copy`.\nBy con= trast, consider\n\n```rust\nstruct PointList {\n points: Vec,\n}\= n```\n\nThe struct `PointList` cannot implement `Copy`, because [`Vec`] = is not `Copy`. If we\nattempt to derive a `Copy` implementation, we'll get = an error:\n\n```text\nthe trait `Copy` cannot be implemented for this type;= field `points` does not implement `Copy`\n```\n\nShared references (`&T`) = are also `Copy`, so a type can be `Copy`, even when it holds\nshared refere= nces of types `T` that are *not* `Copy`. Consider the following struct,\nwh= ich can implement `Copy`, because it only holds a *shared reference* to our= non-`Copy`\ntype `PointList` from above:\n\n```rust\n#[derive(Copy, Clone)= ]\nstruct PointListWrapper<'a> {\n point_list_ref: &'a PointList,\n}\n``= `\n\n## When *can't* my type be `Copy`?\n\nSome types can't be copied safel= y. For example, copying `&mut T` would create an aliased\nmutable reference= . Copying [`String`] would duplicate responsibility for managing the\n[`Str= ing`]'s buffer, leading to a double free.\n\nGeneralizing the latter case, = any type implementing [`Drop`] can't be `Copy`, because it's\nmanaging some= resource besides its own [`size_of::`] bytes.\n\nIf you try to implemen= t `Copy` on a struct or enum containing non-`Copy` data, you will get\nthe = error [E0204].\n\n[E0204]: ../../error_codes/E0204.html\n\n## When *should*= my type be `Copy`?\n\nGenerally speaking, if your type _can_ implement `Co= py`, it should. Keep in mind, though,\nthat implementing `Copy` is part of = the public API of your type. If the type might become\nnon-`Copy` in the fu= ture, it could be prudent to omit the `Copy` implementation now, to\navoid = a breaking API change.\n\n## Additional implementors\n\nIn addition to the = [implementors listed below][impls],\nthe following types also implement `Co= py`:\n\n* Function item types (i.e., the distinct types defined for each fu= nction)\n* Function pointer types (e.g., `fn() -> i32`)\n* Closure types, i= f they capture no value from the environment\n or if all such captured val= ues implement `Copy` themselves.\n Note that variables captured by shared = reference always implement `Copy`\n (even if the referent doesn't),\n whi= le variables captured by mutable reference never implement `Copy`.\n\n[`Vec= `]: ../../std/vec/struct.Vec.html\n[`String`]: ../../std/string/struct.S= tring.html\n[`size_of::`]: crate::mem::size_of\n[impls]: #implementors") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Copy" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Copy") :additionalTextEdits []) (:label "Default" :kind 8 :documentation (:kind "markdown" :value "A trait for giving a type a useful default = value.\n\nSometimes, you want to fall back to some kind of default value, a= nd\ndon't particularly care what it is. This comes up often with `struct`s\= nthat define a set of options:\n\n```rust\nstruct SomeOptions {\n foo: i= 32,\n bar: f32,\n}\n```\n\nHow can we define some default values? You ca= n use `Default`:\n\n```rust\n#[derive(Default)]\nstruct SomeOptions {\n = foo: i32,\n bar: f32,\n}\n\nfn main() {\n let options: SomeOptions = =3D Default::default();\n}\n```\n\nNow, you get all of the default values. = Rust implements `Default` for various primitives types.\n\nIf you want to o= verride a particular option, but still retain the other defaults:\n\n```rus= t\nfn main() {\n let options =3D SomeOptions { foo: 42, ..Default::defau= lt() };\n}\n```\n\n## Derivable\n\nThis trait can be used with `#[derive]` = if all of the type's fields implement\n`Default`. When `derive`d, it will u= se the default value for each field's type.\n\n### `enum`s\n\nWhen using `#= [derive(Default)]` on an `enum`, you need to choose which unit variant will= be\ndefault. You do this by placing the `#[default]` attribute on the vari= ant.\n\n```rust\n#[derive(Default)]\nenum Kind {\n #[default]\n A,\n = B,\n C,\n}\n```\n\nYou cannot use the `#[default]` attribute on non-u= nit or non-exhaustive variants.\n\nThe `#[default]` attribute was stabilize= d in Rust 1.62.0.\n\n## How can I implement `Default`?\n\nProvide an implem= entation for the `default()` method that returns the value of\nyour type th= at should be the default:\n\n```rust\nenum Kind {\n A,\n B,\n C,\n= }\n\nimpl Default for Kind {\n fn default() -> Self { Kind::A }\n}\n```\= n\n# Examples\n\n```rust\n#[derive(Default)]\nstruct SomeOptions {\n foo= : i32,\n bar: f32,\n}\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Default" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Default") :additionalTextEdits []) (:label "DoubleEndedIterator" :kind 8 :documentation (:kind "markdown" :value "An iterator able to yield elements from bot= h ends.\n\nSomething that implements `DoubleEndedIterator` has one extra ca= pability\nover something that implements [`Iterator`]: the ability to also = take\n`Item`s from the back, as well as the front.\n\nIt is important to no= te that both back and forth work on the same range,\nand do not cross: iter= ation is over when they meet in the middle.\n\nIn a similar fashion to the = [`Iterator`] protocol, once a\n`DoubleEndedIterator` returns [`None`] from = a [`next_back()`], calling it\nagain may or may not ever return [`Some`] ag= ain. [`next()`] and\n[`next_back()`] are interchangeable for this purpose.\= n\n[`next_back()`]: DoubleEndedIterator::next_back\n[`next()`]: Iterator::n= ext\n\n# Examples\n\nBasic usage:\n\n```rust\nlet numbers =3D vec![1, 2, 3,= 4, 5, 6];\n\nlet mut iter =3D numbers.iter();\n\nassert_eq!(Some(&1), iter= .next());\nassert_eq!(Some(&6), iter.next_back());\nassert_eq!(Some(&5), it= er.next_back());\nassert_eq!(Some(&2), iter.next());\nassert_eq!(Some(&3), = iter.next());\nassert_eq!(Some(&4), iter.next());\nassert_eq!(None, iter.ne= xt());\nassert_eq!(None, iter.next_back());\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "DoubleEndedIterator" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "DoubleEndedIterator") :additionalTextEdits []) (:label "Drop" :kind 8 :documentation (:kind "markdown" :value "Custom code within the destructor.\n\nWhen = a value is no longer needed, Rust will run a \"destructor\" on that value.\= nThe most common way that a value is no longer needed is when it goes out o= f\nscope. Destructors may still run in other circumstances, but we're going= to\nfocus on scope for the examples here. To learn about some of those oth= er cases,\nplease see [the reference] section on destructors.\n\n[the refer= ence]: https://doc.rust-lang.org/reference/destructors.html\n\nThis destruc= tor consists of two components:\n- A call to `Drop::drop` for that value, i= f this special `Drop` trait is implemented for its type.\n- The automatical= ly generated \"drop glue\" which recursively calls the destructors\n of = all the fields of this value.\n\nAs Rust automatically calls the destructor= s of all contained fields,\nyou don't have to implement `Drop` in most case= s. But there are some cases where\nit is useful, for example for types whic= h directly manage a resource.\nThat resource may be memory, it may be a fil= e descriptor, it may be a network socket.\nOnce a value of that type is no = longer going to be used, it should \"clean up\" its\nresource by freeing th= e memory or closing the file or socket. This is\nthe job of a destructor, a= nd therefore the job of `Drop::drop`.\n\n## Examples\n\nTo see destructors = in action, let's take a look at the following program:\n\n```rust\nstruct H= asDrop;\n\nimpl Drop for HasDrop {\n fn drop(&mut self) {\n print= ln!(\"Dropping HasDrop!\");\n }\n}\n\nstruct HasTwoDrops {\n one: Has= Drop,\n two: HasDrop,\n}\n\nimpl Drop for HasTwoDrops {\n fn drop(&mu= t self) {\n println!(\"Dropping HasTwoDrops!\");\n }\n}\n\nfn mai= n() {\n let _x =3D HasTwoDrops { one: HasDrop, two: HasDrop };\n prin= tln!(\"Running!\");\n}\n```\n\nRust will first call `Drop::drop` for `_x` a= nd then for both `_x.one` and `_x.two`,\nmeaning that running this will pri= nt\n\n```text\nRunning!\nDropping HasTwoDrops!\nDropping HasDrop!\nDropping= HasDrop!\n```\n\nEven if we remove the implementation of `Drop` for `HasTw= oDrop`, the destructors of its fields are still called.\nThis would result = in\n\n```test\nRunning!\nDropping HasDrop!\nDropping HasDrop!\n```\n\n## Yo= u cannot call `Drop::drop` yourself\n\nBecause `Drop::drop` is used to clea= n up a value, it may be dangerous to use this value after\nthe method has b= een called. As `Drop::drop` does not take ownership of its input,\nRust pre= vents misuse by not allowing you to call `Drop::drop` directly.\n\nIn other= words, if you tried to explicitly call `Drop::drop` in the above example, = you'd get a compiler error.\n\nIf you'd like to explicitly call the destruc= tor of a value, [`mem::drop`] can be used instead.\n\n[`mem::drop`]: drop\n= \n## Drop order\n\nWhich of our two `HasDrop` drops first, though? For stru= cts, it's the same\norder that they're declared: first `one`, then `two`. I= f you'd like to try\nthis yourself, you can modify `HasDrop` above to conta= in some data, like an\ninteger, and then use it in the `println!` inside of= `Drop`. This behavior is\nguaranteed by the language.\n\nUnlike for struct= s, local variables are dropped in reverse order:\n\n```rust\nstruct Foo;\n\= nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"Dropping= Foo!\")\n }\n}\n\nstruct Bar;\n\nimpl Drop for Bar {\n fn drop(&mut = self) {\n println!(\"Dropping Bar!\")\n }\n}\n\nfn main() {\n = let _foo =3D Foo;\n let _bar =3D Bar;\n}\n```\n\nThis will print\n\n```t= ext\nDropping Bar!\nDropping Foo!\n```\n\nPlease see [the reference] for th= e full rules.\n\n[the reference]: https://doc.rust-lang.org/reference/destr= uctors.html\n\n## `Copy` and `Drop` are exclusive\n\nYou cannot implement b= oth [`Copy`] and `Drop` on the same type. Types that\nare `Copy` get implic= itly duplicated by the compiler, making it very\nhard to predict when, and = how often destructors will be executed. As such,\nthese types cannot have d= estructors.\n\n## Drop check\n\nDropping interacts with the borrow checker = in subtle ways: when a type `T` is being implicitly\ndropped as some variab= le of this type goes out of scope, the borrow checker needs to ensure that\= ncalling `T`'s destructor at this moment is safe. In particular, it also ne= eds to be safe to\nrecursively drop all the fields of `T`. For example, it = is crucial that code like the following\nis being rejected:\n\n```rust\nuse= std::cell::Cell;\n\nstruct S<'a>(Cell>>, Box);\nimpl= Drop for S<'_> {\n fn drop(&mut self) {\n if let Some(r) =3D sel= f.0.get() {\n // Print the contents of the `Box` in `r`.\n = println!(\"{}\", r.1);\n }\n }\n}\n\nfn main() {\n // Se= t up two `S` that point to each other.\n let s1 =3D S(Cell::new(None), B= ox::new(42));\n let s2 =3D S(Cell::new(Some(&s1)), Box::new(42));\n s= 1.0.set(Some(&s2));\n // Now they both get dropped. But whichever is the= 2nd one\n // to be dropped will access the `Box` in the first one,\n = // which is a use-after-free!\n}\n```\n\nThe Nomicon discusses the need fo= r [drop check in more detail][drop check].\n\nTo reject such code, the \"dr= op check\" analysis determines which types and lifetimes need to\nstill be = live when `T` gets dropped. The exact details of this analysis are not yet\= nstably guaranteed and **subject to change**. Currently, the analysis works= as follows:\n- If `T` has no drop glue, then trivially nothing is required= to be live. This is the case if\n neither `T` nor any of its (recursive) = fields have a destructor (`impl Drop`). [`PhantomData`]\n and [`ManuallyDr= op`] are considered to never have a destructor, no matter their field type.= \n- If `T` has drop glue, then, for all types `U` that are *owned* by any f= ield of `T`,\n recursively add the types and lifetimes that need to be liv= e when `U` gets dropped. The set of\n owned types is determined by recursi= vely traversing `T`:\n - Recursively descend through `PhantomData`, `Box`,= tuples, and arrays (including arrays of\n length 0).\n - Stop at refer= ence and raw pointer types as well as function pointers and function items;= \n they do not own anything.\n - Stop at non-composite types (type para= meters that remain generic in the current context and\n base types such = as integers and `bool`); these types are owned.\n - When hitting an ADT wi= th `impl Drop`, stop there; this type is owned.\n - When hitting an ADT wi= thout `impl Drop`, recursively descend to its fields. (For an `enum`,\n = consider all fields of all variants.)\n- Furthermore, if `T` implements `Dr= op`, then all generic (lifetime and type) parameters of `T`\n must be live= .\n\nIn the above example, the last clause implies that `'a` must be live w= hen `S<'a>` is dropped,\nand hence the example is rejected. If we remove th= e `impl Drop`, the liveness requirement\ndisappears and the example is acce= pted.\n\nThere exists an unstable way for a type to opt-out of the last cla= use; this is called \"drop\ncheck eyepatch\" or `may_dangle`. For more deta= ils on this nightly-only feature, see the\n[discussion in the Nomicon][nomi= con].\n\n[`ManuallyDrop`]: crate::mem::ManuallyDrop\n[`PhantomData`]: crate= ::marker::PhantomData\n[drop check]: ../../nomicon/dropck.html\n[nomicon]: = ../../nomicon/phantom-data.html#an-exception-the-special-case-of-the-standa= rd-library-and-its-unstable-may_dangle") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Drop" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Drop") :additionalTextEdits []) (:label "Eq (alias =3D=3D, !=3D)" :kind 8 :documentation (:kind "markdown" :value "Trait for comparisons corresponding to [equ= ivalence relations](\nhttps://en.wikipedia.org/wiki/Equivalence_relation).\= n\nThis means, that in addition to `a =3D=3D b` and `a !=3D b` being strict= inverses,\nthe relation must be (for all `a`, `b` and `c`):\n\n- reflexive= : `a =3D=3D a`;\n- symmetric: `a =3D=3D b` implies `b =3D=3D a` (required b= y `PartialEq` as well); and\n- transitive: `a =3D=3D b` and `b =3D=3D c` im= plies `a =3D=3D c` (required by `PartialEq` as well).\n\nThis property cann= ot be checked by the compiler, and therefore `Eq` implies\n[`PartialEq`], a= nd has no extra methods.\n\nViolating this property is a logic error. The b= ehavior resulting from a logic error is not\nspecified, but users of the tr= ait must ensure that such logic errors do *not* result in\nundefined behavi= or. This means that `unsafe` code **must not** rely on the correctness of t= hese\nmethods.\n\nImplement `Eq` in addition to `PartialEq` if it's guarant= eed that\n`PartialEq::eq(a, a)` always returns `true` (reflexivity), in add= ition to\nthe symmetric and transitive properties already required by `Part= ialEq`.\n\n## Derivable\n\nThis trait can be used with `#[derive]`. When `d= erive`d, because `Eq` has\nno extra methods, it is only informing the compi= ler that this is an\nequivalence relation rather than a partial equivalence= relation. Note that\nthe `derive` strategy requires all fields are `Eq`, w= hich isn't\nalways desired.\n\n## How can I implement `Eq`?\n\nIf you canno= t use the `derive` strategy, specify that your type implements\n`Eq`, which= has no methods:\n\n```rust\nenum BookFormat { Paperback, Hardback, Ebook }= \nstruct Book {\n isbn: i32,\n format: BookFormat,\n}\nimpl PartialEq= for Book {\n fn eq(&self, other: &Self) -> bool {\n self.isbn = =3D=3D other.isbn\n }\n}\nimpl Eq for Book {}\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Eq" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Eq") :additionalTextEdits []) (:label "ExactSizeIterator" :kind 8 :documentation (:kind "markdown" :value "An iterator that knows its exact length.\n\= nMany [`Iterator`]s don't know how many times they will iterate, but some d= o.\nIf an iterator knows how many times it can iterate, providing access to= \nthat information can be useful. For example, if you want to iterate\nback= wards, a good start is to know where the end is.\n\nWhen implementing an `E= xactSizeIterator`, you must also implement\n[`Iterator`]. When doing so, th= e implementation of [`Iterator::size_hint`]\n*must* return the exact size o= f the iterator.\n\nThe [`len`] method has a default implementation, so you = usually shouldn't\nimplement it. However, you may be able to provide a more= performant\nimplementation than the default, so overriding it in this case= makes sense.\n\nNote that this trait is a safe trait and as such does *not= * and *cannot*\nguarantee that the returned length is correct. This means t= hat `unsafe`\ncode **must not** rely on the correctness of [`Iterator::size= _hint`]. The\nunstable and unsafe [`TrustedLen`](super::marker::TrustedLen)= trait gives\nthis additional guarantee.\n\n[`len`]: ExactSizeIterator::len= \n\n# When *shouldn't* an adapter be `ExactSizeIterator`?\n\nIf an adapter = makes an iterator *longer*, then it's usually incorrect for\nthat adapter t= o implement `ExactSizeIterator`. The inner exact-sized\niterator might alr= eady be `usize::MAX`-long, and thus the length of the\nlonger adapted itera= tor would no longer be exactly representable in `usize`.\n\nThis is why [`C= hain`](crate::iter::Chain) isn't `ExactSizeIterator`,\neven when `A` = and `B` are both `ExactSizeIterator`.\n\n# Examples\n\nBasic usage:\n\n```r= ust\n// a finite range knows exactly how many times it will iterate\nlet fi= ve =3D 0..5;\n\nassert_eq!(5, five.len());\n```\n\nIn the [module-level doc= s], we implemented an [`Iterator`], `Counter`.\nLet's implement `ExactSizeI= terator` for it as well:\n\n[module-level docs]: crate::iter\n\n```rust\nim= pl ExactSizeIterator for Counter {\n // We can easily calculate the rema= ining number of iterations.\n fn len(&self) -> usize {\n 5 - self= .count\n }\n}\n\n// And now we can use it!\n\nlet mut counter =3D Counte= r::new();\n\nassert_eq!(5, counter.len());\nlet _ =3D counter.next();\nasse= rt_eq!(4, counter.len());\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "ExactSizeIterator" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "ExactSizeIterator") :additionalTextEdits []) (:label "Extend" :kind 8 :documentation (:kind "markdown" :value "Extend a collection with the contents of an= iterator.\n\nIterators produce a series of values, and collections can als= o be thought\nof as a series of values. The `Extend` trait bridges this gap= , allowing you\nto extend a collection by including the contents of that it= erator. When\nextending a collection with an already existing key, that ent= ry is updated\nor, in the case of collections that permit multiple entries = with equal\nkeys, that entry is inserted.\n\n# Examples\n\nBasic usage:\n\n= ```rust\n// You can extend a String with some chars:\nlet mut message =3D S= tring::from(\"The first three letters are: \");\n\nmessage.extend(&['a', 'b= ', 'c']);\n\nassert_eq!(\"abc\", &message[29..32]);\n```\n\nImplementing `E= xtend`:\n\n```rust\n// A sample collection, that's just a wrapper over Vec<= T>\n#[derive(Debug)]\nstruct MyCollection(Vec);\n\n// Let's give it so= me methods so we can create one and add things\n// to it.\nimpl MyCollectio= n {\n fn new() -> MyCollection {\n MyCollection(Vec::new())\n = }\n\n fn add(&mut self, elem: i32) {\n self.0.push(elem);\n }\= n}\n\n// since MyCollection has a list of i32s, we implement Extend for i32= \nimpl Extend for MyCollection {\n\n // This is a bit simpler with = the concrete type signature: we can call\n // extend on anything which c= an be turned into an Iterator which gives\n // us i32s. Because we need = i32s to put into MyCollection.\n fn extend>(= &mut self, iter: T) {\n\n // The implementation is very straightforw= ard: loop through the\n // iterator, and add() each element to ourse= lves.\n for elem in iter {\n self.add(elem);\n }\n= }\n}\n\nlet mut c =3D MyCollection::new();\n\nc.add(5);\nc.add(6);\nc.a= dd(7);\n\n// let's extend our collection with three more numbers\nc.extend(= vec![1, 2, 3]);\n\n// we've added these elements onto the end\nassert_eq!(\= "MyCollection([5, 6, 7, 1, 2, 3])\", format!(\"{c:?}\"));\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Extend" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Extend") :additionalTextEdits []) (:label "Fn" :kind 8 :documentation (:kind "markdown" :value "The version of the call operator that takes= an immutable receiver.\n\nInstances of `Fn` can be called repeatedly witho= ut mutating state.\n\n*This trait (`Fn`) is not to be confused with [functi= on pointers]\n(`fn`).*\n\n`Fn` is implemented automatically by closures whi= ch only take immutable\nreferences to captured variables or don't capture a= nything at all, as well\nas (safe) [function pointers] (with some caveats, = see their documentation\nfor more details). Additionally, for any type `F` = that implements `Fn`, `&F`\nimplements `Fn`, too.\n\nSince both [`FnMut`] a= nd [`FnOnce`] are supertraits of `Fn`, any\ninstance of `Fn` can be used as= a parameter where a [`FnMut`] or [`FnOnce`]\nis expected.\n\nUse `Fn` as a= bound when you want to accept a parameter of function-like\ntype and need = to call it repeatedly and without mutating state (e.g., when\ncalling it co= ncurrently). If you do not need such strict requirements, use\n[`FnMut`] or= [`FnOnce`] as bounds.\n\nSee the [chapter on closures in *The Rust Program= ming Language*][book] for\nsome more information on this topic.\n\nAlso of = note is the special syntax for `Fn` traits (e.g.\n`Fn(usize, bool) -> usize= `). Those interested in the technical details of\nthis can refer to [the re= levant section in the *Rustonomicon*][nomicon].\n\n[book]: ../../book/ch13-= 01-closures.html\n[function pointers]: fn\n[nomicon]: ../../nomicon/hrtb.ht= ml\n\n# Examples\n\n## Calling a closure\n\n```rust\nlet square =3D |x| x *= x;\nassert_eq!(square(5), 25);\n```\n\n## Using a `Fn` parameter\n\n```rus= t\nfn call_with_one(func: F) -> usize\n where F: Fn(usize) -> usize {= \n func(1)\n}\n\nlet double =3D |x| x * 2;\nassert_eq!(call_with_one(dou= ble), 2);\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Fn" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Fn") :additionalTextEdits []) (:label "FnMut" :kind 8 :documentation (:kind "markdown" :value "The version of the call operator that takes= a mutable receiver.\n\nInstances of `FnMut` can be called repeatedly and m= ay mutate state.\n\n`FnMut` is implemented automatically by closures which = take mutable\nreferences to captured variables, as well as all types that i= mplement\n[`Fn`], e.g., (safe) [function pointers] (since `FnMut` is a supe= rtrait of\n[`Fn`]). Additionally, for any type `F` that implements `FnMut`,= `&mut F`\nimplements `FnMut`, too.\n\nSince [`FnOnce`] is a supertrait of = `FnMut`, any instance of `FnMut` can be\nused where a [`FnOnce`] is expecte= d, and since [`Fn`] is a subtrait of\n`FnMut`, any instance of [`Fn`] can b= e used where `FnMut` is expected.\n\nUse `FnMut` as a bound when you want t= o accept a parameter of function-like\ntype and need to call it repeatedly,= while allowing it to mutate state.\nIf you don't want the parameter to mut= ate state, use [`Fn`] as a\nbound; if you don't need to call it repeatedly,= use [`FnOnce`].\n\nSee the [chapter on closures in *The Rust Programming L= anguage*][book] for\nsome more information on this topic.\n\nAlso of note i= s the special syntax for `Fn` traits (e.g.\n`Fn(usize, bool) -> usize`). Th= ose interested in the technical details of\nthis can refer to [the relevant= section in the *Rustonomicon*][nomicon].\n\n[book]: ../../book/ch13-01-clo= sures.html\n[function pointers]: fn\n[nomicon]: ../../nomicon/hrtb.html\n\n= # Examples\n\n## Calling a mutably capturing closure\n\n```rust\nlet mut x = =3D 5;\n{\n let mut square_x =3D || x *=3D x;\n square_x();\n}\nasser= t_eq!(x, 25);\n```\n\n## Using a `FnMut` parameter\n\n```rust\nfn do_twice<= F>(mut func: F)\n where F: FnMut()\n{\n func();\n func();\n}\n\nle= t mut x: usize =3D 1;\n{\n let add_two_to_x =3D || x +=3D 2;\n do_twi= ce(add_two_to_x);\n}\n\nassert_eq!(x, 5);\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "FnMut" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "FnMut") :additionalTextEdits []) (:label "FnOnce" :kind 8 :documentation (:kind "markdown" :value "The version of the call operator that takes= a by-value receiver.\n\nInstances of `FnOnce` can be called, but might not= be callable multiple\ntimes. Because of this, if the only thing known abou= t a type is that it\nimplements `FnOnce`, it can only be called once.\n\n`F= nOnce` is implemented automatically by closures that might consume captured= \nvariables, as well as all types that implement [`FnMut`], e.g., (safe)\n[= function pointers] (since `FnOnce` is a supertrait of [`FnMut`]).\n\nSince = both [`Fn`] and [`FnMut`] are subtraits of `FnOnce`, any instance of\n[`Fn`= ] or [`FnMut`] can be used where a `FnOnce` is expected.\n\nUse `FnOnce` as= a bound when you want to accept a parameter of function-like\ntype and onl= y need to call it once. If you need to call the parameter\nrepeatedly, use = [`FnMut`] as a bound; if you also need it to not mutate\nstate, use [`Fn`].= \n\nSee the [chapter on closures in *The Rust Programming Language*][book] = for\nsome more information on this topic.\n\nAlso of note is the special sy= ntax for `Fn` traits (e.g.\n`Fn(usize, bool) -> usize`). Those interested i= n the technical details of\nthis can refer to [the relevant section in the = *Rustonomicon*][nomicon].\n\n[book]: ../../book/ch13-01-closures.html\n[fun= ction pointers]: fn\n[nomicon]: ../../nomicon/hrtb.html\n\n# Examples\n\n##= Using a `FnOnce` parameter\n\n```rust\nfn consume_with_relish(func: F)\= n where F: FnOnce() -> String\n{\n // `func` consumes its captured va= riables, so it cannot be run more\n // than once.\n println!(\"Consum= ed: {}\", func());\n\n println!(\"Delicious!\");\n\n // Attempting to= invoke `func()` again will throw a `use of moved\n // value` error for = `func`.\n}\n\nlet x =3D String::from(\"x\");\nlet consume_and_return_x =3D = move || x;\nconsume_with_relish(consume_and_return_x);\n\n// `consume_and_r= eturn_x` can no longer be invoked at this point\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "FnOnce" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "FnOnce") :additionalTextEdits []) (:label "From" :kind 8 :documentation (:kind "markdown" :value "Used to do value-to-value conversions while= consuming the input value. It is the reciprocal of\n[`Into`].\n\nOne shoul= d always prefer implementing `From` over [`Into`]\nbecause implementing `Fr= om` automatically provides one with an implementation of [`Into`]\nthanks t= o the blanket implementation in the standard library.\n\nOnly implement [`I= nto`] when targeting a version prior to Rust 1.41 and converting to a type\= noutside the current crate.\n`From` was not able to do these types of conve= rsions in earlier versions because of Rust's\norphaning rules.\nSee [`Into`= ] for more details.\n\nPrefer using [`Into`] over using `From` when specify= ing trait bounds on a generic function.\nThis way, types that directly impl= ement [`Into`] can be used as arguments as well.\n\nThe `From` trait is als= o very useful when performing error handling. When constructing a function\= nthat is capable of failing, the return type will generally be of the form = `Result`.\n`From` simplifies error handling by allowing a function to= return a single error type\nthat encapsulates multiple error types. See th= e \"Examples\" section and [the book][book] for more\ndetails.\n\n**Note: T= his trait must not fail**. The `From` trait is intended for perfect convers= ions.\nIf the conversion can fail or is not perfect, use [`TryFrom`].\n\n# = Generic Implementations\n\n- `From for U` implies [`Into`]` for T`\n-= `From` is reflexive, which means that `From for T` is implemented\n\n# = When to implement `From`\n\nWhile there's no technical restrictions on whic= h conversions can be done using\na `From` implementation, the general expec= tation is that the conversions\nshould typically be restricted as follows:\= n\n* The conversion is *infallible*: if the conversion can fail, use [`TryF= rom`]\n instead; don't provide a `From` impl that panics.\n\n* The convers= ion is *lossless*: semantically, it should not lose or discard\n informati= on. For example, `i32: From` exists, where the original\n value can b= e recovered using `u16: TryFrom`. And `String: From<&str>`\n exists,= where you can get something equivalent to the original value via\n `Deref= `. But `From` cannot be used to convert from `u32` to `u16`, since\n that= cannot succeed in a lossless way. (There's some wiggle room here for\n i= nformation not considered semantically relevant. For example,\n `Box<[T]>= : From>` exists even though it might not preserve capacity,\n like = how two vectors can be equal despite differing capacities.)\n\n* The conver= sion is *value-preserving*: the conceptual kind and meaning of\n the resul= ting value is the same, even though the Rust type and technical\n represen= tation might be different. For example `-1_i8 as u8` is *lossless*,\n sin= ce `as` casting back can recover the original value, but that conversion\n = is *not* available via `From` because `-1` and `255` are different concept= ual\n values (despite being identical bit patterns technically). But\n `= f32: From` *is* available because `1_i16` and `1.0_f32` are conceptual= ly\n the same real number (despite having very different bit patterns tech= nically).\n `String: From` is available because they're both *text*,= but\n `String: From` is *not* available, since `1` (a number) and `\= "1\"`\n (text) are too different. (Converting values to text is instead c= overed\n by the [`Display`](crate::fmt::Display) trait.)\n\n* The conversi= on is *obvious*: it's the only reasonable conversion between\n the two typ= es. Otherwise it's better to have it be a named method or\n constructor, = like how [`str::as_bytes`] is a method and how integers have\n methods lik= e [`u32::from_ne_bytes`], [`u32::from_le_bytes`], and\n [`u32::from_be_byt= es`], none of which are `From` implementations. Whereas\n there's only on= e reasonable way to wrap an [`Ipv6Addr`](crate::net::Ipv6Addr)\n into an [= `IpAddr`](crate::net::IpAddr), thus `IpAddr: From` exists.\n\n# E= xamples\n\n[`String`] implements `From<&str>`:\n\nAn explicit conversion fr= om a `&str` to a String is done as follows:\n\n```rust\nlet string =3D \"he= llo\".to_string();\nlet other_string =3D String::from(\"hello\");\n\nassert= _eq!(string, other_string);\n```\n\nWhile performing error handling it is o= ften useful to implement `From` for your own error type.\nBy converting und= erlying error types to our own custom error type that encapsulates the\nund= erlying error type, we can return a single error type without losing inform= ation on the\nunderlying cause. The '?' operator automatically converts the= underlying error type to our\ncustom error type with `From::from`.\n\n```r= ust\nuse std::fs;\nuse std::io;\nuse std::num;\n\nenum CliError {\n IoEr= ror(io::Error),\n ParseError(num::ParseIntError),\n}\n\nimpl From for CliError {\n fn from(error: io::Error) -> Self {\n CliEr= ror::IoError(error)\n }\n}\n\nimpl From for CliError= {\n fn from(error: num::ParseIntError) -> Self {\n CliError::Par= seError(error)\n }\n}\n\nfn open_and_parse_file(file_name: &str) -> Resu= lt {\n let mut contents =3D fs::read_to_string(&file_name= )?;\n let num: i32 =3D contents.trim().parse()?;\n Ok(num)\n}\n```\n\= n[`String`]: ../../std/string/struct.String.html\n[`from`]: From::from\n[bo= ok]: ../../book/ch09-00-error-handling.html") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "From" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "From") :additionalTextEdits []) (:label "FromIterator" :kind 8 :documentation (:kind "markdown" :value "Conversion from an [`Iterator`].\n\nBy impl= ementing `FromIterator` for a type, you define how it will be\ncreated from= an iterator. This is common for types which describe a\ncollection of some= kind.\n\nIf you want to create a collection from the contents of an iterat= or, the\n[`Iterator::collect()`] method is preferred. However, when you nee= d to\nspecify the container type, [`FromIterator::from_iter()`] can be more= \nreadable than using a turbofish (e.g. `::>()`). See the\n[`Iterato= r::collect()`] documentation for more examples of its use.\n\nSee also: [`I= ntoIterator`].\n\n# Examples\n\nBasic usage:\n\n```rust\nlet five_fives =3D= std::iter::repeat(5).take(5);\n\nlet v =3D Vec::from_iter(five_fives);\n\n= assert_eq!(v, vec![5, 5, 5, 5, 5]);\n```\n\nUsing [`Iterator::collect()`] t= o implicitly use `FromIterator`:\n\n```rust\nlet five_fives =3D std::iter::= repeat(5).take(5);\n\nlet v: Vec =3D five_fives.collect();\n\nassert_e= q!(v, vec![5, 5, 5, 5, 5]);\n```\n\nUsing [`FromIterator::from_iter()`] as = a more readable alternative to\n[`Iterator::collect()`]:\n\n```rust\nuse st= d::collections::VecDeque;\nlet first =3D (0..10).collect::>()= ;\nlet second =3D VecDeque::from_iter(0..10);\n\nassert_eq!(first, second);= \n```\n\nImplementing `FromIterator` for your type:\n\n```rust\n// A sample= collection, that's just a wrapper over Vec\n#[derive(Debug)]\nstruct My= Collection(Vec);\n\n// Let's give it some methods so we can create one= and add things\n// to it.\nimpl MyCollection {\n fn new() -> MyCollecti= on {\n MyCollection(Vec::new())\n }\n\n fn add(&mut self, elem= : i32) {\n self.0.push(elem);\n }\n}\n\n// and we'll implement Fr= omIterator\nimpl FromIterator for MyCollection {\n fn from_iter>(iter: I) -> Self {\n let mut c =3D MyColle= ction::new();\n\n for i in iter {\n c.add(i);\n }\= n\n c\n }\n}\n\n// Now we can make a new iterator...\nlet iter = =3D (0..5).into_iter();\n\n// ... and make a MyCollection out of it\nlet c = =3D MyCollection::from_iter(iter);\n\nassert_eq!(c.0, vec![0, 1, 2, 3, 4]);= \n\n// collect works too!\n\nlet iter =3D (0..5).into_iter();\nlet c: MyCol= lection =3D iter.collect();\n\nassert_eq!(c.0, vec![0, 1, 2, 3, 4]);\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "FromIterator" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "FromIterator") :additionalTextEdits []) (:label "Into" :kind 8 :documentation (:kind "markdown" :value "A value-to-value conversion that consumes t= he input value. The\nopposite of [`From`].\n\nOne should avoid implementing= [`Into`] and implement [`From`] instead.\nImplementing [`From`] automatica= lly provides one with an implementation of [`Into`]\nthanks to the blanket = implementation in the standard library.\n\nPrefer using [`Into`] over [`Fro= m`] when specifying trait bounds on a generic function\nto ensure that type= s that only implement [`Into`] can be used as well.\n\n**Note: This trait m= ust not fail**. If the conversion can fail, use [`TryInto`].\n\n# Generic I= mplementations\n\n- [`From`]` for U` implies `Into for T`\n- [`Into`]= is reflexive, which means that `Into for T` is implemented\n\n# Impleme= nting [`Into`] for conversions to external types in old versions of Rust\n\= nPrior to Rust 1.41, if the destination type was not part of the current cr= ate\nthen you couldn't implement [`From`] directly.\nFor example, take this= code:\n\n```rust\nstruct Wrapper(Vec);\nimpl From> for= Vec {\n fn from(w: Wrapper) -> Vec {\n w.0\n }\n}\n`= ``\nThis will fail to compile in older versions of the language because Rus= t's orphaning rules\nused to be a little bit more strict. To bypass this, y= ou could implement [`Into`] directly:\n\n```rust\nstruct Wrapper(Vec)= ;\nimpl Into> for Wrapper {\n fn into(self) -> Vec {\n = self.0\n }\n}\n```\n\nIt is important to understand that [`Into`] = does not provide a [`From`] implementation\n(as [`From`] does with [`Into`]= ). Therefore, you should always try to implement [`From`]\nand then fall ba= ck to [`Into`] if [`From`] can't be implemented.\n\n# Examples\n\n[`String`= ] implements [`Into`]`<`[`Vec`]`<`[`u8`]`>>`:\n\nIn order to express that w= e want a generic function to take all arguments that can be\nconverted to a= specified type `T`, we can use a trait bound of [`Into`]``.\nFor exampl= e: The function `is_hello` takes all arguments that can be converted into a= \n[`Vec`]`<`[`u8`]`>`.\n\n```rust\nfn is_hello>>(s: T) {\n = let bytes =3D b\"hello\".to_vec();\n assert_eq!(bytes, s.into());\n}\n\= nlet s =3D \"hello\".to_string();\nis_hello(s);\n```\n\n[`String`]: ../../s= td/string/struct.String.html\n[`Vec`]: ../../std/vec/struct.Vec.html") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Into" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Into") :additionalTextEdits []) (:label "IntoIterator" :kind 8 :documentation (:kind "markdown" :value "Conversion into an [`Iterator`].\n\nBy impl= ementing `IntoIterator` for a type, you define how it will be\nconverted to= an iterator. This is common for types which describe a\ncollection of some= kind.\n\nOne benefit of implementing `IntoIterator` is that your type will= [work\nwith Rust's `for` loop syntax](crate::iter#for-loops-and-intoiterat= or).\n\nSee also: [`FromIterator`].\n\n# Examples\n\nBasic usage:\n\n```rus= t\nlet v =3D [1, 2, 3];\nlet mut iter =3D v.into_iter();\n\nassert_eq!(Some= (1), iter.next());\nassert_eq!(Some(2), iter.next());\nassert_eq!(Some(3), = iter.next());\nassert_eq!(None, iter.next());\n```\nImplementing `IntoItera= tor` for your type:\n\n```rust\n// A sample collection, that's just a wrapp= er over Vec\n#[derive(Debug)]\nstruct MyCollection(Vec);\n\n// Let'= s give it some methods so we can create one and add things\n// to it.\nimpl= MyCollection {\n fn new() -> MyCollection {\n MyCollection(Vec::= new())\n }\n\n fn add(&mut self, elem: i32) {\n self.0.push(el= em);\n }\n}\n\n// and we'll implement IntoIterator\nimpl IntoIterator fo= r MyCollection {\n type Item =3D i32;\n type IntoIter =3D std::vec::I= ntoIter;\n\n fn into_iter(self) -> Self::IntoIter {\n = self.0.into_iter()\n }\n}\n\n// Now we can make a new collection...\nle= t mut c =3D MyCollection::new();\n\n// ... add some stuff to it ...\nc.add(= 0);\nc.add(1);\nc.add(2);\n\n// ... and then turn it into an Iterator:\nfor= (i, n) in c.into_iter().enumerate() {\n assert_eq!(i as i32, n);\n}\n``= `\n\nIt is common to use `IntoIterator` as a trait bound. This allows\nthe = input collection type to change, so long as it is still an\niterator. Addit= ional bounds can be specified by restricting on\n`Item`:\n\n```rust\nfn col= lect_as_strings(collection: T) -> Vec\nwhere\n T: IntoIterato= r,\n T::Item: std::fmt::Debug,\n{\n collection\n .into_iter()\= n .map(|item| format!(\"{item:?}\"))\n .collect()\n}\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "IntoIterator" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "IntoIterator") :additionalTextEdits []) (:label "Iterator" :kind 8 :documentation (:kind "markdown" :value "A trait for dealing with iterators.\n\nThis= is the main iterator trait. For more about the concept of iterators\ngener= ally, please see the [module-level documentation]. In particular, you\nmay = want to know how to [implement `Iterator`][impl].\n\n[module-level document= ation]: crate::iter\n[impl]: crate::iter#implementing-iterator") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Iterator" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Iterator") :additionalTextEdits []) (:label "Option" :kind 13 :detail "Option<{unknown}>" :documentation (:kind "markdown" :value "The `Option` type. See [the module level do= cumentation](self) for more.") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Option" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Option") :additionalTextEdits []) (:label "Ord (alias <, >, <=3D, >=3D)" :kind 8 :documentation (:kind "markdown" :value "Trait for types that form a [total order](h= ttps://en.wikipedia.org/wiki/Total_order).\n\nImplementations must be consi= stent with the [`PartialOrd`] implementation, and ensure\n`max`, `min`, and= `clamp` are consistent with `cmp`:\n\n- `partial_cmp(a, b) =3D=3D Some(cmp= (a, b))`.\n- `max(a, b) =3D=3D max_by(a, b, cmp)` (ensured by the default i= mplementation).\n- `min(a, b) =3D=3D min_by(a, b, cmp)` (ensured by the def= ault implementation).\n- For `a.clamp(min, max)`, see the [method docs](#me= thod.clamp)\n (ensured by the default implementation).\n\nIt's easy to acc= identally make `cmp` and `partial_cmp` disagree by\nderiving some of the tr= aits and manually implementing others.\n\nViolating these requirements is a= logic error. The behavior resulting from a logic error is not\nspecified, = but users of the trait must ensure that such logic errors do *not* result i= n\nundefined behavior. This means that `unsafe` code **must not** rely on t= he correctness of these\nmethods.\n\n## Corollaries\n\nFrom the above and t= he requirements of `PartialOrd`, it follows that for\nall `a`, `b` and `c`:= \n\n- exactly one of `a < b`, `a =3D=3D b` or `a > b` is true; and\n- `<` i= s transitive: `a < b` and `b < c` implies `a < c`. The same must hold for b= oth `=3D=3D` and `>`.\n\nMathematically speaking, the `<` operator defines = a strict [weak order]. In\ncases where `=3D=3D` conforms to mathematical eq= uality, it also defines a\nstrict [total order].\n\n[weak order]: https://e= n.wikipedia.org/wiki/Weak_ordering\n[total order]: https://en.wikipedia.org= /wiki/Total_order\n\n## Derivable\n\nThis trait can be used with `#[derive]= `.\n\nWhen `derive`d on structs, it will produce a\n[lexicographic](https:/= /en.wikipedia.org/wiki/Lexicographic_order) ordering\nbased on the top-to-b= ottom declaration order of the struct's members.\n\nWhen `derive`d on enums= , variants are ordered primarily by their discriminants.\nSecondarily, they= are ordered by their fields.\nBy default, the discriminant is smallest for= variants at the top, and\nlargest for variants at the bottom. Here's an ex= ample:\n\n```rust\n#[derive(PartialEq, Eq, PartialOrd, Ord)]\nenum E {\n = Top,\n Bottom,\n}\n\nassert!(E::Top < E::Bottom);\n```\n\nHowever, manu= ally setting the discriminants can override this default\nbehavior:\n\n```r= ust\n#[derive(PartialEq, Eq, PartialOrd, Ord)]\nenum E {\n Top =3D 2,\n = Bottom =3D 1,\n}\n\nassert!(E::Bottom < E::Top);\n```\n\n## Lexicographi= cal comparison\n\nLexicographical comparison is an operation with the follo= wing properties:\n - Two sequences are compared element by element.\n - The= first mismatching element defines which sequence is lexicographically less= or greater than the other.\n - If one sequence is a prefix of another, the= shorter sequence is lexicographically less than the other.\n - If two sequ= ences have equivalent elements and are of the same length, then the sequenc= es are lexicographically equal.\n - An empty sequence is lexicographically = less than any non-empty sequence.\n - Two empty sequences are lexicographic= ally equal.\n\n## How can I implement `Ord`?\n\n`Ord` requires that the typ= e also be [`PartialOrd`] and [`Eq`] (which requires [`PartialEq`]).\n\nThen= you must define an implementation for [`cmp`]. You may find it useful to u= se\n[`cmp`] on your type's fields.\n\nHere's an example where you want to s= ort people by height only, disregarding `id`\nand `name`:\n\n```rust\nuse s= td::cmp::Ordering;\n\n#[derive(Eq)]\nstruct Person {\n id: u32,\n nam= e: String,\n height: u32,\n}\n\nimpl Ord for Person {\n fn cmp(&self,= other: &Self) -> Ordering {\n self.height.cmp(&other.height)\n }= \n}\n\nimpl PartialOrd for Person {\n fn partial_cmp(&self, other: &Self= ) -> Option {\n Some(self.cmp(other))\n }\n}\n\nimpl Pa= rtialEq for Person {\n fn eq(&self, other: &Self) -> bool {\n sel= f.height =3D=3D other.height\n }\n}\n```\n\n[`cmp`]: Ord::cmp") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Ord" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Ord") :additionalTextEdits []) (:label "PartialEq (alias =3D=3D, !=3D)" :kind 8 :documentation (:kind "markdown" :value "Trait for comparisons using the equality op= erator.\n\nImplementing this trait for types provides the `=3D=3D` and `!= =3D` operators for\nthose types.\n\n`x.eq(y)` can also be written `x =3D=3D= y`, and `x.ne(y)` can be written `x !=3D y`.\nWe use the easier-to-read in= fix notation in the remainder of this documentation.\n\nThis trait allows f= or comparisons using the equality operator, for types\nthat do not have a f= ull equivalence relation. For example, in floating point\nnumbers `NaN !=3D= NaN`, so floating point types implement `PartialEq` but not\n[`trait@Eq`].= Formally speaking, when `Rhs =3D=3D Self`, this trait corresponds\nto a [p= artial equivalence relation].\n\n[partial equivalence relation]: https://en= .wikipedia.org/wiki/Partial_equivalence_relation\n\nImplementations must en= sure that `eq` and `ne` are consistent with each other:\n\n- `a !=3D b` if = and only if `!(a =3D=3D b)`.\n\nThe default implementation of `ne` provides= this consistency and is almost\nalways sufficient. It should not be overri= dden without very good reason.\n\nIf [`PartialOrd`] or [`Ord`] are also imp= lemented for `Self` and `Rhs`, their methods must also\nbe consistent with = `PartialEq` (see the documentation of those traits for the exact\nrequireme= nts). It's easy to accidentally make them disagree by deriving some of the = traits and\nmanually implementing others.\n\nThe equality relation `=3D=3D`= must satisfy the following conditions\n(for all `a`, `b`, `c` of type `A`,= `B`, `C`):\n\n- **Symmetry**: if `A: PartialEq` and `B: PartialEq`, = then **`a =3D=3D b`\n implies `b =3D=3D a`**; and\n\n- **Transitivity**: i= f `A: PartialEq` and `B: PartialEq` and `A:\n PartialEq`, then **= `a =3D=3D b` and `b =3D=3D c` implies `a =3D=3D c`**.\n This must also wor= k for longer chains, such as when `A: PartialEq`, `B: PartialEq`,\n = `C: PartialEq`, and `A: PartialEq` all exist.\n\nNote that the `B: Pa= rtialEq` (symmetric) and `A: PartialEq`\n(transitive) impls are not f= orced to exist, but these requirements apply\nwhenever they do exist.\n\nVi= olating these requirements is a logic error. The behavior resulting from a = logic error is not\nspecified, but users of the trait must ensure that such= logic errors do *not* result in\nundefined behavior. This means that `unsa= fe` code **must not** rely on the correctness of these\nmethods.\n\n## Cros= s-crate considerations\n\nUpholding the requirements stated above can becom= e tricky when one crate implements `PartialEq`\nfor a type of another crate= (i.e., to allow comparing one of its own types with a type from the\nstand= ard library). The recommendation is to never implement this trait for a for= eign type. In\nother words, such a crate should do `impl PartialEq for LocalType`, but it should\n*not* do `impl PartialEq for= ForeignType`.\n\nThis avoids the problem of transitive chains that criss-c= ross crate boundaries: for all local\ntypes `T`, you may assume that no oth= er crate will add `impl`s that allow comparing `T =3D=3D U`. In\nother word= s, if other crates add `impl`s that allow building longer transitive chains= `U1 =3D=3D ...\n=3D=3D T =3D=3D V1 =3D=3D ...`, then all the types that ap= pear to the right of `T` must be types that the\ncrate defining `T` already= knows about. This rules out transitive chains where downstream crates\ncan= add new `impl`s that \"stitch together\" comparisons of foreign types in w= ays that violate\ntransitivity.\n\nNot having such foreign `impl`s also avo= ids forward compatibility issues where one crate adding\nmore `PartialEq` i= mplementations can cause build failures in downstream crates.\n\n## Derivab= le\n\nThis trait can be used with `#[derive]`. When `derive`d on structs, t= wo\ninstances are equal if all fields are equal, and not equal if any field= s\nare not equal. When `derive`d on enums, two instances are equal if they\= nare the same variant and all fields are equal.\n\n## How can I implement `= PartialEq`?\n\nAn example implementation for a domain in which two books ar= e considered\nthe same book if their ISBN matches, even if the formats diff= er:\n\n```rust\nenum BookFormat {\n Paperback,\n Hardback,\n Ebook= ,\n}\n\nstruct Book {\n isbn: i32,\n format: BookFormat,\n}\n\nimpl P= artialEq for Book {\n fn eq(&self, other: &Self) -> bool {\n self= .isbn =3D=3D other.isbn\n }\n}\n\nlet b1 =3D Book { isbn: 3, format: Boo= kFormat::Paperback };\nlet b2 =3D Book { isbn: 3, format: BookFormat::Ebook= };\nlet b3 =3D Book { isbn: 10, format: BookFormat::Paperback };\n\nassert= !(b1 =3D=3D b2);\nassert!(b1 !=3D b3);\n```\n\n## How can I compare two dif= ferent types?\n\nThe type you can compare with is controlled by `PartialEq`= 's type parameter.\nFor example, let's tweak our previous code a bit:\n\n``= `rust\n// The derive implements =3D=3D comparison= s\n#[derive(PartialEq)]\nenum BookFormat {\n Paperback,\n Hardback,\n= Ebook,\n}\n\nstruct Book {\n isbn: i32,\n format: BookFormat,\n}\= n\n// Implement =3D=3D comparisons\nimpl PartialEq for Book {\n fn eq(&self, other: &BookFormat) -> bool {\n = self.format =3D=3D *other\n }\n}\n\n// Implement =3D=3D comparisons\nimpl PartialEq for BookFormat {\n fn eq(&self, o= ther: &Book) -> bool {\n *self =3D=3D other.format\n }\n}\n\nlet = b1 =3D Book { isbn: 3, format: BookFormat::Paperback };\n\nassert!(b1 =3D= =3D BookFormat::Paperback);\nassert!(BookFormat::Ebook !=3D b1);\n```\n\nBy= changing `impl PartialEq for Book` to `impl PartialEq for Book= `,\nwe allow `BookFormat`s to be compared with `Book`s.\n\nA comparison lik= e the one above, which ignores some fields of the struct,\ncan be dangerous= . It can easily lead to an unintended violation of the\nrequirements for a = partial equivalence relation. For example, if we kept\nthe above implementa= tion of `PartialEq` for `BookFormat` and added an\nimplementation of = `PartialEq` for `Book` (either via a `#[derive]` or\nvia the manual i= mplementation from the first example) then the result would\nviolate transi= tivity:\n\n```rust\n#[derive(PartialEq)]\nenum BookFormat {\n Paperback,= \n Hardback,\n Ebook,\n}\n\n#[derive(PartialEq)]\nstruct Book {\n = isbn: i32,\n format: BookFormat,\n}\n\nimpl PartialEq for Bo= ok {\n fn eq(&self, other: &BookFormat) -> bool {\n self.format = =3D=3D *other\n }\n}\n\nimpl PartialEq for BookFormat {\n fn eq= (&self, other: &Book) -> bool {\n *self =3D=3D other.format\n }\n= }\n\nfn main() {\n let b1 =3D Book { isbn: 1, format: BookFormat::Paperb= ack };\n let b2 =3D Book { isbn: 2, format: BookFormat::Paperback };\n\n= assert!(b1 =3D=3D BookFormat::Paperback);\n assert!(BookFormat::Pape= rback =3D=3D b2);\n\n // The following should hold by transitivity but d= oesn't.\n assert!(b1 =3D=3D b2); // <-- PANICS\n}\n```\n\n# Examples\n\n= ```rust\nlet x: u32 =3D 0;\nlet y: u32 =3D 1;\n\nassert_eq!(x =3D=3D y, fal= se);\nassert_eq!(x.eq(&y), false);\n```\n\n[`eq`]: PartialEq::eq\n[`ne`]: P= artialEq::ne") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "PartialEq" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "PartialEq") :additionalTextEdits []) (:label "PartialOrd (alias >, <, <=3D, >=3D)" :kind 8 :documentation (:kind "markdown" :value "Trait for types that form a [partial order]= (https://en.wikipedia.org/wiki/Partial_order).\n\nThe `lt`, `le`, `gt`, and= `ge` methods of this trait can be called using\nthe `<`, `<=3D`, `>`, and = `>=3D` operators, respectively.\n\nThe methods of this trait must be consis= tent with each other and with those of [`PartialEq`].\nThe following condit= ions must hold:\n\n1. `a =3D=3D b` if and only if `partial_cmp(a, b) =3D=3D= Some(Equal)`.\n2. `a < b` if and only if `partial_cmp(a, b) =3D=3D Some(Le= ss)`\n3. `a > b` if and only if `partial_cmp(a, b) =3D=3D Some(Greater)`\n4= . `a <=3D b` if and only if `a < b || a =3D=3D b`\n5. `a >=3D b` if and onl= y if `a > b || a =3D=3D b`\n6. `a !=3D b` if and only if `!(a =3D=3D b)`.\n= \nConditions 2=E2=80=935 above are ensured by the default implementation.\n= Condition 6 is already ensured by [`PartialEq`].\n\nIf [`Ord`] is also impl= emented for `Self` and `Rhs`, it must also be consistent with\n`partial_cmp= ` (see the documentation of that trait for the exact requirements). It's\ne= asy to accidentally make them disagree by deriving some of the traits and m= anually\nimplementing others.\n\nThe comparison relations must satisfy the = following conditions\n(for all `a`, `b`, `c` of type `A`, `B`, `C`):\n\n- *= *Transitivity**: if `A: PartialOrd` and `B: PartialOrd` and `A:\n Pa= rtialOrd`, then `a < b` and `b < c` implies `a < c`. The same must hold = for both `=3D=3D` and `>`.\n This must also work for longer chains, such a= s when `A: PartialOrd`, `B: PartialOrd`,\n `C: PartialOrd`, and `= A: PartialOrd` all exist.\n- **Duality**: if `A: PartialOrd` and `B: = PartialOrd`, then `a < b` if and only if `b > a`.\n\nNote that the `B: P= artialOrd` (dual) and `A: PartialOrd`\n(transitive) impls are not for= ced to exist, but these requirements apply\nwhenever they do exist.\n\nViol= ating these requirements is a logic error. The behavior resulting from a lo= gic error is not\nspecified, but users of the trait must ensure that such l= ogic errors do *not* result in\nundefined behavior. This means that `unsafe= ` code **must not** rely on the correctness of these\nmethods.\n\n## Cross-= crate considerations\n\nUpholding the requirements stated above can become = tricky when one crate implements `PartialOrd`\nfor a type of another crate = (i.e., to allow comparing one of its own types with a type from the\nstanda= rd library). The recommendation is to never implement this trait for a fore= ign type. In\nother words, such a crate should do `impl PartialOrd for LocalType`, but it should\n*not* do `impl PartialOrd fo= r ForeignType`.\n\nThis avoids the problem of transitive chains that criss-= cross crate boundaries: for all local\ntypes `T`, you may assume that no ot= her crate will add `impl`s that allow comparing `T < U`. In\nother words, i= f other crates add `impl`s that allow building longer transitive chains `U1= < ...\n< T < V1 < ...`, then all the types that appear to the right of `T`= must be types that the crate\ndefining `T` already knows about. This rules= out transitive chains where downstream crates can\nadd new `impl`s that \"= stitch together\" comparisons of foreign types in ways that violate\ntransi= tivity.\n\nNot having such foreign `impl`s also avoids forward compatibilit= y issues where one crate adding\nmore `PartialOrd` implementations can caus= e build failures in downstream crates.\n\n## Corollaries\n\nThe following c= orollaries follow from the above requirements:\n\n- irreflexivity of `<` an= d `>`: `!(a < a)`, `!(a > a)`\n- transitivity of `>`: if `a > b` and `b > c= ` then `a > c`\n- duality of `partial_cmp`: `partial_cmp(a, b) =3D=3D parti= al_cmp(b, a).map(Ordering::reverse)`\n\n## Strict and non-strict partial or= ders\n\nThe `<` and `>` operators behave according to a *strict* partial or= der.\nHowever, `<=3D` and `>=3D` do **not** behave according to a *non-stri= ct*\npartial order.\nThat is because mathematically, a non-strict partial o= rder would require\nreflexivity, i.e. `a <=3D a` would need to be true for = every `a`. This isn't\nalways the case for types that implement `PartialOrd= `, for example:\n\n```rust\nlet a =3D f64::sqrt(-1.0);\nassert_eq!(a <=3D a= , false);\n```\n\n## Derivable\n\nThis trait can be used with `#[derive]`.\= n\nWhen `derive`d on structs, it will produce a\n[lexicographic](https://en= .wikipedia.org/wiki/Lexicographic_order) ordering\nbased on the top-to-bott= om declaration order of the struct's members.\n\nWhen `derive`d on enums, v= ariants are primarily ordered by their discriminants.\nSecondarily, they ar= e ordered by their fields.\nBy default, the discriminant is smallest for va= riants at the top, and\nlargest for variants at the bottom. Here's an examp= le:\n\n```rust\n#[derive(PartialEq, PartialOrd)]\nenum E {\n Top,\n B= ottom,\n}\n\nassert!(E::Top < E::Bottom);\n```\n\nHowever, manually setting= the discriminants can override this default\nbehavior:\n\n```rust\n#[deriv= e(PartialEq, PartialOrd)]\nenum E {\n Top =3D 2,\n Bottom =3D 1,\n}\n= \nassert!(E::Bottom < E::Top);\n```\n\n## How can I implement `PartialOrd`?= \n\n`PartialOrd` only requires implementation of the [`partial_cmp`] method= , with the others\ngenerated from default implementations.\n\nHowever it re= mains possible to implement the others separately for types which do not ha= ve a\ntotal order. For example, for floating point numbers, `NaN < 0 =3D=3D= false` and `NaN >=3D 0 =3D=3D\nfalse` (cf. IEEE 754-2008 section 5.11).\n\= n`PartialOrd` requires your type to be [`PartialEq`].\n\nIf your type is [`= Ord`], you can implement [`partial_cmp`] by using [`cmp`]:\n\n```rust\nuse = std::cmp::Ordering;\n\n#[derive(Eq)]\nstruct Person {\n id: u32,\n na= me: String,\n height: u32,\n}\n\nimpl PartialOrd for Person {\n fn pa= rtial_cmp(&self, other: &Self) -> Option {\n Some(self.cmp= (other))\n }\n}\n\nimpl Ord for Person {\n fn cmp(&self, other: &Self= ) -> Ordering {\n self.height.cmp(&other.height)\n }\n}\n\nimpl P= artialEq for Person {\n fn eq(&self, other: &Self) -> bool {\n se= lf.height =3D=3D other.height\n }\n}\n```\n\nYou may also find it useful= to use [`partial_cmp`] on your type's fields. Here\nis an example of `Pers= on` types who have a floating-point `height` field that\nis the only field = to be used for sorting:\n\n```rust\nuse std::cmp::Ordering;\n\nstruct Perso= n {\n id: u32,\n name: String,\n height: f64,\n}\n\nimpl PartialOr= d for Person {\n fn partial_cmp(&self, other: &Self) -> Option= {\n self.height.partial_cmp(&other.height)\n }\n}\n\nimpl Partia= lEq for Person {\n fn eq(&self, other: &Self) -> bool {\n self.he= ight =3D=3D other.height\n }\n}\n```\n\n# Examples\n\n```rust\nlet x: u3= 2 =3D 0;\nlet y: u32 =3D 1;\n\nassert_eq!(x < y, true);\nassert_eq!(x.lt(&y= ), true);\n```\n\n[`partial_cmp`]: PartialOrd::partial_cmp\n[`cmp`]: Ord::c= mp") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "PartialOrd" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "PartialOrd") :additionalTextEdits []) (:label "Result" :kind 13 :detail "Result<{unknown}, {unknown}>" :docu= mentation (:kind "markdown" :value "`Result` is a type that represents either s= uccess ([`Ok`]) or failure ([`Err`]).\n\nSee the [module documentation](sel= f) for details.") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Result" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Result") :additionalTextEdits []) (:label "RustcDecodable" :kind 18 :deprecated :json-false :preselect t= :sortText "ffffffef" :filterText "RustcDecodable" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "RustcDecodable") :additionalTextEdits []) (:label "RustcEncodable" :kind 18 :deprecated :json-false :preselect t= :sortText "ffffffef" :filterText "RustcEncodable" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "RustcEncodable") :additionalTextEdits []) (:label "Send" :kind 8 :documentation (:kind "markdown" :value "Types that can be transferred across thread= boundaries.\n\nThis trait is automatically implemented when the compiler d= etermines it's\nappropriate.\n\nAn example of a non-`Send` type is the refe= rence-counting pointer\n[`rc::Rc`][`Rc`]. If two threads attempt to clone [= `Rc`]s that point to the same\nreference-counted value, they might try to u= pdate the reference count at the\nsame time, which is [undefined behavior][= ub] because [`Rc`] doesn't use atomic\noperations. Its cousin [`sync::Arc`]= [arc] does use atomic operations (incurring\nsome overhead) and thus is `Se= nd`.\n\nSee [the Nomicon](../../nomicon/send-and-sync.html) and the [`Sync`= ] trait for more details.\n\n[`Rc`]: ../../std/rc/struct.Rc.html\n[arc]: ..= /../std/sync/struct.Arc.html\n[ub]: ../../reference/behavior-considered-und= efined.html") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Send" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Send") :additionalTextEdits []) (:label "Sized (alias ?)" :kind 8 :documentation (:kind "markdown" :value "Types with a constant size known at compile= time.\n\nAll type parameters have an implicit bound of `Sized`. The specia= l syntax\n`?Sized` can be used to remove this bound if it's not appropriate= .\n\n```rust\nstruct Foo(T);\nstruct Bar(T);\n\n// struct Foo= Use(Foo<[i32]>); // error: Sized is not implemented for [i32]\nstruct BarUs= e(Bar<[i32]>); // OK\n```\n\nThe one exception is the implicit `Self` type = of a trait. A trait does not\nhave an implicit `Sized` bound as this is inc= ompatible with [trait object]s\nwhere, by definition, the trait needs to wo= rk with all possible implementors,\nand thus could be any size.\n\nAlthough= Rust will let you bind `Sized` to a trait, you won't\nbe able to use it to= form a trait object later:\n\n```rust\ntrait Foo { }\ntrait Bar: Sized { }= \n\nstruct Impl;\nimpl Foo for Impl { }\nimpl Bar for Impl { }\n\nlet x: &d= yn Foo =3D &Impl; // OK\n// let y: &dyn Bar =3D &Impl; // error: the tra= it `Bar` cannot\n // be made into an object\n```= \n\n[trait object]: ../../book/ch17-02-trait-objects.html") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Sized" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Sized") :additionalTextEdits []) (:label "String" :kind 22 :detail "String" :documentation (:kind "markdown" :value "A UTF-8=E2=80=93encoded, growable string.\n= \n`String` is the most common string type. It has ownership over the conten= ts\nof the string, stored in a heap-allocated buffer (see [Representation](= #representation)).\nIt is closely related to its borrowed counterpart, the = primitive [`str`].\n\n# Examples\n\nYou can create a `String` from [a liter= al string][`&str`] with [`String::from`]:\n\n[`String::from`]: From::from\n= \n```rust\nlet hello =3D String::from(\"Hello, world!\");\n```\n\nYou can a= ppend a [`char`] to a `String` with the [`push`] method, and\nappend a [`&s= tr`] with the [`push_str`] method:\n\n```rust\nlet mut hello =3D String::fr= om(\"Hello, \");\n\nhello.push('w');\nhello.push_str(\"orld!\");\n```\n\n[`= push`]: String::push\n[`push_str`]: String::push_str\n\nIf you have a vecto= r of UTF-8 bytes, you can create a `String` from it with\nthe [`from_utf8`]= method:\n\n```rust\n// some bytes, in a vector\nlet sparkle_heart =3D vec!= [240, 159, 146, 150];\n\n// We know these bytes are valid, so we'll use `un= wrap()`.\nlet sparkle_heart =3D String::from_utf8(sparkle_heart).unwrap();\= n\nassert_eq!(\"=F0=9F=92=96\", sparkle_heart);\n```\n\n[`from_utf8`]: Stri= ng::from_utf8\n\n# UTF-8\n\n`String`s are always valid UTF-8. If you need a= non-UTF-8 string, consider\n[`OsString`]. It is similar, but without the U= TF-8 constraint. Because UTF-8\nis a variable width encoding, `String`s are= typically smaller than an array of\nthe same `chars`:\n\n```rust\nuse std:= :mem;\n\n// `s` is ASCII which represents each `char` as one byte\nlet s = =3D \"hello\";\nassert_eq!(s.len(), 5);\n\n// A `char` array with the same = contents would be longer because\n// every `char` is four bytes\nlet s =3D = ['h', 'e', 'l', 'l', 'o'];\nlet size: usize =3D s.into_iter().map(|c| mem::= size_of_val(&c)).sum();\nassert_eq!(size, 20);\n\n// However, for non-ASCII= strings, the difference will be smaller\n// and sometimes they are the sam= e\nlet s =3D \"=F0=9F=92=96=F0=9F=92=96=F0=9F=92=96=F0=9F=92=96=F0=9F=92=96= \";\nassert_eq!(s.len(), 20);\n\nlet s =3D ['=F0=9F=92=96', '=F0=9F=92=96',= '=F0=9F=92=96', '=F0=9F=92=96', '=F0=9F=92=96'];\nlet size: usize =3D s.in= to_iter().map(|c| mem::size_of_val(&c)).sum();\nassert_eq!(size, 20);\n```\= n\nThis raises interesting questions as to how `s[i]` should work.\nWhat sh= ould `i` be here? Several options include byte indices and\n`char` indices = but, because of UTF-8 encoding, only byte indices\nwould provide constant t= ime indexing. Getting the `i`th `char`, for\nexample, is available using [`= chars`]:\n\n```rust\nlet s =3D \"hello\";\nlet third_character =3D s.chars(= ).nth(2);\nassert_eq!(third_character, Some('l'));\n\nlet s =3D \"=F0=9F=92= =96=F0=9F=92=96=F0=9F=92=96=F0=9F=92=96=F0=9F=92=96\";\nlet third_character= =3D s.chars().nth(2);\nassert_eq!(third_character, Some('=F0=9F=92=96'));\= n```\n\nNext, what should `s[i]` return? Because indexing returns a referen= ce\nto underlying data it could be `&u8`, `&[u8]`, or something else simila= r.\nSince we're only providing one index, `&u8` makes the most sense but th= at\nmight not be what the user expects and can be explicitly achieved with\= n[`as_bytes()`]:\n\n```rust\n// The first byte is 104 - the byte value of `= 'h'`\nlet s =3D \"hello\";\nassert_eq!(s.as_bytes()[0], 104);\n// or\nasser= t_eq!(s.as_bytes()[0], b'h');\n\n// The first byte is 240 which isn't obvio= usly useful\nlet s =3D \"=F0=9F=92=96=F0=9F=92=96=F0=9F=92=96=F0=9F=92=96= =F0=9F=92=96\";\nassert_eq!(s.as_bytes()[0], 240);\n```\n\nDue to these amb= iguities/restrictions, indexing with a `usize` is simply\nforbidden:\n\n```= rust\nlet s =3D \"hello\";\n\n// The following will not compile!\nprintln!(= \"The first letter of s is {}\", s[0]);\n```\n\nIt is more clear, however, = how `&s[i..j]` should work (that is,\nindexing with a range). It should acc= ept byte indices (to be constant-time)\nand return a `&str` which is UTF-8 = encoded. This is also called \"string slicing\".\nNote this will panic if t= he byte indices provided are not character\nboundaries - see [`is_char_boun= dary`] for more details. See the implementations\nfor [`SliceIndex`] f= or more details on string slicing. For a non-panicking\nversion of string s= licing, see [`get`].\n\n[`OsString`]: ../../std/ffi/struct.OsString.html \"= ffi::OsString\"\n[`SliceIndex`]: core::slice::SliceIndex\n[`as_bytes()= `]: str::as_bytes\n[`get`]: str::get\n[`is_char_boundary`]: str::is_char_bo= undary\n\nThe [`bytes`] and [`chars`] methods return iterators over the byt= es and\ncodepoints of the string, respectively. To iterate over codepoints = along\nwith byte indices, use [`char_indices`].\n\n[`bytes`]: str::bytes\n[= `chars`]: str::chars\n[`char_indices`]: str::char_indices\n\n# Deref\n\n`St= ring` implements [Deref], and so inherits al= l of [`str`]'s\nmethods. In addition, this means that you can pass a `Strin= g` to a\nfunction which takes a [`&str`] by using an ampersand (`&`):\n\n``= `rust\nfn takes_str(s: &str) { }\n\nlet s =3D String::from(\"Hello\");\n\nt= akes_str(&s);\n```\n\nThis will create a [`&str`] from the `String` and pas= s it in. This\nconversion is very inexpensive, and so generally, functions = will accept\n[`&str`]s as arguments unless they need a `String` for some sp= ecific\nreason.\n\nIn certain cases Rust doesn't have enough information to= make this\nconversion, known as [`Deref`] coercion. In the following examp= le a string\nslice [`&'a str`][`&str`] implements the trait `TraitExample`,= and the function\n`example_func` takes anything that implements the trait.= In this case Rust\nwould need to make two implicit conversions, which Rust= doesn't have the\nmeans to do. For that reason, the following example will= not compile.\n\n```rust\ntrait TraitExample {}\n\nimpl<'a> TraitExample fo= r &'a str {}\n\nfn example_func(example_arg: A) {}\n\nlet = example_string =3D String::from(\"example_string\");\nexample_func(&example= _string);\n```\n\nThere are two options that would work instead. The first = would be to\nchange the line `example_func(&example_string);` to\n`example_= func(example_string.as_str());`, using the method [`as_str()`]\nto explicit= ly extract the string slice containing the string. The second\nway changes = `example_func(&example_string);` to\n`example_func(&*example_string);`. In = this case we are dereferencing a\n`String` to a [`str`], then referencing t= he [`str`] back to\n[`&str`]. The second way is more idiomatic, however bot= h work to do the\nconversion explicitly rather than relying on the implicit= conversion.\n\n# Representation\n\nA `String` is made up of three componen= ts: a pointer to some bytes, a\nlength, and a capacity. The pointer points = to the internal buffer which `String`\nuses to store its data. The length i= s the number of bytes currently stored\nin the buffer, and the capacity is = the size of the buffer in bytes. As such,\nthe length will always be less t= han or equal to the capacity.\n\nThis buffer is always stored on the heap.\= n\nYou can look at these with the [`as_ptr`], [`len`], and [`capacity`]\nme= thods:\n\n```rust\nuse std::mem;\n\nlet story =3D String::from(\"Once upon = a time...\");\n\n// Prevent automatically dropping the String's data\nlet m= ut story =3D mem::ManuallyDrop::new(story);\n\nlet ptr =3D story.as_mut_ptr= ();\nlet len =3D story.len();\nlet capacity =3D story.capacity();\n\n// sto= ry has nineteen bytes\nassert_eq!(19, len);\n\n// We can re-build a String = out of ptr, len, and capacity. This is all\n// unsafe because we are respon= sible for making sure the components are\n// valid:\nlet s =3D unsafe { Str= ing::from_raw_parts(ptr, len, capacity) } ;\n\nassert_eq!(String::from(\"On= ce upon a time...\"), s);\n```\n\n[`as_ptr`]: str::as_ptr\n[`len`]: String:= :len\n[`capacity`]: String::capacity\n\nIf a `String` has enough capacity, = adding elements to it will not\nre-allocate. For example, consider this pro= gram:\n\n```rust\nlet mut s =3D String::new();\n\nprintln!(\"{}\", s.capaci= ty());\n\nfor _ in 0..5 {\n s.push_str(\"hello\");\n println!(\"{}\",= s.capacity());\n}\n```\n\nThis will output the following:\n\n```text\n0\n8= \n16\n16\n32\n32\n```\n\nAt first, we have no memory allocated at all, but = as we append to the\nstring, it increases its capacity appropriately. If we= instead use the\n[`with_capacity`] method to allocate the correct capacity= initially:\n\n```rust\nlet mut s =3D String::with_capacity(25);\n\nprintln= !(\"{}\", s.capacity());\n\nfor _ in 0..5 {\n s.push_str(\"hello\");\n = println!(\"{}\", s.capacity());\n}\n```\n\n[`with_capacity`]: String::wit= h_capacity\n\nWe end up with a different output:\n\n```text\n25\n25\n25\n25= \n25\n25\n```\n\nHere, there's no need to allocate more memory inside the l= oop.\n\n[str]: prim@str \"str\"\n[`str`]: prim@str \"str\"\n[`&str`]: prim@= str \"&str\"\n[Deref]: core::ops::Deref \"ops::Deref\"\n[`Deref`]: core::op= s::Deref \"ops::Deref\"\n[`as_str()`]: String::as_str") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "String" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "String") :additionalTextEdits []) (:label "Sync" :kind 8 :documentation (:kind "markdown" :value "Types for which it is safe to share referen= ces between threads.\n\nThis trait is automatically implemented when the co= mpiler determines\nit's appropriate.\n\nThe precise definition is: a type `= T` is [`Sync`] if and only if `&T` is\n[`Send`]. In other words, if there i= s no possibility of\n[undefined behavior][ub] (including data races) when p= assing\n`&T` references between threads.\n\nAs one would expect, primitive = types like [`u8`] and [`f64`]\nare all [`Sync`], and so are simple aggregat= e types containing them,\nlike tuples, structs and enums. More examples of = basic [`Sync`]\ntypes include \"immutable\" types like `&T`, and those with= simple\ninherited mutability, such as [`Box`][box], [`Vec`][vec] and= \nmost other collection types. (Generic parameters need to be [`Sync`]\nfor= their container to be [`Sync`].)\n\nA somewhat surprising consequence of t= he definition is that `&mut T`\nis `Sync` (if `T` is `Sync`) even though it= seems like that might\nprovide unsynchronized mutation. The trick is that = a mutable\nreference behind a shared reference (that is, `& &mut T`)\nbecom= es read-only, as if it were a `& &T`. Hence there is no risk\nof a data rac= e.\n\nA shorter overview of how [`Sync`] and [`Send`] relate to referencing= :\n* `&T` is [`Send`] if and only if `T` is [`Sync`]\n* `&mut T` is [`Send`= ] if and only if `T` is [`Send`]\n* `&T` and `&mut T` are [`Sync`] if and o= nly if `T` is [`Sync`]\n\nTypes that are not `Sync` are those that have \"i= nterior\nmutability\" in a non-thread-safe form, such as [`Cell`][cell]\nan= d [`RefCell`][refcell]. These types allow for mutation of\ntheir contents e= ven through an immutable, shared reference. For\nexample the `set` method o= n [`Cell`][cell] takes `&self`, so it requires\nonly a shared reference = [`&Cell`][cell]. The method performs no\nsynchronization, thus [`Cell`][= cell] cannot be `Sync`.\n\nAnother example of a non-`Sync` type is the refe= rence-counting\npointer [`Rc`][rc]. Given any reference [`&Rc`][rc], you= can clone\na new [`Rc`][rc], modifying the reference counts in a non-at= omic way.\n\nFor cases when one does need thread-safe interior mutability,\= nRust provides [atomic data types], as well as explicit locking via\n[`sync= ::Mutex`][mutex] and [`sync::RwLock`][rwlock]. These types\nensure that any= mutation cannot cause data races, hence the types\nare `Sync`. Likewise, [= `sync::Arc`][arc] provides a thread-safe\nanalogue of [`Rc`][rc].\n\nAny ty= pes with interior mutability must also use the\n[`cell::UnsafeCell`][unsafe= cell] wrapper around the value(s) which\ncan be mutated through a shared re= ference. Failing to doing this is\n[undefined behavior][ub]. For example, [= `transmute`][transmute]-ing\nfrom `&T` to `&mut T` is invalid.\n\nSee [the = Nomicon][nomicon-send-and-sync] for more details about `Sync`.\n\n[box]: ..= /../std/boxed/struct.Box.html\n[vec]: ../../std/vec/struct.Vec.html\n[cell]= : crate::cell::Cell\n[refcell]: crate::cell::RefCell\n[rc]: ../../std/rc/st= ruct.Rc.html\n[arc]: ../../std/sync/struct.Arc.html\n[atomic data types]: c= rate::sync::atomic\n[mutex]: ../../std/sync/struct.Mutex.html\n[rwlock]: ..= /../std/sync/struct.RwLock.html\n[unsafecell]: crate::cell::UnsafeCell\n[ub= ]: ../../reference/behavior-considered-undefined.html\n[transmute]: crate::= mem::transmute\n[nomicon-send-and-sync]: ../../nomicon/send-and-sync.html") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Sync" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Sync") :additionalTextEdits []) (:label "ToOwned" :kind 8 :documentation (:kind "markdown" :value "A generalization of `Clone` to borrowed dat= a.\n\nSome types make it possible to go from borrowed to owned, usually by\= nimplementing the `Clone` trait. But `Clone` works only for going from `&T`= \nto `T`. The `ToOwned` trait generalizes `Clone` to construct owned data\n= from any borrow of a given type.") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "ToOwned" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "ToOwned") :additionalTextEdits []) (:label "ToString" :kind 8 :documentation (:kind "markdown" :value "A trait for converting a value to a `String= `.\n\nThis trait is automatically implemented for any type which implements= the\n[`Display`] trait. As such, `ToString` shouldn't be implemented direc= tly:\n[`Display`] should be implemented instead, and you get the `ToString`= \nimplementation for free.\n\n[`Display`]: fmt::Display") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "ToString" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "ToString") :additionalTextEdits []) (:label "TryFrom" :kind 8 :documentation (:kind "markdown" :value "Simple and safe type conversions that may f= ail in a controlled\nway under some circumstances. It is the reciprocal of = [`TryInto`].\n\nThis is useful when you are doing a type conversion that ma= y\ntrivially succeed but may also need special handling.\nFor example, ther= e is no way to convert an [`i64`] into an [`i32`]\nusing the [`From`] trait= , because an [`i64`] may contain a value\nthat an [`i32`] cannot represent = and so the conversion would lose data.\nThis might be handled by truncating= the [`i64`] to an [`i32`] or by\nsimply returning [`i32::MAX`], or by some= other method. The [`From`]\ntrait is intended for perfect conversions, so= the `TryFrom` trait\ninforms the programmer when a type conversion could g= o bad and lets\nthem decide how to handle it.\n\n# Generic Implementations\= n\n- `TryFrom for U` implies [`TryInto`]` for T`\n- [`try_from`] is r= eflexive, which means that `TryFrom for T`\nis implemented and cannot fa= il -- the associated `Error` type for\ncalling `T::try_from()` on a value o= f type `T` is [`Infallible`].\nWhen the [`!`] type is stabilized [`Infallib= le`] and [`!`] will be\nequivalent.\n\n`TryFrom` can be implemented as f= ollows:\n\n```rust\nstruct GreaterThanZero(i32);\n\nimpl TryFrom for G= reaterThanZero {\n type Error =3D &'static str;\n\n fn try_from(value= : i32) -> Result {\n if value <=3D 0 {\n = Err(\"GreaterThanZero only accepts values greater than zero!\")\n = } else {\n Ok(GreaterThanZero(value))\n }\n }\n}\n```= \n\n# Examples\n\nAs described, [`i32`] implements `TryFrom<`[`i64`]`>`:\n\= n```rust\nlet big_number =3D 1_000_000_000_000i64;\n// Silently truncates `= big_number`, requires detecting\n// and handling the truncation after the f= act.\nlet smaller_number =3D big_number as i32;\nassert_eq!(smaller_number,= -727379968);\n\n// Returns an error because `big_number` is too big to\n//= fit in an `i32`.\nlet try_smaller_number =3D i32::try_from(big_number);\na= ssert!(try_smaller_number.is_err());\n\n// Returns `Ok(3)`.\nlet try_succes= sful_smaller_number =3D i32::try_from(3);\nassert!(try_successful_smaller_n= umber.is_ok());\n```\n\n[`try_from`]: TryFrom::try_from") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "TryFrom" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "TryFrom") :additionalTextEdits []) (:label "TryInto" :kind 8 :documentation (:kind "markdown" :value "An attempted conversion that consumes `self= `, which may or may not be\nexpensive.\n\nLibrary authors should usually no= t directly implement this trait,\nbut should prefer implementing the [`TryF= rom`] trait, which offers\ngreater flexibility and provides an equivalent `= TryInto`\nimplementation for free, thanks to a blanket implementation in th= e\nstandard library. For more information on this, see the\ndocumentation f= or [`Into`].\n\n# Implementing `TryInto`\n\nThis suffers the same restricti= ons and reasoning as implementing\n[`Into`], see there for details.") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "TryInto" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "TryInto") :additionalTextEdits []) (:label "Unpin" :kind 8 :documentation (:kind "markdown" :value "Types that do not require any pinning guara= ntees.\n\nFor information on what \"pinning\" is, see the [`pin` module] do= cumentation.\n\nImplementing the `Unpin` trait for `T` expresses the fact t= hat `T` is pinning-agnostic:\nit shall not expose nor rely on any pinning g= uarantees. This, in turn, means that a\n`Pin`-wrapped pointer to such a typ= e can feature a *fully unrestricted* API.\nIn other words, if `T: Unpin`, a= value of type `T` will *not* be bound by the invariants\nwhich pinning oth= erwise offers, even when \"pinned\" by a [`Pin`] pointing at it.\nWhen= a value of type `T` is pointed at by a [`Pin`], [`Pin`] will not rest= rict access\nto the pointee value like it normally would, thus allowing the= user to do anything that they\nnormally could with a non-[`Pin`]-wrapped `= Ptr` to that value.\n\nThe idea of this trait is to alleviate the reduced e= rgonomics of APIs that require the use\nof [`Pin`] for soundness for some t= ypes, but which also want to be used by other types that\ndon't care about = pinning. The prime example of such an API is [`Future::poll`]. There are ma= ny\n[`Future`] types that don't care about pinning. These futures can imple= ment `Unpin` and\ntherefore get around the pinning related restrictions in = the API, while still allowing the\nsubset of [`Future`]s which *do* require= pinning to be implemented soundly.\n\nFor more discussion on the consequen= ces of [`Unpin`] within the wider scope of the pinning\nsystem, see the [se= ction about `Unpin`] in the [`pin` module].\n\n`Unpin` has no consequence a= t all for non-pinned data. In particular, [`mem::replace`] happily\nmoves `= !Unpin` data, which would be immovable when pinned ([`mem::replace`] works = for any\n`&mut T`, not just when `T: Unpin`).\n\n*However*, you cannot use = [`mem::replace`] on `!Unpin` data which is *pinned* by being wrapped\ninsid= e a [`Pin`] pointing at it. This is because you cannot (safely) use a\= n[`Pin`] to get an `&mut T` to its pointee value, which you would need= to call\n[`mem::replace`], and *that* is what makes this system work.\n\nS= o this, for example, can only be done on types implementing `Unpin`:\n\n```= rust\nuse std::mem;\nuse std::pin::Pin;\n\nlet mut string =3D \"this\".to_s= tring();\nlet mut pinned_string =3D Pin::new(&mut string);\n\n// We need a = mutable reference to call `mem::replace`.\n// We can obtain such a referenc= e by (implicitly) invoking `Pin::deref_mut`,\n// but that is only possible = because `String` implements `Unpin`.\nmem::replace(&mut *pinned_string, \"o= ther\".to_string());\n```\n\nThis trait is automatically implemented for al= most every type. The compiler is free\nto take the conservative stance of m= arking types as [`Unpin`] so long as all of the types that\ncompose its fie= lds are also [`Unpin`]. This is because if a type implements [`Unpin`], the= n it\nis unsound for that type's implementation to rely on pinning-related = guarantees for soundness,\n*even* when viewed through a \"pinning\" pointer= ! It is the responsibility of the implementor of\na type that relies upon p= inning for soundness to ensure that type is *not* marked as [`Unpin`]\nby a= dding [`PhantomPinned`] field. For more details, see the [`pin` module] doc= s.\n\n[`mem::replace`]: crate::mem::replace \"mem replace\"\n[`Future`]: cr= ate::future::Future \"Future\"\n[`Future::poll`]: crate::future::Future::po= ll \"Future poll\"\n[`Pin`]: crate::pin::Pin \"Pin\"\n[`Pin`]: crate::= pin::Pin \"Pin\"\n[`pin` module]: crate::pin \"pin module\"\n[section about= `Unpin`]: crate::pin#unpin \"pin module docs about unpin\"\n[`unsafe`]: ..= /../std/keyword.unsafe.html \"keyword unsafe\"") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Unpin" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Unpin") :additionalTextEdits []) (:label "Vec" :kind 22 :detail "Vec<{unknown}, {unknown}>" :documentat= ion (:kind "markdown" :value "A contiguous growable array type, written a= s `Vec`, short for 'vector'.\n\n# Examples\n\n```rust\nlet mut vec =3D V= ec::new();\nvec.push(1);\nvec.push(2);\n\nassert_eq!(vec.len(), 2);\nassert= _eq!(vec[0], 1);\n\nassert_eq!(vec.pop(), Some(2));\nassert_eq!(vec.len(), = 1);\n\nvec[0] =3D 7;\nassert_eq!(vec[0], 7);\n\nvec.extend([1, 2, 3]);\n\nf= or x in &vec {\n println!(\"{x}\");\n}\nassert_eq!(vec, [7, 1, 2, 3]);\n= ```\n\nThe [`vec!`] macro is provided for convenient initialization:\n\n```= rust\nlet mut vec1 =3D vec![1, 2, 3];\nvec1.push(4);\nlet vec2 =3D Vec::fro= m([1, 2, 3, 4]);\nassert_eq!(vec1, vec2);\n```\n\nIt can also initialize ea= ch element of a `Vec` with a given value.\nThis may be more efficient th= an performing allocation and initialization\nin separate steps, especially = when initializing a vector of zeros:\n\n```rust\nlet vec =3D vec![0; 5];\na= ssert_eq!(vec, [0, 0, 0, 0, 0]);\n\n// The following is equivalent, but pot= entially slower:\nlet mut vec =3D Vec::with_capacity(5);\nvec.resize(5, 0);= \nassert_eq!(vec, [0, 0, 0, 0, 0]);\n```\n\nFor more information, see\n[Cap= acity and Reallocation](#capacity-and-reallocation).\n\nUse a `Vec` as a= n efficient stack:\n\n```rust\nlet mut stack =3D Vec::new();\n\nstack.push(= 1);\nstack.push(2);\nstack.push(3);\n\nwhile let Some(top) =3D stack.pop() = {\n // Prints 3, 2, 1\n println!(\"{top}\");\n}\n```\n\n# Indexing\n\= nThe `Vec` type allows access to values by index, because it implements the= \n[`Index`] trait. An example will be more explicit:\n\n```rust\nlet v =3D = vec![0, 2, 4, 6];\nprintln!(\"{}\", v[1]); // it will display '2'\n```\n\nH= owever be careful: if you try to access an index which isn't in the `Vec`,\= nyour software will panic! You cannot do this:\n\n```rust\nlet v =3D vec![0= , 2, 4, 6];\nprintln!(\"{}\", v[6]); // it will panic!\n```\n\nUse [`get`] = and [`get_mut`] if you want to check whether the index is in\nthe `Vec`.\n\= n# Slicing\n\nA `Vec` can be mutable. On the other hand, slices are read-on= ly objects.\nTo get a [slice][prim@slice], use [`&`]. Example:\n\n```rust\n= fn read_slice(slice: &[usize]) {\n // ...\n}\n\nlet v =3D vec![0, 1];\nr= ead_slice(&v);\n\n// ... and that's all!\n// you can also do it like this:\= nlet u: &[usize] =3D &v;\n// or like this:\nlet u: &[_] =3D &v;\n```\n\nIn = Rust, it's more common to pass slices as arguments rather than vectors\nwhe= n you just want to provide read access. The same goes for [`String`] and\n[= `&str`].\n\n# Capacity and reallocation\n\nThe capacity of a vector is the = amount of space allocated for any future\nelements that will be added onto = the vector. This is not to be confused with\nthe *length* of a vector, whic= h specifies the number of actual elements\nwithin the vector. If a vector's= length exceeds its capacity, its capacity\nwill automatically be increased= , but its elements will have to be\nreallocated.\n\nFor example, a vector w= ith capacity 10 and length 0 would be an empty vector\nwith space for 10 mo= re elements. Pushing 10 or fewer elements onto the\nvector will not change = its capacity or cause reallocation to occur. However,\nif the vector's leng= th is increased to 11, it will have to reallocate, which\ncan be slow. For = this reason, it is recommended to use [`Vec::with_capacity`]\nwhenever poss= ible to specify how big the vector is expected to get.\n\n# Guarantees\n\nD= ue to its incredibly fundamental nature, `Vec` makes a lot of guarantees\na= bout its design. This ensures that it's as low-overhead as possible in\nthe= general case, and can be correctly manipulated in primitive ways\nby unsaf= e code. Note that these guarantees refer to an unqualified `Vec`.\nIf ad= ditional type parameters are added (e.g., to support custom allocators),\no= verriding their defaults may change the behavior.\n\nMost fundamentally, `V= ec` is and always will be a (pointer, capacity, length)\ntriplet. No more, = no less. The order of these fields is completely\nunspecified, and you shou= ld use the appropriate methods to modify these.\nThe pointer will never be = null, so this type is null-pointer-optimized.\n\nHowever, the pointer might= not actually point to allocated memory. In particular,\nif you construct a= `Vec` with capacity 0 via [`Vec::new`], [`vec![]`][`vec!`],\n[`Vec::with_c= apacity(0)`][`Vec::with_capacity`], or by calling [`shrink_to_fit`]\non an = empty Vec, it will not allocate memory. Similarly, if you store zero-sized\= ntypes inside a `Vec`, it will not allocate space for them. *Note that in t= his case\nthe `Vec` might not report a [`capacity`] of 0*. `Vec` will alloc= ate if and only\nif [mem::size_of::\\]\\() * [capacity]\\() > 0. In general, `Vec`'s allocation\ndetails are very subtle --- if you in= tend to allocate memory using a `Vec`\nand use it for something else (eithe= r to pass to unsafe code, or to build your\nown memory-backed collection), = be sure to deallocate this memory by using\n`from_raw_parts` to recover the= `Vec` and then dropping it.\n\nIf a `Vec` *has* allocated memory, then the= memory it points to is on the heap\n(as defined by the allocator Rust is c= onfigured to use by default), and its\npointer points to [`len`] initialize= d, contiguous elements in order (what\nyou would see if you coerced it to a= slice), followed by [capacity] - [len]\nlogically uninitializ= ed, contiguous elements.\n\nA vector containing the elements `'a'` and `'b'= ` with capacity 4 can be\nvisualized as below. The top part is the `Vec` st= ruct, it contains a\npointer to the head of the allocation in the heap, len= gth and capacity.\nThe bottom part is the allocation on the heap, a contigu= ous memory block.\n\n```text\n ptr len capacity\n +-= -------+--------+--------+\n | 0x0123 | 2 | 4 |\n +--= ------+--------+--------+\n |\n v\nHeap +--------+-= -------+--------+--------+\n | 'a' | 'b' | uninit | uninit |\n = +--------+--------+--------+--------+\n```\n\n- **uninit** represents= memory that is not initialized, see [`MaybeUninit`].\n- Note: the ABI is n= ot stable and `Vec` makes no guarantees about its memory\n layout (includi= ng the order of fields).\n\n`Vec` will never perform a \"small optimization= \" where elements are actually\nstored on the stack for two reasons:\n\n* I= t would make it more difficult for unsafe code to correctly manipulate\n a= `Vec`. The contents of a `Vec` wouldn't have a stable address if it were\n= only moved, and it would be more difficult to determine if a `Vec` had\n = actually allocated memory.\n\n* It would penalize the general case, incurr= ing an additional branch\n on every access.\n\n`Vec` will never automatica= lly shrink itself, even if completely empty. This\nensures no unnecessary a= llocations or deallocations occur. Emptying a `Vec`\nand then filling it ba= ck up to the same [`len`] should incur no calls to\nthe allocator. If you w= ish to free up unused memory, use\n[`shrink_to_fit`] or [`shrink_to`].\n\n[= `push`] and [`insert`] will never (re)allocate if the reported capacity is\= nsufficient. [`push`] and [`insert`] *will* (re)allocate if\n[len] = =3D=3D [capacity]. That is, the reported capacity is completely\nacc= urate, and can be relied on. It can even be used to manually free the memor= y\nallocated by a `Vec` if desired. Bulk insertion methods *may* reallocate= , even\nwhen not necessary.\n\n`Vec` does not guarantee any particular grow= th strategy when reallocating\nwhen full, nor when [`reserve`] is called. T= he current strategy is basic\nand it may prove desirable to use a non-const= ant growth factor. Whatever\nstrategy is used will of course guarantee *O*(= 1) amortized [`push`].\n\n`vec![x; n]`, `vec![a, b, c, d]`, and\n[`Vec::wit= h_capacity(n)`][`Vec::with_capacity`], will all produce a `Vec`\nwith at le= ast the requested capacity. If [len] =3D=3D [capacity],\n(as i= s the case for the [`vec!`] macro), then a `Vec` can be converted to\nan= d from a [`Box<[T]>`][owned slice] without reallocating or moving the eleme= nts.\n\n`Vec` will not specifically overwrite any data that is removed from= it,\nbut also won't specifically preserve it. Its uninitialized memory is\= nscratch space that it may use however it wants. It will generally just do\= nwhatever is most efficient or otherwise easy to implement. Do not rely on\= nremoved data to be erased for security purposes. Even if you drop a `Vec`,= its\nbuffer may simply be reused by another allocation. Even if you zero a= `Vec`'s memory\nfirst, that might not actually happen because the optimize= r does not consider\nthis a side-effect that must be preserved. There is on= e case which we will\nnot break, however: using `unsafe` code to write to t= he excess capacity,\nand then increasing the length to match, is always val= id.\n\nCurrently, `Vec` does not guarantee the order in which elements are = dropped.\nThe order has changed in the past and may change again.\n\n[`get`= ]: slice::get\n[`get_mut`]: slice::get_mut\n[`String`]: crate::string::Stri= ng\n[`&str`]: type@str\n[`shrink_to_fit`]: Vec::shrink_to_fit\n[`shrink_to`= ]: Vec::shrink_to\n[capacity]: Vec::capacity\n[`capacity`]: Vec::capacity\n= [mem::size_of::\\]: core::mem::size_of\n[len]: Vec::len\n[`len`]: Vec::l= en\n[`push`]: Vec::push\n[`insert`]: Vec::insert\n[`reserve`]: Vec::reserve= \n[`MaybeUninit`]: core::mem::MaybeUninit\n[owned slice]: Box") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Vec" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Vec") :additionalTextEdits []) (:label "alloc_error_handler" :kind 18 :deprecated :json-false :presel= ect t :sortText "ffffffef" :filterText "alloc_error_handler" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "alloc_error_handler") :additionalTextEdits [])])) [client-request] (id:13) Mon Sep 16 12:52:59 2024: (:jsonrpc "2.0" :id 13 :method "completionItem/resolve" :params (:label #("HashSet (use std::collections::HashSet)" 0 1 (eglot--lsp-item #1)) :kind 22 :detail "HashSet<{unknown}, {unknown}>" :documentation (:kind "markdown" :value "A [hash set] implemented as a `HashMap` where= the value is `()`.\n\nAs with the [`HashMap`] type, a `HashSet` requires t= hat the elements\nimplement the [`Eq`] and [`Hash`] traits. This can freque= ntly be achieved by\nusing `#[derive(PartialEq, Eq, Hash)]`. If you impleme= nt these yourself,\nit is important that the following property holds:\n\n`= ``text\nk1 =3D=3D k2 -> hash(k1) =3D=3D hash(k2)\n```\n\nIn other words, if= two keys are equal, their hashes must be equal.\nViolating this property i= s a logic error.\n\nIt is also a logic error for a key to be modified in su= ch a way that the key's\nhash, as determined by the [`Hash`] trait, or its = equality, as determined by\nthe [`Eq`] trait, changes while it is in the ma= p. This is normally only\npossible through [`Cell`], [`RefCell`], global st= ate, I/O, or unsafe code.\n\nThe behavior resulting from either logic error= is not specified, but will\nbe encapsulated to the `HashSet` that observed= the logic error and not\nresult in undefined behavior. This could include = panics, incorrect results,\naborts, memory leaks, and non-termination.\n\n#= Examples\n\n```rust\nuse std::collections::HashSet;\n// Type inference let= s us omit an explicit type signature (which\n// would be `HashSet` = in this example).\nlet mut books =3D HashSet::new();\n\n// Add some books.\= nbooks.insert(\"A Dance With Dragons\".to_string());\nbooks.insert(\"To Kil= l a Mockingbird\".to_string());\nbooks.insert(\"The Odyssey\".to_string());= \nbooks.insert(\"The Great Gatsby\".to_string());\n\n// Check for a specifi= c one.\nif !books.contains(\"The Winds of Winter\") {\n println!(\"We ha= ve {} books, but The Winds of Winter ain't one.\",\n books.len(= ));\n}\n\n// Remove a book.\nbooks.remove(\"The Odyssey\");\n\n// Iterate o= ver everything.\nfor book in &books {\n println!(\"{book}\");\n}\n```\n\= nThe easiest way to use `HashSet` with a custom type is to derive\n[`Eq`] a= nd [`Hash`]. We must also derive [`PartialEq`],\nwhich is required if [`Eq`= ] is derived.\n\n```rust\nuse std::collections::HashSet;\n#[derive(Hash, Eq= , PartialEq, Debug)]\nstruct Viking {\n name: String,\n power: usize,= \n}\n\nlet mut vikings =3D HashSet::new();\n\nvikings.insert(Viking { name:= \"Einar\".to_string(), power: 9 });\nvikings.insert(Viking { name: \"Einar= \".to_string(), power: 9 });\nvikings.insert(Viking { name: \"Olaf\".to_str= ing(), power: 4 });\nvikings.insert(Viking { name: \"Harald\".to_string(), = power: 8 });\n\n// Use derived implementation to print the vikings.\nfor x = in &vikings {\n println!(\"{x:?}\");\n}\n```\n\nA `HashSet` with a known= list of items can be initialized from an array:\n\n```rust\nuse std::colle= ctions::HashSet;\n\nlet viking_names =3D HashSet::from([\"Einar\", \"Olaf\"= , \"Harald\"]);\n```\n\n[hash set]: crate::collections#use-the-set-variant-= of-any-of-these-maps-when\n[`HashMap`]: crate::collections::HashMap\n[`RefC= ell`]: crate::cell::RefCell\n[`Cell`]: crate::cell::Cell") :deprecated :json-false :sortText "fffffff0" :filterText "HashSet" :tex= tEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "HashSet") :additionalTextEdits [] :data (:position (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 17)) :imports [(:full_import_path "std::collections::HashSet" :imported_name "HashSe= t")] :version 0))) [server-reply] (id:13) Mon Sep 16 12:52:59 2024: (:jsonrpc "2.0" :id 13 :result (:label "HashSet (use std::collections::HashSet)" :kind 22 :detail "Hash= Set<{unknown}, {unknown}>" :documentation (:kind "markdown" :value "A [hash set] implemented as a `HashMap` where= the value is `()`.\n\nAs with the [`HashMap`] type, a `HashSet` requires t= hat the elements\nimplement the [`Eq`] and [`Hash`] traits. This can freque= ntly be achieved by\nusing `#[derive(PartialEq, Eq, Hash)]`. If you impleme= nt these yourself,\nit is important that the following property holds:\n\n`= ``text\nk1 =3D=3D k2 -> hash(k1) =3D=3D hash(k2)\n```\n\nIn other words, if= two keys are equal, their hashes must be equal.\nViolating this property i= s a logic error.\n\nIt is also a logic error for a key to be modified in su= ch a way that the key's\nhash, as determined by the [`Hash`] trait, or its = equality, as determined by\nthe [`Eq`] trait, changes while it is in the ma= p. This is normally only\npossible through [`Cell`], [`RefCell`], global st= ate, I/O, or unsafe code.\n\nThe behavior resulting from either logic error= is not specified, but will\nbe encapsulated to the `HashSet` that observed= the logic error and not\nresult in undefined behavior. This could include = panics, incorrect results,\naborts, memory leaks, and non-termination.\n\n#= Examples\n\n```rust\nuse std::collections::HashSet;\n// Type inference let= s us omit an explicit type signature (which\n// would be `HashSet` = in this example).\nlet mut books =3D HashSet::new();\n\n// Add some books.\= nbooks.insert(\"A Dance With Dragons\".to_string());\nbooks.insert(\"To Kil= l a Mockingbird\".to_string());\nbooks.insert(\"The Odyssey\".to_string());= \nbooks.insert(\"The Great Gatsby\".to_string());\n\n// Check for a specifi= c one.\nif !books.contains(\"The Winds of Winter\") {\n println!(\"We ha= ve {} books, but The Winds of Winter ain't one.\",\n books.len(= ));\n}\n\n// Remove a book.\nbooks.remove(\"The Odyssey\");\n\n// Iterate o= ver everything.\nfor book in &books {\n println!(\"{book}\");\n}\n```\n\= nThe easiest way to use `HashSet` with a custom type is to derive\n[`Eq`] a= nd [`Hash`]. We must also derive [`PartialEq`],\nwhich is required if [`Eq`= ] is derived.\n\n```rust\nuse std::collections::HashSet;\n#[derive(Hash, Eq= , PartialEq, Debug)]\nstruct Viking {\n name: String,\n power: usize,= \n}\n\nlet mut vikings =3D HashSet::new();\n\nvikings.insert(Viking { name:= \"Einar\".to_string(), power: 9 });\nvikings.insert(Viking { name: \"Einar= \".to_string(), power: 9 });\nvikings.insert(Viking { name: \"Olaf\".to_str= ing(), power: 4 });\nvikings.insert(Viking { name: \"Harald\".to_string(), = power: 8 });\n\n// Use derived implementation to print the vikings.\nfor x = in &vikings {\n println!(\"{x:?}\");\n}\n```\n\nA `HashSet` with a known= list of items can be initialized from an array:\n\n```rust\nuse std::colle= ctions::HashSet;\n\nlet viking_names =3D HashSet::from([\"Einar\", \"Olaf\"= , \"Harald\"]);\n```\n\n[hash set]: crate::collections#use-the-set-variant-= of-any-of-these-maps-when\n[`HashMap`]: crate::collections::HashMap\n[`RefC= ell`]: crate::cell::RefCell\n[`Cell`]: crate::cell::Cell") :deprecated :json-false :sortText "fffffff0" :filterText "HashSet" :tex= tEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "HashSet") :additionalTextEdits [(:range (:start (:line 0 :character 0) :end (:line 0 :character 0)) :newText "use std::collections::HashSet;\n\n")])) [client-notification] Mon Sep 16 12:52:59 2024: (:jsonrpc "2.0" :method "textDocument/didChange" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs" :version 5) :contentChanges [(:range (:start (:line 4 :character 17) :end (:line 4 :character 17)) :rangeLength 0 :text " (use std::collections::HashSet)") (:range (:start (:line 4 :character 17) :end (:line 4 :character 49)) :rangeLength 32 :text "") (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :rangeLength 7 :text "") (:range (:start (:line 4 :character 10) :end (:line 4 :character 10)) :rangeLength 0 :text "HashSet") (:range (:start (:line 0 :character 0) :end (:line 0 :character 0)) :rangeLength 0 :text "use std::collections::HashSet;\n\n")])) [client-request] (id:14) Mon Sep 16 12:52:59 2024: (:jsonrpc "2.0" :id 14 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 6 :character 17))) [client-request] (id:15) Mon Sep 16 12:52:59 2024: (:jsonrpc "2.0" :id 15 :method "textDocument/hover" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 6 :character 17))) [client-request] (id:16) Mon Sep 16 12:52:59 2024: (:jsonrpc "2.0" :id 16 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 6 :character 17))) [client-notification] Mon Sep 16 12:52:59 2024: (:jsonrpc "2.0" :method "workspace/didChangeWatchedFiles" :params (:changes [(:uri "file:///home/brennan/test_rust/src/brennan@taipei.1665562%3A172= 6418014" :type 1)])) [server-reply] (id:14) Mon Sep 16 12:52:59 2024: (:jsonrpc "2.0" :id 14 :result (:signatures [(:label "struct S" :parameters [(:label [9 10])] :activeParameter 0)] :activeSignature 0 :activeParameter 0)) [server-reply] (id:16) Mon Sep 16 12:52:59 2024: (:jsonrpc "2.0" :id 16 :result [(:range (:start (:line 0 :character 22) :end (:line 0 :character 29))) (:range (:start (:line 6 :character 10) :end (:line 6 :character 17)))]) [server-reply] (id:15) Mon Sep 16 12:52:59 2024: (:jsonrpc "2.0" :id 15 :result (:contents (:kind "plaintext" :value "std::collections::hash::set\n\npub struct Ha= shSet {\n base: {unknown},\n}\n\n\nA [hash set] im= plemented as a HashMap where the value is ().\n\nAs with the [HashMap] type= , a HashSet requires that the elements implement the Eq and Hash traits. Th= is can frequently be achieved by using #[derive(PartialEq, Eq, Hash)]. If y= ou implement these yourself, it is important that the following property ho= lds:\n\nk1 =3D=3D k2 -> hash(k1) =3D=3D hash(k2)\n\nIn other words, if two = keys are equal, their hashes must be equal. Violating this property is a lo= gic error.\n\nIt is also a logic error for a key to be modified in such a w= ay that the key's hash, as determined by the Hash trait, or its equality, a= s determined by the Eq trait, changes while it is in the map. This is norma= lly only possible through [Cell], [RefCell], global state, I/O, or unsafe c= ode.\n\nThe behavior resulting from either logic error is not specified, bu= t will be encapsulated to the HashSet that observed the logic error and not= result in undefined behavior. This could include panics, incorrect results= , aborts, memory leaks, and non-termination.\n\nExamplesuse std::collection= s::HashSet;\n// Type inference lets us omit an explicit type signature (whi= ch\n// would be `HashSet` in this example).\nlet mut books =3D Hash= Set::new();\n\n// Add some books.\nbooks.insert(\"A Dance With Dragons\".to= _string());\nbooks.insert(\"To Kill a Mockingbird\".to_string());\nbooks.in= sert(\"The Odyssey\".to_string());\nbooks.insert(\"The Great Gatsby\".to_st= ring());\n\n// Check for a specific one.\nif !books.contains(\"The Winds of= Winter\") {\n println!(\"We have {} books, but The Winds of Winter ain'= t one.\",\n books.len());\n}\n\n// Remove a book.\nbooks.remove= (\"The Odyssey\");\n\n// Iterate over everything.\nfor book in &books {\n = println!(\"{book}\");\n}\n\nThe easiest way to use HashSet with a custom = type is to derive Eq and Hash. We must also derive PartialEq, which is requ= ired if Eq is derived.\n\nuse std::collections::HashSet;\n#[derive(Hash, Eq= , PartialEq, Debug)]\nstruct Viking {\n name: String,\n power: usize,= \n}\n\nlet mut vikings =3D HashSet::new();\n\nvikings.insert(Viking { name:= \"Einar\".to_string(), power: 9 });\nvikings.insert(Viking { name: \"Einar= \".to_string(), power: 9 });\nvikings.insert(Viking { name: \"Olaf\".to_str= ing(), power: 4 });\nvikings.insert(Viking { name: \"Harald\".to_string(), = power: 8 });\n\n// Use derived implementation to print the vikings.\nfor x = in &vikings {\n println!(\"{x:?}\");\n}\n\nA HashSet with a known list o= f items can be initialized from an array:\n\nuse std::collections::HashSet;= \n\nlet viking_names =3D HashSet::from([\"Einar\", \"Olaf\", \"Harald\"]);") :range (:start (:line 6 :character 10) :end (:line 6 :character 17)))) [client-request] (id:17) Mon Sep 16 12:52:59 2024: (:jsonrpc "2.0" :id 17 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 6 :character 17))) [client-request] (id:18) Mon Sep 16 12:52:59 2024: (:jsonrpc "2.0" :id 18 :method "textDocument/hover" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 6 :character 17))) [client-request] (id:19) Mon Sep 16 12:52:59 2024: (:jsonrpc "2.0" :id 19 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 6 :character 17))) [client-request] (id:20) Mon Sep 16 12:52:59 2024: (:jsonrpc "2.0" :id 20 :method "textDocument/inlayHint" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :range (:start (:line 0 :character 0) :end (:line 10 :character 0)))) [server-reply] (id:17) Mon Sep 16 12:52:59 2024: (:jsonrpc "2.0" :id 17 :result (:signatures [(:label "struct S" :parameters [(:label [9 10])] :activeParameter 0)] :activeSignature 0 :activeParameter 0)) [server-reply] (id:18) Mon Sep 16 12:52:59 2024: (:jsonrpc "2.0" :id 18 :result (:contents (:kind "plaintext" :value "std::collections::hash::set\n\npub struct Ha= shSet {\n base: {unknown},\n}\n\n\nA [hash set] im= plemented as a HashMap where the value is ().\n\nAs with the [HashMap] type= , a HashSet requires that the elements implement the Eq and Hash traits. Th= is can frequently be achieved by using #[derive(PartialEq, Eq, Hash)]. If y= ou implement these yourself, it is important that the following property ho= lds:\n\nk1 =3D=3D k2 -> hash(k1) =3D=3D hash(k2)\n\nIn other words, if two = keys are equal, their hashes must be equal. Violating this property is a lo= gic error.\n\nIt is also a logic error for a key to be modified in such a w= ay that the key's hash, as determined by the Hash trait, or its equality, a= s determined by the Eq trait, changes while it is in the map. This is norma= lly only possible through [Cell], [RefCell], global state, I/O, or unsafe c= ode.\n\nThe behavior resulting from either logic error is not specified, bu= t will be encapsulated to the HashSet that observed the logic error and not= result in undefined behavior. This could include panics, incorrect results= , aborts, memory leaks, and non-termination.\n\nExamplesuse std::collection= s::HashSet;\n// Type inference lets us omit an explicit type signature (whi= ch\n// would be `HashSet` in this example).\nlet mut books =3D Hash= Set::new();\n\n// Add some books.\nbooks.insert(\"A Dance With Dragons\".to= _string());\nbooks.insert(\"To Kill a Mockingbird\".to_string());\nbooks.in= sert(\"The Odyssey\".to_string());\nbooks.insert(\"The Great Gatsby\".to_st= ring());\n\n// Check for a specific one.\nif !books.contains(\"The Winds of= Winter\") {\n println!(\"We have {} books, but The Winds of Winter ain'= t one.\",\n books.len());\n}\n\n// Remove a book.\nbooks.remove= (\"The Odyssey\");\n\n// Iterate over everything.\nfor book in &books {\n = println!(\"{book}\");\n}\n\nThe easiest way to use HashSet with a custom = type is to derive Eq and Hash. We must also derive PartialEq, which is requ= ired if Eq is derived.\n\nuse std::collections::HashSet;\n#[derive(Hash, Eq= , PartialEq, Debug)]\nstruct Viking {\n name: String,\n power: usize,= \n}\n\nlet mut vikings =3D HashSet::new();\n\nvikings.insert(Viking { name:= \"Einar\".to_string(), power: 9 });\nvikings.insert(Viking { name: \"Einar= \".to_string(), power: 9 });\nvikings.insert(Viking { name: \"Olaf\".to_str= ing(), power: 4 });\nvikings.insert(Viking { name: \"Harald\".to_string(), = power: 8 });\n\n// Use derived implementation to print the vikings.\nfor x = in &vikings {\n println!(\"{x:?}\");\n}\n\nA HashSet with a known list o= f items can be initialized from an array:\n\nuse std::collections::HashSet;= \n\nlet viking_names =3D HashSet::from([\"Einar\", \"Olaf\", \"Harald\"]);") :range (:start (:line 6 :character 10) :end (:line 6 :character 17)))) [server-reply] (id:19) Mon Sep 16 12:52:59 2024: (:jsonrpc "2.0" :id 19 :result [(:range (:start (:line 0 :character 22) :end (:line 0 :character 29))) (:range (:start (:line 6 :character 10) :end (:line 6 :character 17)))]) [server-reply] (id:20) Mon Sep 16 12:52:59 2024: (:jsonrpc "2.0" :id 20 :result []) [client-request] (id:21) Mon Sep 16 12:53:02 2024: (:jsonrpc "2.0" :id 21 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 6 :character 17))) [client-request] (id:22) Mon Sep 16 12:53:02 2024: (:jsonrpc "2.0" :id 22 :method "textDocument/hover" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 6 :character 17))) [client-request] (id:23) Mon Sep 16 12:53:02 2024: (:jsonrpc "2.0" :id 23 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 6 :character 17))) [server-reply] (id:21) Mon Sep 16 12:53:02 2024: (:jsonrpc "2.0" :id 21 :result (:signatures [(:label "struct S" :parameters [(:label [9 10])] :activeParameter 0)] :activeSignature 0 :activeParameter 0)) [server-reply] (id:23) Mon Sep 16 12:53:02 2024: (:jsonrpc "2.0" :id 23 :result [(:range (:start (:line 0 :character 22) :end (:line 0 :character 29))) (:range (:start (:line 6 :character 10) :end (:line 6 :character 17)))]) [server-reply] (id:22) Mon Sep 16 12:53:02 2024: (:jsonrpc "2.0" :id 22 :result (:contents (:kind "plaintext" :value "std::collections::hash::set\n\npub struct Ha= shSet {\n base: {unknown},\n}\n\n\nA [hash set] im= plemented as a HashMap where the value is ().\n\nAs with the [HashMap] type= , a HashSet requires that the elements implement the Eq and Hash traits. Th= is can frequently be achieved by using #[derive(PartialEq, Eq, Hash)]. If y= ou implement these yourself, it is important that the following property ho= lds:\n\nk1 =3D=3D k2 -> hash(k1) =3D=3D hash(k2)\n\nIn other words, if two = keys are equal, their hashes must be equal. Violating this property is a lo= gic error.\n\nIt is also a logic error for a key to be modified in such a w= ay that the key's hash, as determined by the Hash trait, or its equality, a= s determined by the Eq trait, changes while it is in the map. This is norma= lly only possible through [Cell], [RefCell], global state, I/O, or unsafe c= ode.\n\nThe behavior resulting from either logic error is not specified, bu= t will be encapsulated to the HashSet that observed the logic error and not= result in undefined behavior. This could include panics, incorrect results= , aborts, memory leaks, and non-termination.\n\nExamplesuse std::collection= s::HashSet;\n// Type inference lets us omit an explicit type signature (whi= ch\n// would be `HashSet` in this example).\nlet mut books =3D Hash= Set::new();\n\n// Add some books.\nbooks.insert(\"A Dance With Dragons\".to= _string());\nbooks.insert(\"To Kill a Mockingbird\".to_string());\nbooks.in= sert(\"The Odyssey\".to_string());\nbooks.insert(\"The Great Gatsby\".to_st= ring());\n\n// Check for a specific one.\nif !books.contains(\"The Winds of= Winter\") {\n println!(\"We have {} books, but The Winds of Winter ain'= t one.\",\n books.len());\n}\n\n// Remove a book.\nbooks.remove= (\"The Odyssey\");\n\n// Iterate over everything.\nfor book in &books {\n = println!(\"{book}\");\n}\n\nThe easiest way to use HashSet with a custom = type is to derive Eq and Hash. We must also derive PartialEq, which is requ= ired if Eq is derived.\n\nuse std::collections::HashSet;\n#[derive(Hash, Eq= , PartialEq, Debug)]\nstruct Viking {\n name: String,\n power: usize,= \n}\n\nlet mut vikings =3D HashSet::new();\n\nvikings.insert(Viking { name:= \"Einar\".to_string(), power: 9 });\nvikings.insert(Viking { name: \"Einar= \".to_string(), power: 9 });\nvikings.insert(Viking { name: \"Olaf\".to_str= ing(), power: 4 });\nvikings.insert(Viking { name: \"Harald\".to_string(), = power: 8 });\n\n// Use derived implementation to print the vikings.\nfor x = in &vikings {\n println!(\"{x:?}\");\n}\n\nA HashSet with a known list o= f items can be initialized from an array:\n\nuse std::collections::HashSet;= \n\nlet viking_names =3D HashSet::from([\"Einar\", \"Olaf\", \"Harald\"]);") :range (:start (:line 6 :character 10) :end (:line 6 :character 17)))) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename=AFTER Content-Transfer-Encoding: quoted-printable Content-Description: After a8c1559 [internal] Mon Sep 16 12:50:03 2024: (:message "Running language server: rust-analyzer") [client-request] (id:1) Mon Sep 16 12:50:03 2024: (:jsonrpc "2.0" :id 1 :method "initialize" :params (:processId 1664968 :clientInfo (:name "Eglot") :rootPath "/home/brennan/test_rust/" :rootUri "file:///home/brennan= /test_rust" :initializationOptions #s(hash-table size 1 test eql rehash-siz= e 1.5 rehash-threshold 0.8125 data ()) :capabilities (:workspace (:applyEdit t :executeCommand (:dynamicRegistration :json-false) :workspaceEdit (:documentChanges t) :didChangeWatchedFiles (:dynamicRegistration t) :symbol (:dynamicRegistration :json-false) :configuration t :workspaceFolders t) :textDocument (:synchronization (:dynamicRegistration :json-false :willSave t :willSaveWaitUntil t :didS= ave t) :completion (:dynamicRegistration :json-false :completionItem (:snippetSupport :json-false :deprecatedSupport t :resolveSupport (:properties ["documentation" "details" "additionalTextEdits"]) :tagSupport (:valueSet [1])) :contextSupport t) :hover (:dynamicRegistration :json-false :contentFormat ["plaintext"]) :signatureHelp (:dynamicRegistration :json-false :signatureInformation (:parameterInformation (:labelOffsetSupport t) :activeParameterSupport t)) :references (:dynamicRegistration :json-false) :definition (:dynamicRegistration :json-false :linkSupport t) :declaration (:dynamicRegistration :json-false :linkSupport t) :implementation (:dynamicRegistration :json-false :linkSupport t) :typeDefinition (:dynamicRegistration :json-false :linkSupport t) :documentSymbol (:dynamicRegistration :json-false :hierarchicalDocumentSymbolSupport t := symbolKind (:valueSet [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24= 25 26])) :documentHighlight (:dynamicRegistration :json-false) :codeAction (:dynamicRegistration :json-false :codeActionLiteralSupport (:codeActionKind (:valueSet ["quickfix" "refactor" "refactor.extract" "refactor.inline" "refactor= .rewrite" "source" "source.organizeImports"])) :isPreferredSupport t) :formatting (:dynamicRegistration :json-false) :rangeFormatting (:dynamicRegistration :json-false) :rename (:dynamicRegistration :json-false) :inlayHint (:dynamicRegistration :json-false) :publishDiagnostics (:relatedInformation :json-false :codeDescriptionSupport :json-false :ta= gSupport (:valueSet [1 2]))) :window (:workDoneProgress t) :general (:positionEncodings ["utf-32" "utf-8" "utf-16"]) :experimental #s(hash-table size 1 test eql rehash-size 1.5 rehash= -threshold 0.8125 data ())) :workspaceFolders [(:uri "file:///home/brennan/test_rust" :name "~/test_rust/")])) [server-reply] (id:1) Mon Sep 16 12:50:03 2024: (:jsonrpc "2.0" :id 1 :result (:capabilities (:positionEncoding "utf-32" :textDocumentSync (:openClose t :change 2 :save nil) :selectionRangeProvider t :hoverProvider t :completionProvider (:resolveProvider t :triggerCharacters [":" "." "'" "("] :completionItem (:labelDetailsSupport :json-false)) :signatureHelpProvider (:triggerCharacters ["(" "," "<"]) :definitionProvider t :typeDefinitionProvider t :implementationPro= vider t :referencesProvider t :documentHighlightProvider t :documentSymbolP= rovider t :workspaceSymbolProvider t :codeActionProvider (:codeActionKinds ["" "quickfix" "refactor" "refactor.extract" "refactor.inline" "r= efactor.rewrite"] :resolveProvider t) :codeLensProvider (:resolveProvider t) :documentFormattingProvider t :documentRangeFormattingProvider :js= on-false :documentOnTypeFormattingProvider (:firstTriggerCharacter "=3D" :moreTriggerCharacter ["." ">" "{" "("]) :renameProvider (:prepareProvider t) :foldingRangeProvider t :declarationProvider t :workspace (:workspaceFolders (:supported t :changeNotifications t) :fileOperations (:willRename (:filters [(:scheme "file" :pattern (:glob "**/*.rs" :matches "file")) (:scheme "file" :pattern (:glob "**" :matches "folder"))]))) :callHierarchyProvider t :semanticTokensProvider (:legend (:tokenTypes ["comment" "decorator" "enumMember" "enum" "function" "interface" "keyw= ord" "macro" "method" "namespace" "number" "operator" "parameter" "property= " "string" "struct" "typeParameter" "variable" "angle" "arithmetic" "attrib= uteBracket" "attribute" "bitwise" "boolean" "brace" "bracket" "builtinAttri= bute" "builtinType" "character" "colon" "comma" "comparison" "constParamete= r" "const" "deriveHelper" "derive" "dot" "escapeSequence" "formatSpecifier"= "generic" "invalidEscapeSequence" "label" "lifetime" "logical" "macroBang"= "parenthesis" "procMacro" "punctuation" "selfKeyword" "selfTypeKeyword" "s= emicolon" "static" "toolModule" "typeAlias" "union" "unresolvedReference"] :tokenModifiers ["async" "documentation" "declaration" "static" "defaultLibrary" "assoc= iated" "attribute" "callable" "constant" "consuming" "controlFlow" "crateRo= ot" "injected" "intraDocLink" "library" "macro" "mutable" "procMacro" "publ= ic" "reference" "trait" "unsafe"]) :range t :full (:delta t)) :inlayHintProvider (:resolveProvider t) :experimental (:externalDocs t :hoverRange t :joinLines t :matchingBrace t :move= Item t :onEnter t :openCargoToml t :parentModule t :runnables (:kinds ["cargo"]) :ssr t :workspaceSymbolScopeKindFiltering t)) :serverInfo (:name "rust-analyzer" :version "1.81.0 (eeb90cda 2024-09-04)"))) [client-notification] Mon Sep 16 12:50:03 2024: (:jsonrpc "2.0" :method "initialized" :params #s(hash-table size 1 test eql= rehash-size 1.5 rehash-threshold 0.8125 data ())) [client-notification] Mon Sep 16 12:50:03 2024: (:jsonrpc "2.0" :method "textDocument/didOpen" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs" :version 0 :language= Id "rust-ts" :text "struct S {\n x: T\n}\n\nimpl S> {\n= }\n\nfn main() {}\n"))) [client-notification] Mon Sep 16 12:50:03 2024: (:jsonrpc "2.0" :method "workspace/didChangeConfiguration" :params (:settings #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshol= d 0.8125 data ()))) [client-request] (id:2) Mon Sep 16 12:50:03 2024: (:jsonrpc "2.0" :id 2 :method "textDocument/inlayHint" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :range (:start (:line 0 :character 0) :end (:line 8 :character 0)))) [server-request] (id:0) Mon Sep 16 12:50:03 2024: (:jsonrpc "2.0" :id 0 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Fetching")) [client-reply] (id:0) Mon Sep 16 12:50:03 2024: (:jsonrpc "2.0" :id 0 :result nil) [server-notification] Mon Sep 16 12:50:03 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Fetching" :value (:kind "begin" :title "Fetching" :cancellable :json-false))) [server-request] (id:1) Mon Sep 16 12:50:03 2024: (:jsonrpc "2.0" :id 1 :method "workspace/configuration" :params (:items [(:section "rust-analyzer")])) [client-reply] (id:1) Mon Sep 16 12:50:03 2024: (:jsonrpc "2.0" :id 1 :result [nil]) [server-reply] (id:2) Mon Sep 16 12:50:03 2024: (:jsonrpc "2.0" :id 2 :result []) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Fetching" :value (:kind "report" :cancellable :json-false :message "metadata"))) [server-request] (id:2) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 2 :method "client/registerCapability" :params (:registrations [(:id "workspace/didChangeWatchedFiles" :method "workspace/didChangeWat= chedFiles" :registerOptions (:watchers [(:globPattern "/home/brennan/test_rust/**/*.rs") (:globPattern "/home/brennan/test_rust/**/Cargo.{toml,lock}") (:globPattern "/home/brennan/test_rust/**/rust-analyzer.toml") (:globPattern "/home/brennan/.config/rust-analyzer/rust-analyzer.toml") (:globPattern "/home/brennan/test_rust/rust-analyzer.toml") (:globPattern "/home/brennan/test_rust/Cargo.toml")]))])) [client-reply] (id:2) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 2 :result nil) [server-request] (id:3) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 3 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Building CrateGraph")) [client-reply] (id:3) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 3 :result nil) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Building CrateGraph" :value (:kind "begin" :title "Building CrateGraph" :cancellable :json-false))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Building CrateGraph" :value (:kind "end"))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Fetching" :value (:kind "end"))) [server-request] (id:4) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 4 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Roots Scanned")) [client-reply] (id:4) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 4 :result nil) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "begin" :title "Roots Scanned" :cancellable :json-false :message= "0/3" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/alloc" :percentage 0))) [server-request] (id:5) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 5 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Fetching")) [client-reply] (id:5) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 5 :result nil) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Fetching" :value (:kind "begin" :title "Fetching" :cancellable :json-false))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/core" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/backtrace" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/panic_abort" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/panic_unwind" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/portable-simd" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/proc_macro" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/profiler_builtins" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/rtstartup" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/rustc-std-workspace-alloc" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/rustc-std-workspace-core" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/rustc-std-workspace-std" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/std" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/stdarch" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/sysroot" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/test" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/unwind" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "1/3" :percentage 33)= )) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "1/3: " :percentage 3= 3))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "1/3: " :percentage 3= 3))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "1/3: src" :percentag= e 33))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "2/3" :percentage 66)= )) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "end" :message "3/3"))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Fetching" :value (:kind "report" :cancellable :json-false :message "metadata"))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Fetching" :value (:kind "end"))) [server-request] (id:6) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 6 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Fetching")) [client-reply] (id:6) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 6 :result nil) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Fetching" :value (:kind "begin" :title "Fetching" :cancellable :json-false))) [server-request] (id:7) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 7 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Indexing")) [client-reply] (id:7) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 7 :result nil) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "begin" :title "Indexing" :cancellable :json-false :percentage 0= ))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:uri "file:///home/brennan/test_rust/src/main.rs" :diagnostics [] :version 0)) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "0/1 (test_rust)" :pe= rcentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :percentage 100))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "end"))) [server-request] (id:8) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 8 :method "window/workDoneProgress/create" :params (:token "rust-analyzer/flycheck/0")) [client-reply] (id:8) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 8 :result nil) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rust-analyzer/flycheck/0" :value (:kind "begin" :title "cargo check" :cancellable t))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:uri "file:///home/brennan/test_rust/src/main.rs" :diagnostics [(:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :severity 1 :code "E0412" :codeDescription (:href "https://doc.rust-lang.org/error-index.html#E0412") :source "rustc" :message "cannot find type `HashSet` in this scope\nnot= found in this scope" :relatedInformation [(:location (:uri "file:///home/brennan/test_rust/src/main.rs" :range (:start (:line 0 :character 0) :end (:line 0 :character 0))) :message "consider importing this struct: `use std::collections::Hash= Set;\n\n`")] :data (:rendered "error[E0412]: cannot find type `HashSet` in this scope\n --= > src/main.rs:5:11\n |\n5 | impl S> {\n | ^^^^^^^= not found in this scope\n |\nhelp: consider importing this struct\n |\n1= + use std::collections::HashSet;\n |\n\n")) (:range (:start (:line 0 :character 0) :end (:line 0 :character 0)) :severity 4 :code "E0412" :codeDescription (:href "https://doc.rust-lang.org/error-index.html#E0412") :source "rustc" :message "consider importing this struct: `use std::col= lections::HashSet;\n\n`" :relatedInformation [(:location (:uri "file:///home/brennan/test_rust/src/main.rs" :range (:start (:line 4 :character 10) :end (:line 4 :character 17))) :message "original diagnostic")])] :version 0)) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rust-analyzer/flycheck/0" :value (:kind "end"))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Fetching" :value (:kind "report" :cancellable :json-false :message "metadata"))) [server-request] (id:9) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 9 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Building CrateGraph")) [client-reply] (id:9) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 9 :result nil) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Building CrateGraph" :value (:kind "begin" :title "Building CrateGraph" :cancellable :json-false))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Building CrateGraph" :value (:kind "end"))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Fetching" :value (:kind "end"))) [server-request] (id:10) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 10 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Building build-artifacts")) [client-reply] (id:10) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 10 :result nil) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Building build-artifacts" :value (:kind "begin" :title "Building build-artifacts" :cancellable :json-fal= se))) [server-request] (id:11) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 11 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Indexing")) [client-reply] (id:11) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 11 :result nil) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "begin" :title "Indexing" :cancellable :json-false :percentage 0= ))) [server-request] (id:12) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 12 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Loading proc-macros")) [client-reply] (id:12) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 12 :result nil) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Loading proc-macros" :value (:kind "begin" :title "Loading proc-macros" :cancellable :json-false))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Loading proc-macros" :value (:kind "end"))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "end"))) [server-request] (id:13) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 13 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Indexing")) [client-reply] (id:13) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 13 :result nil) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "begin" :title "Indexing" :cancellable :json-false :percentage 0= ))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "1/12 (core + 6 more)= " :percentage 8))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "3/12 (core + 4 more)= " :percentage 25))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "4/12 (core + 3 more)= " :percentage 33))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "5/12 (core + 2 more)= " :percentage 41))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "6/12 (core + 1 more)= " :percentage 50))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "7/12 (core)" :percen= tage 58))) [client-request] (id:3) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 3 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 0 :character 0))) [client-request] (id:4) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 4 :method "textDocument/hover" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 0 :character 0))) [client-request] (id:5) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 5 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 0 :character 0))) [server-request] (id:14) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 14 :method "window/workDoneProgress/create" :params (:token "rust-analyzer/flycheck/0")) [client-reply] (id:14) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 14 :result nil) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rust-analyzer/flycheck/0" :value (:kind "begin" :title "cargo check" :cancellable t))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:uri "file:///home/brennan/test_rust/src/main.rs" :diagnostics [(:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :severity 1 :code "E0412" :codeDescription (:href "https://doc.rust-lang.org/error-index.html#E0412") :source "rustc" :message "cannot find type `HashSet` in this scope\nnot= found in this scope" :relatedInformation [(:location (:uri "file:///home/brennan/test_rust/src/main.rs" :range (:start (:line 0 :character 0) :end (:line 0 :character 0))) :message "consider importing this struct: `use std::collections::Hash= Set;\n\n`")] :data (:rendered "error[E0412]: cannot find type `HashSet` in this scope\n --= > src/main.rs:5:11\n |\n5 | impl S> {\n | ^^^^^^^= not found in this scope\n |\nhelp: consider importing this struct\n |\n1= + use std::collections::HashSet;\n |\n\n")) (:range (:start (:line 0 :character 0) :end (:line 0 :character 0)) :severity 4 :code "E0412" :codeDescription (:href "https://doc.rust-lang.org/error-index.html#E0412") :source "rustc" :message "consider importing this struct: `use std::col= lections::HashSet;\n\n`" :relatedInformation [(:location (:uri "file:///home/brennan/test_rust/src/main.rs" :range (:start (:line 4 :character 10) :end (:line 4 :character 17))) :message "original diagnostic")])] :version 0)) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rust-analyzer/flycheck/0" :value (:kind "end"))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Building build-artifacts" :value (:kind "report" :cancellable :json-false :message "building proc-macros= : test_rust"))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Building build-artifacts" :value (:kind "report" :cancellable :json-false :message "building proc-macros= : test_rust"))) [server-request] (id:15) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 15 :method "client/registerCapability" :params (:registrations [(:id "workspace/didChangeWatchedFiles" :method "workspace/didChangeWat= chedFiles" :registerOptions (:watchers [(:globPattern "/home/brennan/test_rust/**/*.rs") (:globPattern "/home/brennan/test_rust/**/Cargo.{toml,lock}") (:globPattern "/home/brennan/test_rust/**/rust-analyzer.toml") (:globPattern "/home/brennan/.config/rust-analyzer/rust-analyzer.toml") (:globPattern "/home/brennan/test_rust/rust-analyzer.toml") (:globPattern "/home/brennan/test_rust/Cargo.toml")]))])) [client-reply] (id:15) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 15 :result nil) [server-request] (id:16) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 16 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Building CrateGraph")) [client-reply] (id:16) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 16 :result nil) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Building CrateGraph" :value (:kind "begin" :title "Building CrateGraph" :cancellable :json-false))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Building CrateGraph" :value (:kind "end"))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Building build-artifacts" :value (:kind "end"))) [server-reply] (id:3) ERROR Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 3 :error (:code -32801 :message "content modified")) [internal] (id:3) ERROR Mon Sep 16 12:50:04 2024: (:message "error ignored, status set (content modified)" :id 3 :error -3280= 1) [server-reply] (id:4) ERROR Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 4 :error (:code -32801 :message "content modified")) [internal] (id:4) ERROR Mon Sep 16 12:50:04 2024: (:message "error ignored, status set (content modified)" :id 4 :error -3280= 1) [server-reply] (id:5) ERROR Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 5 :error (:code -32801 :message "content modified")) [internal] (id:5) ERROR Mon Sep 16 12:50:04 2024: (:message "error ignored, status set (content modified)" :id 5 :error -3280= 1) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "end"))) [server-request] (id:17) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 17 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Loading proc-macros")) [client-reply] (id:17) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 17 :result nil) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Loading proc-macros" :value (:kind "begin" :title "Loading proc-macros" :cancellable :json-false))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Loading proc-macros" :value (:kind "end"))) [server-request] (id:18) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 18 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Indexing")) [client-reply] (id:18) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 18 :result nil) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "begin" :title "Indexing" :cancellable :json-false :percentage 0= ))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "end"))) [server-request] (id:19) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 19 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Roots Scanned")) [client-reply] (id:19) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 19 :result nil) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "begin" :title "Roots Scanned" :cancellable :json-false :message= "0/3" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/alloc" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/core" :percentage 0))) [server-request] (id:20) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 20 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Indexing")) [client-reply] (id:20) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 20 :result nil) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "begin" :title "Indexing" :cancellable :json-false :percentage 0= ))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "2/12 (core + 4 more)= " :percentage 16))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "5/12 (core + 2 more)= " :percentage 41))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "6/12 (core + 1 more)= " :percentage 50))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/backtrace" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/panic_abort" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/panic_unwind" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/portable-simd" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/proc_macro" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/profiler_builtins" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/rtstartup" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/rustc-std-workspace-alloc" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/rustc-std-workspace-core" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/rustc-std-workspace-std" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/std" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/stdarch" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "7/12 (core)" :percen= tage 58))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/sysroot" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/test" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "0/3: /home/brennan/.= rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/lib= rary/unwind" :percentage 0))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "1/3" :percentage 33)= )) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "1/3: " :percentage 3= 3))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "1/3: " :percentage 3= 3))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "1/3: src" :percentag= e 33))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "report" :cancellable :json-false :message "2/3" :percentage 66)= )) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Roots Scanned" :value (:kind "end" :message "3/3"))) [server-request] (id:21) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 21 :method "window/workDoneProgress/create" :params (:token "rust-analyzer/flycheck/0")) [client-reply] (id:21) Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :id 21 :result nil) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rust-analyzer/flycheck/0" :value (:kind "begin" :title "cargo check" :cancellable t))) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:uri "file:///home/brennan/test_rust/src/main.rs" :diagnostics [(:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :severity 1 :code "E0412" :codeDescription (:href "https://doc.rust-lang.org/error-index.html#E0412") :source "rustc" :message "cannot find type `HashSet` in this scope\nnot= found in this scope" :relatedInformation [(:location (:uri "file:///home/brennan/test_rust/src/main.rs" :range (:start (:line 0 :character 0) :end (:line 0 :character 0))) :message "consider importing this struct: `use std::collections::Hash= Set;\n\n`")] :data (:rendered "error[E0412]: cannot find type `HashSet` in this scope\n --= > src/main.rs:5:11\n |\n5 | impl S> {\n | ^^^^^^^= not found in this scope\n |\nhelp: consider importing this struct\n |\n1= + use std::collections::HashSet;\n |\n\n")) (:range (:start (:line 0 :character 0) :end (:line 0 :character 0)) :severity 4 :code "E0412" :codeDescription (:href "https://doc.rust-lang.org/error-index.html#E0412") :source "rustc" :message "consider importing this struct: `use std::col= lections::HashSet;\n\n`" :relatedInformation [(:location (:uri "file:///home/brennan/test_rust/src/main.rs" :range (:start (:line 4 :character 10) :end (:line 4 :character 17))) :message "original diagnostic")])] :version 0)) [server-notification] Mon Sep 16 12:50:04 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rust-analyzer/flycheck/0" :value (:kind "end"))) [server-notification] Mon Sep 16 12:50:05 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :percentage 66))) [server-notification] Mon Sep 16 12:50:05 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "8/12 (alloc)" :perce= ntage 66))) [server-notification] Mon Sep 16 12:50:05 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :percentage 75))) [server-notification] Mon Sep 16 12:50:05 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "9/12 (std)" :percent= age 75))) [server-notification] Mon Sep 16 12:50:05 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :percentage 83))) [server-notification] Mon Sep 16 12:50:05 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "10/12 (proc_macro)" = :percentage 83))) [server-notification] Mon Sep 16 12:50:05 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :percentage 91))) [server-notification] Mon Sep 16 12:50:05 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :message "11/12 (test_rust)" := percentage 91))) [server-notification] Mon Sep 16 12:50:05 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :percentage 100))) [server-notification] Mon Sep 16 12:50:05 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "end"))) [server-request] (id:22) Mon Sep 16 12:50:05 2024: (:jsonrpc "2.0" :id 22 :method "window/workDoneProgress/create" :params (:token "rustAnalyzer/Indexing")) [client-reply] (id:22) Mon Sep 16 12:50:05 2024: (:jsonrpc "2.0" :id 22 :result nil) [server-notification] Mon Sep 16 12:50:05 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "begin" :title "Indexing" :cancellable :json-false :percentage 0= ))) [server-notification] Mon Sep 16 12:50:05 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :percentage 91))) [server-notification] Mon Sep 16 12:50:05 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "report" :cancellable :json-false :percentage 100))) [server-notification] Mon Sep 16 12:50:05 2024: (:jsonrpc "2.0" :method "$/progress" :params (:token "rustAnalyzer/Indexing" :value (:kind "end"))) [client-request] (id:6) Mon Sep 16 12:50:07 2024: (:jsonrpc "2.0" :id 6 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 9))) [client-request] (id:7) Mon Sep 16 12:50:07 2024: (:jsonrpc "2.0" :id 7 :method "textDocument/hover" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 9))) [client-request] (id:8) Mon Sep 16 12:50:07 2024: (:jsonrpc "2.0" :id 8 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 9))) [server-reply] (id:6) Mon Sep 16 12:50:07 2024: (:jsonrpc "2.0" :id 6 :result nil) [server-reply] (id:8) Mon Sep 16 12:50:07 2024: (:jsonrpc "2.0" :id 8 :result [(:range (:start (:line 4 :character 8) :end (:line 4 :character 9))) (:range (:start (:line 0 :character 7) :end (:line 0 :character 8)))]) [server-reply] (id:7) Mon Sep 16 12:50:07 2024: (:jsonrpc "2.0" :id 7 :result (:contents (:kind "plaintext" :value "test_rust\n\nstruct S {\n x: T,\n}") :range (:start (:line 4 :character 8) :end (:line 4 :character 9)))) [client-request] (id:9) Mon Sep 16 12:50:08 2024: (:jsonrpc "2.0" :id 9 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 17))) [client-request] (id:10) Mon Sep 16 12:50:08 2024: (:jsonrpc "2.0" :id 10 :method "textDocument/hover" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 17))) [client-request] (id:11) Mon Sep 16 12:50:08 2024: (:jsonrpc "2.0" :id 11 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 17))) [server-reply] (id:9) Mon Sep 16 12:50:08 2024: (:jsonrpc "2.0" :id 9 :result (:signatures [(:label "struct S" :parameters [(:label [9 10])] :activeParameter 0)] :activeSignature 0 :activeParameter 0)) [server-reply] (id:10) Mon Sep 16 12:50:08 2024: (:jsonrpc "2.0" :id 10 :result nil) [server-reply] (id:11) Mon Sep 16 12:50:08 2024: (:jsonrpc "2.0" :id 11 :result nil) [client-request] (id:12) Mon Sep 16 12:50:08 2024: (:jsonrpc "2.0" :id 12 :method "textDocument/completion" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 17) :context (:triggerKind 1))) [server-reply] (id:12) Mon Sep 16 12:50:08 2024: (:jsonrpc "2.0" :id 12 :result (:isIncomplete t :items [(:label "HashSet (use std::collections::HashSet)" :kind 22 :detail "Ha= shSet<{unknown}, {unknown}>" :documentation (:kind "markdown" :value "A [hash set] implemented as a `HashMap` whe= re the value is `()`.\n\nAs with the [`HashMap`] type, a `HashSet` requires= that the elements\nimplement the [`Eq`] and [`Hash`] traits. This can freq= uently be achieved by\nusing `#[derive(PartialEq, Eq, Hash)]`. If you imple= ment these yourself,\nit is important that the following property holds:\n\= n```text\nk1 =3D=3D k2 -> hash(k1) =3D=3D hash(k2)\n```\n\nIn other words, = if two keys are equal, their hashes must be equal.\nViolating this property= is a logic error.\n\nIt is also a logic error for a key to be modified in = such a way that the key's\nhash, as determined by the [`Hash`] trait, or it= s equality, as determined by\nthe [`Eq`] trait, changes while it is in the = map. This is normally only\npossible through [`Cell`], [`RefCell`], global = state, I/O, or unsafe code.\n\nThe behavior resulting from either logic err= or is not specified, but will\nbe encapsulated to the `HashSet` that observ= ed the logic error and not\nresult in undefined behavior. This could includ= e panics, incorrect results,\naborts, memory leaks, and non-termination.\n\= n# Examples\n\n```rust\nuse std::collections::HashSet;\n// Type inference l= ets us omit an explicit type signature (which\n// would be `HashSet= ` in this example).\nlet mut books =3D HashSet::new();\n\n// Add some books= .\nbooks.insert(\"A Dance With Dragons\".to_string());\nbooks.insert(\"To K= ill a Mockingbird\".to_string());\nbooks.insert(\"The Odyssey\".to_string()= );\nbooks.insert(\"The Great Gatsby\".to_string());\n\n// Check for a speci= fic one.\nif !books.contains(\"The Winds of Winter\") {\n println!(\"We = have {} books, but The Winds of Winter ain't one.\",\n books.le= n());\n}\n\n// Remove a book.\nbooks.remove(\"The Odyssey\");\n\n// Iterate= over everything.\nfor book in &books {\n println!(\"{book}\");\n}\n```\= n\nThe easiest way to use `HashSet` with a custom type is to derive\n[`Eq`]= and [`Hash`]. We must also derive [`PartialEq`],\nwhich is required if [`E= q`] is derived.\n\n```rust\nuse std::collections::HashSet;\n#[derive(Hash, = Eq, PartialEq, Debug)]\nstruct Viking {\n name: String,\n power: usiz= e,\n}\n\nlet mut vikings =3D HashSet::new();\n\nvikings.insert(Viking { nam= e: \"Einar\".to_string(), power: 9 });\nvikings.insert(Viking { name: \"Ein= ar\".to_string(), power: 9 });\nvikings.insert(Viking { name: \"Olaf\".to_s= tring(), power: 4 });\nvikings.insert(Viking { name: \"Harald\".to_string()= , power: 8 });\n\n// Use derived implementation to print the vikings.\nfor = x in &vikings {\n println!(\"{x:?}\");\n}\n```\n\nA `HashSet` with a kno= wn list of items can be initialized from an array:\n\n```rust\nuse std::col= lections::HashSet;\n\nlet viking_names =3D HashSet::from([\"Einar\", \"Olaf= \", \"Harald\"]);\n```\n\n[hash set]: crate::collections#use-the-set-varian= t-of-any-of-these-maps-when\n[`HashMap`]: crate::collections::HashMap\n[`Re= fCell`]: crate::cell::RefCell\n[`Cell`]: crate::cell::Cell") :deprecated :json-false :sortText "fffffff0" :filterText "HashSet" :t= extEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "HashSet") :additionalTextEdits [] :data (:position (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 17)) :imports [(:full_import_path "std::collections::HashSet" :imported_name "Hash= Set")] :version 0)) (:label "self::" :kind 14 :deprecated :json-false :preselect t :sortTe= xt "ffffffef" :filterText "self::" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "self::") :additionalTextEdits []) (:label "crate::" :kind 14 :deprecated :json-false :preselect t :sortT= ext "ffffffef" :filterText "crate::" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "crate::") :additionalTextEdits []) (:label "Self" :kind 12 :detail "S<{unknown}>" :deprecated :json-false= :preselect t :sortText "ffffffef" :filterText "Self" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Self") :additionalTextEdits []) (:label "T" :kind 25 :deprecated :json-false :preselect t :sortText "f= fffffef" :filterText "T" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "T") :additionalTextEdits []) (:label "S" :kind 22 :detail "S<{unknown}>" :deprecated :json-false :p= reselect t :sortText "ffffffef" :filterText "S" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "S") :additionalTextEdits []) (:label "panic!" :kind 3 :detail "macro_rules! panic" :deprecated :jso= n-false :preselect t :sortText "ffffffef" :filterText "panic!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "panic!") :additionalTextEdits []) (:label "println!" :kind 3 :detail "macro_rules! println" :documentati= on (:kind "markdown" :value "Prints to the standard output, with a newli= ne.\n\nOn all platforms, the newline is the LINE FEED character (`\\n`/`U+0= 00A`) alone\n(no additional CARRIAGE RETURN (`\\r`/`U+000D`)).\n\nThis macr= o uses the same syntax as [`format!`], but writes to the standard output in= stead.\nSee [`std::fmt`] for more information.\n\nThe `println!` macro will= lock the standard output on each call. If you call\n`println!` within a ho= t loop, this behavior may be the bottleneck of the loop.\nTo avoid this, lo= ck stdout with [`io::stdout().lock()`][lock]:\n```rust\nuse std::io::{stdou= t, Write};\n\nlet mut lock =3D stdout().lock();\nwriteln!(lock, \"hello wor= ld\").unwrap();\n```\n\nUse `println!` only for the primary output of your = program. Use\n[`eprintln!`] instead to print error and progress messages.\n= \nSee [the formatting documentation in `std::fmt`](../std/fmt/index.html)\n= for details of the macro argument syntax.\n\n[`std::fmt`]: crate::fmt\n[`ep= rintln!`]: crate::eprintln\n[lock]: crate::io::Stdout\n\n# Panics\n\nPanics= if writing to [`io::stdout`] fails.\n\nWriting to non-blocking stdout can = cause an error, which will lead\nthis macro to panic.\n\n[`io::stdout`]: cr= ate::io::stdout\n\n# Examples\n\n```rust\nprintln!(); // prints just a newl= ine\nprintln!(\"hello there!\");\nprintln!(\"format {} arguments\", \"some\= ");\nlet local_variable =3D \"some\";\nprintln!(\"format {local_variable} a= rguments\");\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "println!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "println!") :additionalTextEdits []) (:label "debug_assert_eq!" :kind 3 :detail "macro_rules! debug_assert_= eq" :documentation (:kind "markdown" :value "Asserts that two expressions are equal to e= ach other.\n\nOn panic, this macro will print the values of the expressions= with their\ndebug representations.\n\nUnlike [`assert_eq!`], `debug_assert= _eq!` statements are only enabled in non\noptimized builds by default. An o= ptimized build will not execute\n`debug_assert_eq!` statements unless `-C d= ebug-assertions` is passed to the\ncompiler. This makes `debug_assert_eq!` = useful for checks that are too\nexpensive to be present in a release build = but may be helpful during\ndevelopment. The result of expanding `debug_asse= rt_eq!` is always type checked.\n\n# Examples\n\n```rust\nlet a =3D 3;\nlet= b =3D 1 + 2;\ndebug_assert_eq!(a, b);\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "debug_assert_eq!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "debug_assert_eq!") :additionalTextEdits []) (:label "include_str!" :kind 3 :detail "macro_rules! include_str" :doc= umentation (:kind "markdown" :value "Includes a UTF-8 encoded file as a string.\= n\nThe file is located relative to the current file (similarly to how\nmodu= les are found). The provided path is interpreted in a platform-specific\nwa= y at compile time. So, for instance, an invocation with a Windows path\ncon= taining backslashes `\\` would not compile correctly on Unix.\n\nThis macro= will yield an expression of type `&'static str` which is the\ncontents of = the file.\n\n# Examples\n\nAssume there are two files in the same directory= with the following\ncontents:\n\nFile 'spanish.in':\n\n```text\nadi=C3=B3s= \n```\n\nFile 'main.rs':\n\n```rust\nfn main() {\n let my_str =3D includ= e_str!(\"spanish.in\");\n assert_eq!(my_str, \"adi=C3=B3s\\n\");\n pr= int!(\"{my_str}\");\n}\n```\n\nCompiling 'main.rs' and running the resultin= g binary will print \"adi=C3=B3s\".") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "include_str!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "include_str!") :additionalTextEdits []) (:label "concat!" :kind 3 :detail "macro_rules! concat" :documentation (:kind "markdown" :value "Concatenates literals into a static string = slice.\n\nThis macro takes any number of comma-separated literals, yielding= an\nexpression of type `&'static str` which represents all of the literals= \nconcatenated left-to-right.\n\nInteger and floating point literals are [s= tringified](core::stringify) in order to be\nconcatenated.\n\n# Examples\n\= n```rust\nlet s =3D concat!(\"test\", 10, 'b', true);\nassert_eq!(s, \"test= 10btrue\");\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "concat!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "concat!") :additionalTextEdits []) (:label "format!" :kind 3 :detail "macro_rules! format" :documentation (:kind "markdown" :value "Creates a `String` using interpolation of r= untime expressions.\n\nThe first argument `format!` receives is a format st= ring. This must be a string\nliteral. The power of the formatting string is= in the `{}`s contained.\nAdditional parameters passed to `format!` replace= the `{}`s within the\nformatting string in the order given unless named or= positional parameters\nare used.\n\nSee [the formatting syntax documentati= on in `std::fmt`](../std/fmt/index.html)\nfor details.\n\nA common use for = `format!` is concatenation and interpolation of strings.\nThe same conventi= on is used with [`print!`] and [`write!`] macros,\ndepending on the intende= d destination of the string; all these macros internally use [`format_args!= `].\n\nTo convert a single value to a string, use the [`to_string`] method.= This\nwill use the [`Display`] formatting trait.\n\nTo concatenate literal= s into a `&'static str`, use the [`concat!`] macro.\n\n[`print!`]: ../std/m= acro.print.html\n[`write!`]: core::write\n[`format_args!`]: core::format_ar= gs\n[`to_string`]: crate::string::ToString\n[`Display`]: core::fmt::Display= \n[`concat!`]: core::concat\n\n# Panics\n\n`format!` panics if a formatting= trait implementation returns an error.\nThis indicates an incorrect implem= entation\nsince `fmt::Write for String` never returns an error itself.\n\n#= Examples\n\n```rust\nformat!(\"test\"); // =3D= > \"test\"\nformat!(\"hello {}\", \"world!\"); // =3D> \"hell= o world!\"\nformat!(\"x =3D {}, y =3D {val}\", 10, val =3D 30); // =3D> \"= x =3D 10, y =3D 30\"\nlet (x, y) =3D (1, 2);\nformat!(\"{x} + {y} =3D 3\");= // =3D> \"1 + 2 =3D 3\"\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "format!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "format!") :additionalTextEdits []) (:label "stringify!" :kind 3 :detail "macro_rules! stringify" :documen= tation (:kind "markdown" :value "Stringifies its arguments.\n\nThis macro wi= ll yield an expression of type `&'static str` which is the\nstringification= of all the tokens passed to the macro. No restrictions\nare placed on the = syntax of the macro invocation itself.\n\nNote that the expanded results of= the input tokens may change in the\nfuture. You should be careful if you r= ely on the output.\n\n# Examples\n\n```rust\nlet one_plus_one =3D stringify= !(1 + 1);\nassert_eq!(one_plus_one, \"1 + 1\");\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "stringify!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "stringify!") :additionalTextEdits []) (:label "assert_ne!" :kind 3 :detail "macro_rules! assert_ne" :documen= tation (:kind "markdown" :value "Asserts that two expressions are not equal = to each other (using [`PartialEq`]).\n\nOn panic, this macro will print the= values of the expressions with their\ndebug representations.\n\nLike [`ass= ert!`], this macro has a second form, where a custom\npanic message can be = provided.\n\n# Examples\n\n```rust\nlet a =3D 3;\nlet b =3D 2;\nassert_ne!(= a, b);\n\nassert_ne!(a, b, \"we are testing that the values are not equal\"= );\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "assert_ne!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "assert_ne!") :additionalTextEdits []) (:label "dbg!" :kind 3 :detail "macro_rules! dbg" :documentation (:kind "markdown" :value "Prints and returns the value of a given exp= ression for quick and dirty\ndebugging.\n\nAn example:\n\n```rust\nlet a = =3D 2;\nlet b =3D dbg!(a * 2) + 1;\n// ^-- prints: [src/main.rs:2:9] a= * 2 =3D 4\nassert_eq!(b, 5);\n```\n\nThe macro works by using the `Debug` = implementation of the type of\nthe given expression to print the value to [= stderr] along with the\nsource location of the macro invocation as well as = the source code\nof the expression.\n\nInvoking the macro on an expression = moves and takes ownership of it\nbefore returning the evaluated expression = unchanged. If the type\nof the expression does not implement `Copy` and you= don't want\nto give up ownership, you can instead borrow with `dbg!(&expr)= `\nfor some expression `expr`.\n\nThe `dbg!` macro works exactly the same i= n release builds.\nThis is useful when debugging issues that only occur in = release\nbuilds or when debugging in release mode is significantly faster.\= n\nNote that the macro is intended as a debugging tool and therefore you\ns= hould avoid having uses of it in version control for long periods\n(other t= han in tests and similar).\nDebug output from production code is better don= e with other facilities\nsuch as the [`debug!`] macro from the [`log`] crat= e.\n\n# Stability\n\nThe exact output printed by this macro should not be r= elied upon\nand is subject to future changes.\n\n# Panics\n\nPanics if writ= ing to `io::stderr` fails.\n\n# Further examples\n\nWith a method call:\n\n= ```rust\nfn foo(n: usize) {\n if let Some(_) =3D dbg!(n.checked_sub(4)) = {\n // ...\n }\n}\n\nfoo(3)\n```\n\nThis prints to [stderr]:\n\n`= ``text,ignore\n[src/main.rs:2:22] n.checked_sub(4) =3D None\n```\n\nNaive f= actorial implementation:\n\n```rust\nfn factorial(n: u32) -> u32 {\n if = dbg!(n <=3D 1) {\n dbg!(1)\n } else {\n dbg!(n * factorial= (n - 1))\n }\n}\n\ndbg!(factorial(4));\n```\n\nThis prints to [stderr]:\= n\n```text,ignore\n[src/main.rs:2:8] n <=3D 1 =3D false\n[src/main.rs:2:8] = n <=3D 1 =3D false\n[src/main.rs:2:8] n <=3D 1 =3D false\n[src/main.rs:2:8]= n <=3D 1 =3D true\n[src/main.rs:3:9] 1 =3D 1\n[src/main.rs:7:9] n * factor= ial(n - 1) =3D 2\n[src/main.rs:7:9] n * factorial(n - 1) =3D 6\n[src/main.r= s:7:9] n * factorial(n - 1) =3D 24\n[src/main.rs:9:1] factorial(4) =3D 24\n= ```\n\nThe `dbg!(..)` macro moves the input:\n\n```rust\n/// A wrapper arou= nd `usize` which importantly is not Copyable.\n#[derive(Debug)]\nstruct NoC= opy(usize);\n\nlet a =3D NoCopy(42);\nlet _ =3D dbg!(a); // <-- `a` is move= d here.\nlet _ =3D dbg!(a); // <-- `a` is moved again; error!\n```\n\nYou c= an also use `dbg!()` without a value to just print the\nfile and line whene= ver it's reached.\n\nFinally, if you want to `dbg!(..)` multiple values, it= will treat them as\na tuple (and return it, too):\n\n```rust\nassert_eq!(d= bg!(1usize, 2u32), (1, 2));\n```\n\nHowever, a single argument with a trail= ing comma will still not be treated\nas a tuple, following the convention o= f ignoring trailing commas in macro\ninvocations. You can use a 1-tuple dir= ectly if you need one:\n\n```rust\nassert_eq!(1, dbg!(1u32,)); // trailing = comma ignored\nassert_eq!((1,), dbg!((1u32,))); // 1-tuple\n```\n\n[stderr]= : https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)\n[= `debug!`]: https://docs.rs/log/*/log/macro.debug.html\n[`log`]: https://cra= tes.io/crates/log") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "dbg!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "dbg!") :additionalTextEdits []) (:label "vec!" :kind 3 :detail "macro_rules! vec" :documentation (:kind "markdown" :value "Creates a [`Vec`] containing the arguments.= \n\n`vec!` allows `Vec`s to be defined with the same syntax as array expres= sions.\nThere are two forms of this macro:\n\n- Create a [`Vec`] containing= a given list of elements:\n\n```rust\nlet v =3D vec![1, 2, 3];\nassert_eq!= (v[0], 1);\nassert_eq!(v[1], 2);\nassert_eq!(v[2], 3);\n```\n\n- Create a [= `Vec`] from a given element and size:\n\n```rust\nlet v =3D vec![1; 3];\nas= sert_eq!(v, [1, 1, 1]);\n```\n\nNote that unlike array expressions this syn= tax supports all elements\nwhich implement [`Clone`] and the number of elem= ents doesn't have to be\na constant.\n\nThis will use `clone` to duplicate = an expression, so one should be careful\nusing this with types having a non= standard `Clone` implementation. For\nexample, `vec![Rc::new(1); 5]` will c= reate a vector of five references\nto the same boxed integer value, not fiv= e references pointing to independently\nboxed integers.\n\nAlso, note that = `vec![expr; 0]` is allowed, and produces an empty vector.\nThis will still = evaluate `expr`, however, and immediately drop the resulting value, so\nbe = mindful of side effects.\n\n[`Vec`]: crate::vec::Vec") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "vec!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "vec!") :additionalTextEdits []) (:label "include!" :kind 3 :detail "macro_rules! include" :documentati= on (:kind "markdown" :value "Parses a file as an expression or an item a= ccording to the context.\n\n**Warning**: For multi-file Rust projects, the = `include!` macro is probably not what you\nare looking for. Usually, multi-= file Rust projects use\n[modules](https://doc.rust-lang.org/reference/items= /modules.html). Multi-file projects and\nmodules are explained in the Rust-= by-Example book\n[here](https://doc.rust-lang.org/rust-by-example/mod/split= .html) and the module system is\nexplained in the Rust Book\n[here](https:/= /doc.rust-lang.org/book/ch07-02-defining-modules-to-control-scope-and-priva= cy.html).\n\nThe included file is placed in the surrounding code\n[unhygien= ically](https://doc.rust-lang.org/reference/macros-by-example.html#hygiene)= . If\nthe included file is parsed as an expression and variables or functio= ns share names across\nboth files, it could result in variables or function= s being different from what the\nincluded file expected.\n\nThe included fi= le is located relative to the current file (similarly to how modules are\nf= ound). The provided path is interpreted in a platform-specific way at compi= le time. So,\nfor instance, an invocation with a Windows path containing ba= ckslashes `\\` would not\ncompile correctly on Unix.\n\n# Uses\n\nThe `incl= ude!` macro is primarily used for two purposes. It is used to include\ndocu= mentation that is written in a separate file and it is used to include [bui= ld artifacts\nusually as a result from the `build.rs`\nscript](https://doc.= rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-scrip= t).\n\nWhen using the `include` macro to include stretches of documentation= , remember that the\nincluded file still needs to be a valid Rust syntax. I= t is also possible to\nuse the [`include_str`] macro as `#![doc =3D include= _str!(\"...\")]` (at the module level) or\n`#[doc =3D include_str!(\"...\")= ]` (at the item level) to include documentation from a plain\ntext or markd= own file.\n\n# Examples\n\nAssume there are two files in the same directory= with the following contents:\n\nFile 'monkeys.in':\n\n```rust\n['=F0=9F=99= =88', '=F0=9F=99=8A', '=F0=9F=99=89']\n .iter()\n .cycle()\n .take= (6)\n .collect::()\n```\n\nFile 'main.rs':\n\n```rust\nfn main()= {\n let my_string =3D include!(\"monkeys.in\");\n assert_eq!(\"=F0= =9F=99=88=F0=9F=99=8A=F0=9F=99=89=F0=9F=99=88=F0=9F=99=8A=F0=9F=99=89\", my= _string);\n println!(\"{my_string}\");\n}\n```\n\nCompiling 'main.rs' an= d running the resulting binary will print\n\"=F0=9F=99=88=F0=9F=99=8A=F0=9F= =99=89=F0=9F=99=88=F0=9F=99=8A=F0=9F=99=89\".") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "include!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "include!") :additionalTextEdits []) (:label "print!" :kind 3 :detail "macro_rules! print" :documentation (:kind "markdown" :value "Prints to the standard output.\n\nEquivalen= t to the [`println!`] macro except that a newline is not printed at\nthe en= d of the message.\n\nNote that stdout is frequently line-buffered by defaul= t so it may be\nnecessary to use [`io::stdout().flush()`][flush] to ensure = the output is emitted\nimmediately.\n\nThe `print!` macro will lock the sta= ndard output on each call. If you call\n`print!` within a hot loop, this be= havior may be the bottleneck of the loop.\nTo avoid this, lock stdout with = [`io::stdout().lock()`][lock]:\n```rust\nuse std::io::{stdout, Write};\n\nl= et mut lock =3D stdout().lock();\nwrite!(lock, \"hello world\").unwrap();\n= ```\n\nUse `print!` only for the primary output of your program. Use\n[`epr= int!`] instead to print error and progress messages.\n\nSee [the formatting= documentation in `std::fmt`](../std/fmt/index.html)\nfor details of the ma= cro argument syntax.\n\n[flush]: crate::io::Write::flush\n[`println!`]: cra= te::println\n[`eprint!`]: crate::eprint\n[lock]: crate::io::Stdout\n\n# Pan= ics\n\nPanics if writing to `io::stdout()` fails.\n\nWriting to non-blockin= g stdout can cause an error, which will lead\nthis macro to panic.\n\n# Exa= mples\n\n```rust\nuse std::io::{self, Write};\n\nprint!(\"this \");\nprint!= (\"will \");\nprint!(\"be \");\nprint!(\"on \");\nprint!(\"the \");\nprint!= (\"same \");\nprint!(\"line \");\n\nio::stdout().flush().unwrap();\n\nprint= !(\"this string has a newline, why not choose println! instead?\\n\");\n\ni= o::stdout().flush().unwrap();\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "print!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "print!") :additionalTextEdits []) (:label "write!" :kind 3 :detail "macro_rules! write" :documentation (:kind "markdown" :value "Writes formatted data into a buffer.\n\nThi= s macro accepts a 'writer', a format string, and a list of arguments. Argum= ents will be\nformatted according to the specified format string and the re= sult will be passed to the writer.\nThe writer may be any value with a `wri= te_fmt` method; generally this comes from an\nimplementation of either the = [`fmt::Write`] or the [`io::Write`] trait. The macro\nreturns whatever the = `write_fmt` method returns; commonly a [`fmt::Result`], or an\n[`io::Result= `].\n\nSee [`std::fmt`] for more information on the format string syntax.\n= \n[`std::fmt`]: ../std/fmt/index.html\n[`fmt::Write`]: crate::fmt::Write\n[= `io::Write`]: ../std/io/trait.Write.html\n[`fmt::Result`]: crate::fmt::Resu= lt\n[`io::Result`]: ../std/io/type.Result.html\n\n# Examples\n\n```rust\nus= e std::io::Write;\n\nfn main() -> std::io::Result<()> {\n let mut w =3D = Vec::new();\n write!(&mut w, \"test\")?;\n write!(&mut w, \"formatted= {}\", \"arguments\")?;\n\n assert_eq!(w, b\"testformatted arguments\");= \n Ok(())\n}\n```\n\nA module can import both `std::fmt::Write` and `std= ::io::Write` and call `write!` on objects\nimplementing either, as objects = do not typically implement both. However, the module must\navoid conflict b= etween the trait names, such as by importing them as `_` or otherwise renam= ing\nthem:\n\n```rust\nuse std::fmt::Write as _;\nuse std::io::Write as _;\= n\nfn main() -> Result<(), Box> {\n let mut s =3D= String::new();\n let mut v =3D Vec::new();\n\n write!(&mut s, \"{} {= }\", \"abc\", 123)?; // uses fmt::Write::write_fmt\n write!(&mut v, \"s = =3D {:?}\", s)?; // uses io::Write::write_fmt\n assert_eq!(v, b\"s =3D \= \\"abc 123\\\"\");\n Ok(())\n}\n```\n\nIf you also need the trait names = themselves, such as to implement one or both on your types,\nimport the con= taining module and then name them with a prefix:\n\n```rust\nuse std::fmt::= {self, Write as _};\nuse std::io::{self, Write as _};\n\nstruct Example;\n\= nimpl fmt::Write for Example {\n fn write_str(&mut self, _s: &str) -> co= re::fmt::Result {\n unimplemented!();\n }\n}\n```\n\nNote: This = macro can be used in `no_std` setups as well.\nIn a `no_std` setup you are = responsible for the implementation details of the components.\n\n```rust\nu= se core::fmt::Write;\n\nstruct Example;\n\nimpl Write for Example {\n fn= write_str(&mut self, _s: &str) -> core::fmt::Result {\n unimplemen= ted!();\n }\n}\n\nlet mut m =3D Example{};\nwrite!(&mut m, \"Hello World= \").expect(\"Not written\");\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "write!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "write!") :additionalTextEdits []) (:label "line!" :kind 3 :detail "macro_rules! line" :documentation (:kind "markdown" :value "Expands to the line number on which it was = invoked.\n\nWith [`column!`] and [`file!`], these macros provide debugging = information for\ndevelopers about the location within the source.\n\nThe ex= panded expression has type `u32` and is 1-based, so the first line\nin each= file evaluates to 1, the second to 2, etc. This is consistent\nwith error = messages by common compilers or popular editors.\nThe returned line is *not= necessarily* the line of the `line!` invocation itself,\nbut rather the fi= rst macro invocation leading up to the invocation\nof the `line!` macro.\n\= n# Examples\n\n```rust\nlet current_line =3D line!();\nprintln!(\"defined o= n line: {current_line}\");\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "line!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "line!") :additionalTextEdits []) (:label "debug_assert!" :kind 3 :detail "macro_rules! debug_assert" :d= ocumentation (:kind "markdown" :value "Asserts that a boolean expression is `true`= at runtime.\n\nThis will invoke the [`panic!`] macro if the provided expre= ssion cannot be\nevaluated to `true` at runtime.\n\nLike [`assert!`], this = macro also has a second version, where a custom panic\nmessage can be provi= ded.\n\n# Uses\n\nUnlike [`assert!`], `debug_assert!` statements are only e= nabled in non\noptimized builds by default. An optimized build will not exe= cute\n`debug_assert!` statements unless `-C debug-assertions` is passed to = the\ncompiler. This makes `debug_assert!` useful for checks that are too\ne= xpensive to be present in a release build but may be helpful during\ndevelo= pment. The result of expanding `debug_assert!` is always type checked.\n\nA= n unchecked assertion allows a program in an inconsistent state to keep\nru= nning, which might have unexpected consequences but does not introduce\nuns= afety as long as this only happens in safe code. The performance cost\nof a= ssertions, however, is not measurable in general. Replacing [`assert!`]\nwi= th `debug_assert!` is thus only encouraged after thorough profiling, and\nm= ore importantly, only in safe code!\n\n# Examples\n\n```rust\n// the panic = message for these assertions is the stringified value of the\n// expression= given.\ndebug_assert!(true);\n\nfn some_expensive_computation() -> bool { = true } // a very simple function\ndebug_assert!(some_expensive_computation(= ));\n\n// assert with a custom message\nlet x =3D true;\ndebug_assert!(x, \= "x wasn't true!\");\n\nlet a =3D 3; let b =3D 27;\ndebug_assert!(a + b =3D= =3D 30, \"a =3D {}, b =3D {}\", a, b);\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "debug_assert!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "debug_assert!") :additionalTextEdits []) (:label "include_bytes!" :kind 3 :detail "macro_rules! include_bytes" = :documentation (:kind "markdown" :value "Includes a file as a reference to a byte ar= ray.\n\nThe file is located relative to the current file (similarly to how\= nmodules are found). The provided path is interpreted in a platform-specifi= c\nway at compile time. So, for instance, an invocation with a Windows path= \ncontaining backslashes `\\` would not compile correctly on Unix.\n\nThis = macro will yield an expression of type `&'static [u8; N]` which is\nthe con= tents of the file.\n\n# Examples\n\nAssume there are two files in the same = directory with the following\ncontents:\n\nFile 'spanish.in':\n\n```text\na= di=C3=B3s\n```\n\nFile 'main.rs':\n\n```rust\nfn main() {\n let bytes = =3D include_bytes!(\"spanish.in\");\n assert_eq!(bytes, b\"adi\\xc3\\xb3= s\\n\");\n print!(\"{}\", String::from_utf8_lossy(bytes));\n}\n```\n\nCo= mpiling 'main.rs' and running the resulting binary will print \"adi=C3=B3s\= ".") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "include_bytes!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "include_bytes!") :additionalTextEdits []) (:label "env!" :kind 3 :detail "macro_rules! env" :documentation (:kind "markdown" :value "Inspects an environment variable at compile= time.\n\nThis macro will expand to the value of the named environment vari= able at\ncompile time, yielding an expression of type `&'static str`. Use\n= [`std::env::var`] instead if you want to read the value at runtime.\n\n[`st= d::env::var`]: ../std/env/fn.var.html\n\nIf the environment variable is not= defined, then a compilation error\nwill be emitted. To not emit a compile = error, use the [`option_env!`]\nmacro instead. A compilation error will als= o be emitted if the\nenvironment variable is not a vaild Unicode string.\n\= n# Examples\n\n```rust\nlet path: &'static str =3D env!(\"PATH\");\nprintln= !(\"the $PATH variable at the time of compiling was: {path}\");\n```\n\nYou= can customize the error message by passing a string as the second\nparamet= er:\n\n```rust\nlet doc: &'static str =3D env!(\"documentation\", \"what's = that?!\");\n```\n\nIf the `documentation` environment variable is not defin= ed, you'll get\nthe following error:\n\n```text\nerror: what's that?!\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "env!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "env!") :additionalTextEdits []) (:label "try!" :kind 3 :detail "macro_rules! r#try" :documentation (:kind "markdown" :value "Unwraps a result or propagates its error.\n= \nThe [`?` operator][propagating-errors] was added to replace `try!`\nand s= hould be used instead. Furthermore, `try` is a reserved word\nin Rust 2018,= so if you must use it, you will need to use the\n[raw-identifier syntax][r= is]: `r#try`.\n\n[propagating-errors]: https://doc.rust-lang.org/book/ch09-= 02-recoverable-errors-with-result.html#a-shortcut-for-propagating-errors-th= e--operator\n[ris]: https://doc.rust-lang.org/nightly/rust-by-example/compa= tibility/raw_identifiers.html\n\n`try!` matches the given [`Result`]. In ca= se of the `Ok` variant, the\nexpression has the value of the wrapped value.= \n\nIn case of the `Err` variant, it retrieves the inner error. `try!` then= \nperforms conversion using `From`. This provides automatic conversion\nbet= ween specialized errors and more general ones. The resulting\nerror is then= immediately returned.\n\nBecause of the early return, `try!` can only be u= sed in functions that\nreturn [`Result`].\n\n# Examples\n\n```rust\nuse std= ::io;\nuse std::fs::File;\nuse std::io::prelude::*;\n\nenum MyError {\n = FileWriteError\n}\n\nimpl From for MyError {\n fn from(e: io:= :Error) -> MyError {\n MyError::FileWriteError\n }\n}\n\n// The p= referred method of quick returning Errors\nfn write_to_file_question() -> R= esult<(), MyError> {\n let mut file =3D File::create(\"my_best_friends.t= xt\")?;\n file.write_all(b\"This is a list of my best friends.\")?;\n = Ok(())\n}\n\n// The previous method of quick returning Errors\nfn write_to= _file_using_try() -> Result<(), MyError> {\n let mut file =3D r#try!(Fil= e::create(\"my_best_friends.txt\"));\n r#try!(file.write_all(b\"This is = a list of my best friends.\"));\n Ok(())\n}\n\n// This is equivalent to:= \nfn write_to_file_using_match() -> Result<(), MyError> {\n let mut file= =3D r#try!(File::create(\"my_best_friends.txt\"));\n match file.write_a= ll(b\"This is a list of my best friends.\") {\n Ok(v) =3D> v,\n = Err(e) =3D> return Err(From::from(e)),\n }\n Ok(())\n}\n```") :deprecated t :preselect t :sortText "ffffffef" :filterText "try!" :t= extEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "r#try!") :additionalTextEdits [] :tags [1]) (:label "file!" :kind 3 :detail "macro_rules! file" :documentation (:kind "markdown" :value "Expands to the file name in which it was in= voked.\n\nWith [`line!`] and [`column!`], these macros provide debugging in= formation for\ndevelopers about the location within the source.\n\nThe expa= nded expression has type `&'static str`, and the returned file\nis not the = invocation of the `file!` macro itself, but rather the\nfirst macro invocat= ion leading up to the invocation of the `file!`\nmacro.\n\n# Examples\n\n``= `rust\nlet this_file =3D file!();\nprintln!(\"defined in file: {this_file}\= ");\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "file!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "file!") :additionalTextEdits []) (:label "thread_local!" :kind 3 :detail "macro_rules! thread_local" :d= ocumentation (:kind "markdown" :value "Declare a new thread local storage key of t= ype [`std::thread::LocalKey`].\n\n# Syntax\n\nThe macro wraps any number of= static declarations and makes them thread local.\nPublicity and attributes= for each static are allowed. Example:\n\n```rust\nuse std::cell::{Cell, Re= fCell};\n\nthread_local! {\n pub static FOO: Cell =3D Cell::new(1);= \n\n static BAR: RefCell> =3D RefCell::new(vec![1.0, 2.0]);\n}\= n\nassert_eq!(FOO.get(), 1);\nBAR.with_borrow(|v| assert_eq!(v[1], 2.0));\n= ```\n\nNote that only shared references (`&T`) to the inner data may be obt= ained, so a\ntype such as [`Cell`] or [`RefCell`] is typically used to allo= w mutating access.\n\nThis macro supports a special `const {}` syntax that = can be used\nwhen the initialization expression can be evaluated as a const= ant.\nThis can enable a more efficient thread local implementation that\nca= n avoid lazy initialization. For types that do not\n[need to be dropped][cr= ate::mem::needs_drop], this can enable an\neven more efficient implementati= on that does not need to\ntrack any additional state.\n\n```rust\nuse std::= cell::RefCell;\n\nthread_local! {\n pub static FOO: RefCell> = =3D const { RefCell::new(Vec::new()) };\n}\n\nFOO.with_borrow(|v| assert_eq= !(v.len(), 0));\n```\n\nSee [`LocalKey` documentation][`std::thread::LocalK= ey`] for more\ninformation.\n\n[`std::thread::LocalKey`]: crate::thread::Lo= calKey") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "thread_local!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "thread_local!") :additionalTextEdits []) (:label "assert!" :kind 3 :detail "macro_rules! assert" :documentation (:kind "markdown" :value "Asserts that a boolean expression is `true`= at runtime.\n\nThis will invoke the [`panic!`] macro if the provided expre= ssion cannot be\nevaluated to `true` at runtime.\n\n# Uses\n\nAssertions ar= e always checked in both debug and release builds, and cannot\nbe disabled.= See [`debug_assert!`] for assertions that are not enabled in\nrelease buil= ds by default.\n\nUnsafe code may rely on `assert!` to enforce run-time inv= ariants that, if\nviolated could lead to unsafety.\n\nOther use-cases of `a= ssert!` include testing and enforcing run-time\ninvariants in safe code (wh= ose violation cannot result in unsafety).\n\n# Custom Messages\n\nThis macr= o has a second form, where a custom panic message can\nbe provided with or = without arguments for formatting. See [`std::fmt`]\nfor syntax for this for= m. Expressions used as format arguments will only\nbe evaluated if the asse= rtion fails.\n\n[`std::fmt`]: ../std/fmt/index.html\n\n# Examples\n\n```rus= t\n// the panic message for these assertions is the stringified value of th= e\n// expression given.\nassert!(true);\n\nfn some_computation() -> bool { = true } // a very simple function\n\nassert!(some_computation());\n\n// asse= rt with a custom message\nlet x =3D true;\nassert!(x, \"x wasn't true!\");\= n\nlet a =3D 3; let b =3D 27;\nassert!(a + b =3D=3D 30, \"a =3D {}, b =3D {= }\", a, b);\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "assert!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "assert!") :additionalTextEdits []) (:label "column!" :kind 3 :detail "macro_rules! column" :documentation (:kind "markdown" :value "Expands to the column number at which it wa= s invoked.\n\nWith [`line!`] and [`file!`], these macros provide debugging = information for\ndevelopers about the location within the source.\n\nThe ex= panded expression has type `u32` and is 1-based, so the first column\nin ea= ch line evaluates to 1, the second to 2, etc. This is consistent\nwith erro= r messages by common compilers or popular editors.\nThe returned column is = *not necessarily* the line of the `column!` invocation itself,\nbut rather = the first macro invocation leading up to the invocation\nof the `column!` m= acro.\n\n# Examples\n\n```rust\nlet current_col =3D column!();\nprintln!(\"= defined on column: {current_col}\");\n```\n\n`column!` counts Unicode code = points, not bytes or graphemes. As a result, the first two\ninvocations ret= urn the same value, but the third does not.\n\n```rust\nlet a =3D (\"foobar= \", column!()).1;\nlet b =3D (\"=E4=BA=BA=E4=B9=8B=E5=88=9D=E6=80=A7=E6=9C= =AC=E5=96=84\", column!()).1;\nlet c =3D (\"f=CC=85o=CC=85o=CC=85b=CC=85a= =CC=85r=CC=85\", column!()).1; // Uses combining overline (U+0305)\n\nasser= t_eq!(a, b);\nassert_ne!(b, c);\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "column!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "column!") :additionalTextEdits []) (:label "unreachable!" :kind 3 :detail "macro_rules! unreachable" :doc= umentation (:kind "markdown" :value "Indicates unreachable code.\n\nThis is usef= ul any time that the compiler can't determine that some code is unreachable= . For\nexample:\n\n* Match arms with guard conditions.\n* Loops that dynami= cally terminate.\n* Iterators that dynamically terminate.\n\nIf the determi= nation that the code is unreachable proves incorrect, the\nprogram immediat= ely terminates with a [`panic!`].\n\nThe unsafe counterpart of this macro i= s the [`unreachable_unchecked`] function, which\nwill cause undefined behav= ior if the code is reached.\n\n[`unreachable_unchecked`]: crate::hint::unre= achable_unchecked\n\n# Panics\n\nThis will always [`panic!`] because `unrea= chable!` is just a shorthand for `panic!` with a\nfixed, specific message.\= n\nLike `panic!`, this macro has a second form for displaying custom values= .\n\n# Examples\n\nMatch arms:\n\n```rust\nfn foo(x: Option) {\n ma= tch x {\n Some(n) if n >=3D 0 =3D> println!(\"Some(Non-negative)\"),= \n Some(n) if n < 0 =3D> println!(\"Some(Negative)\"),\n Som= e(_) =3D> unreachable!(), // compile error if commented out\n = None =3D> println!(\"None\")\n }\n}\n```\n\nIterators:\= n\n```rust\nfn divide_by_three(x: u32) -> u32 { // one of the poorest imple= mentations of x/3\n for i in 0.. {\n if 3*i < i { panic!(\"u32 ov= erflow\"); }\n if x < 3*i { return i-1; }\n }\n unreachable!(\= "The loop should always return\");\n}\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "unreachable!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "unreachable!") :additionalTextEdits []) (:label "eprintln!" :kind 3 :detail "macro_rules! eprintln" :documenta= tion (:kind "markdown" :value "Prints to the standard error, with a newlin= e.\n\nEquivalent to the [`println!`] macro, except that output goes to\n[`i= o::stderr`] instead of [`io::stdout`]. See [`println!`] for\nexample usage.= \n\nUse `eprintln!` only for error and progress messages. Use `println!`\ni= nstead for the primary output of your program.\n\nSee [the formatting docum= entation in `std::fmt`](../std/fmt/index.html)\nfor details of the macro ar= gument syntax.\n\n[`io::stderr`]: crate::io::stderr\n[`io::stdout`]: crate:= :io::stdout\n[`println!`]: crate::println\n\n# Panics\n\nPanics if writing = to `io::stderr` fails.\n\nWriting to non-blocking stderr can cause an error= , which will lead\nthis macro to panic.\n\n# Examples\n\n```rust\neprintln!= (\"Error: Could not complete task\");\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "eprintln!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "eprintln!") :additionalTextEdits []) (:label "unimplemented!" :kind 3 :detail "macro_rules! unimplemented" = :documentation (:kind "markdown" :value "Indicates unimplemented code by panicking w= ith a message of \"not implemented\".\n\nThis allows your code to type-chec= k, which is useful if you are prototyping or\nimplementing a trait that req= uires multiple methods which you don't plan to use all of.\n\nThe differenc= e between `unimplemented!` and [`todo!`] is that while `todo!`\nconveys an = intent of implementing the functionality later and the message is \"not yet= \nimplemented\", `unimplemented!` makes no such claims. Its message is \"no= t implemented\".\n\nAlso, some IDEs will mark `todo!`s.\n\n# Panics\n\nThis= will always [`panic!`] because `unimplemented!` is just a shorthand for `p= anic!` with a\nfixed, specific message.\n\nLike `panic!`, this macro has a = second form for displaying custom values.\n\n[`todo!`]: crate::todo\n\n# Ex= amples\n\nSay we have a trait `Foo`:\n\n```rust\ntrait Foo {\n fn bar(&s= elf) -> u8;\n fn baz(&self);\n fn qux(&self) -> Result;\n}\n= ```\n\nWe want to implement `Foo` for 'MyStruct', but for some reason it on= ly makes sense\nto implement the `bar()` function. `baz()` and `qux()` will= still need to be defined\nin our implementation of `Foo`, but we can use `= unimplemented!` in their definitions\nto allow our code to compile.\n\nWe s= till want to have our program stop running if the unimplemented methods are= \nreached.\n\n```rust\nstruct MyStruct;\n\nimpl Foo for MyStruct {\n fn = bar(&self) -> u8 {\n 1 + 1\n }\n\n fn baz(&self) {\n //= It makes no sense to `baz` a `MyStruct`, so we have no logic here\n = // at all.\n // This will display \"thread 'main' panicked at 'not = implemented'\".\n unimplemented!();\n }\n\n fn qux(&self) -> R= esult {\n // We have some logic here,\n // We can ad= d a message to unimplemented! to display our omission.\n // This wil= l display:\n // \"thread 'main' panicked at 'not implemented: MyStru= ct isn't quxable'\".\n unimplemented!(\"MyStruct isn't quxable\");\n= }\n}\n\nfn main() {\n let s =3D MyStruct;\n s.bar();\n}\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "unimplemented!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "unimplemented!") :additionalTextEdits []) (:label "cfg!" :kind 3 :detail "macro_rules! cfg" :documentation (:kind "markdown" :value "Evaluates boolean combinations of configura= tion flags at compile-time.\n\nIn addition to the `#[cfg]` attribute, this = macro is provided to allow\nboolean expression evaluation of configuration = flags. This frequently\nleads to less duplicated code.\n\nThe syntax given = to this macro is the same syntax as the [`cfg`]\nattribute.\n\n`cfg!`, unli= ke `#[cfg]`, does not remove any code and only evaluates to true or false. = For\nexample, all blocks in an if/else expression need to be valid when `cf= g!` is used for\nthe condition, regardless of what `cfg!` is evaluating.\n\= n[`cfg`]: ../reference/conditional-compilation.html#the-cfg-attribute\n\n# = Examples\n\n```rust\nlet my_directory =3D if cfg!(windows) {\n \"windows= -specific-directory\"\n} else {\n \"unix-directory\"\n};\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "cfg!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "cfg!") :additionalTextEdits []) (:label "todo!" :kind 3 :detail "macro_rules! todo" :documentation (:kind "markdown" :value "Indicates unfinished code.\n\nThis can be u= seful if you are prototyping and just\nwant a placeholder to let your code = pass type analysis.\n\nThe difference between [`unimplemented!`] and `todo!= ` is that while `todo!` conveys\nan intent of implementing the functionalit= y later and the message is \"not yet\nimplemented\", `unimplemented!` makes= no such claims. Its message is \"not implemented\".\n\nAlso, some IDEs wil= l mark `todo!`s.\n\n# Panics\n\nThis will always [`panic!`] because `todo!`= is just a shorthand for `panic!` with a\nfixed, specific message.\n\nLike = `panic!`, this macro has a second form for displaying custom values.\n\n# E= xamples\n\nHere's an example of some in-progress code. We have a trait `Foo= `:\n\n```rust\ntrait Foo {\n fn bar(&self) -> u8;\n fn baz(&self);\n = fn qux(&self) -> Result;\n}\n```\n\nWe want to implement `Foo` = on one of our types, but we also want to work on\njust `bar()` first. In or= der for our code to compile, we need to implement\n`baz()` and `qux()`, so = we can use `todo!`:\n\n```rust\nstruct MyStruct;\n\nimpl Foo for MyStruct {= \n fn bar(&self) -> u8 {\n 1 + 1\n }\n\n fn baz(&self) {\n = // Let's not worry about implementing baz() for now\n todo!()= ;\n }\n\n fn qux(&self) -> Result {\n // We can add a= message to todo! to display our omission.\n // This will display:\n= // \"thread 'main' panicked at 'not yet implemented: MyStruct is no= t yet quxable'\".\n todo!(\"MyStruct is not yet quxable\");\n }\n= }\n\nfn main() {\n let s =3D MyStruct;\n s.bar();\n\n // We aren't= even using baz() or qux(), so this is fine.\n}\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "todo!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "todo!") :additionalTextEdits []) (:label "module_path!" :kind 3 :detail "macro_rules! module_path" :doc= umentation (:kind "markdown" :value "Expands to a string that represents the cur= rent module path.\n\nThe current module path can be thought of as the hiera= rchy of modules\nleading back up to the crate root. The first component of = the path\nreturned is the name of the crate currently being compiled.\n\n# = Examples\n\n```rust\nmod test {\n pub fn foo() {\n assert!(module= _path!().ends_with(\"test\"));\n }\n}\n\ntest::foo();\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "module_path!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "module_path!") :additionalTextEdits []) (:label "option_env!" :kind 3 :detail "macro_rules! option_env" :docum= entation (:kind "markdown" :value "Optionally inspects an environment variable= at compile time.\n\nIf the named environment variable is present at compil= e time, this will\nexpand into an expression of type `Option<&'static str>`= whose value is\n`Some` of the value of the environment variable. If the en= vironment\nvariable is not present, then this will expand to `None`. See\n[= `Option`][Option] for more information on this type. Use\n[`std::env::v= ar`] instead if you want to read the value at runtime.\n\n[`std::env::var`]= : ../std/env/fn.var.html\n\nA compile time error is never emitted when usin= g this macro regardless\nof whether the environment variable is present or = not.\nTo emit a compile error if the environment variable is not present,\n= use the [`env!`] macro instead.\n\n# Examples\n\n```rust\nlet key: Option<&= 'static str> =3D option_env!(\"SECRET_KEY\");\nprintln!(\"the secret key mi= ght be: {key:?}\");\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "option_env!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "option_env!") :additionalTextEdits []) (:label "writeln!" :kind 3 :detail "macro_rules! writeln" :documentati= on (:kind "markdown" :value "Write formatted data into a buffer, with a = newline appended.\n\nOn all platforms, the newline is the LINE FEED charact= er (`\\n`/`U+000A`) alone\n(no additional CARRIAGE RETURN (`\\r`/`U+000D`).= \n\nFor more information, see [`write!`]. For information on the format str= ing syntax, see\n[`std::fmt`].\n\n[`std::fmt`]: ../std/fmt/index.html\n\n# = Examples\n\n```rust\nuse std::io::{Write, Result};\n\nfn main() -> Result<(= )> {\n let mut w =3D Vec::new();\n writeln!(&mut w)?;\n writeln!(&= mut w, \"test\")?;\n writeln!(&mut w, \"formatted {}\", \"arguments\")?;= \n\n assert_eq!(&w[..], \"\\ntest\\nformatted arguments\\n\".as_bytes())= ;\n Ok(())\n}\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "writeln!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "writeln!") :additionalTextEdits []) (:label "assert_eq!" :kind 3 :detail "macro_rules! assert_eq" :documen= tation (:kind "markdown" :value "Asserts that two expressions are equal to e= ach other (using [`PartialEq`]).\n\nOn panic, this macro will print the val= ues of the expressions with their\ndebug representations.\n\nLike [`assert!= `], this macro has a second form, where a custom\npanic message can be prov= ided.\n\n# Examples\n\n```rust\nlet a =3D 3;\nlet b =3D 1 + 2;\nassert_eq!(= a, b);\n\nassert_eq!(a, b, \"we are testing addition with {} and {}\", a, b= );\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "assert_eq!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "assert_eq!") :additionalTextEdits []) (:label "compile_error!" :kind 3 :detail "macro_rules! compile_error" = :documentation (:kind "markdown" :value "Causes compilation to fail with the given e= rror message when encountered.\n\nThis macro should be used when a crate us= es a conditional compilation strategy to provide\nbetter error messages for= erroneous conditions. It's the compiler-level form of [`panic!`],\nbut emi= ts an error during *compilation* rather than at *runtime*.\n\n# Examples\n\= nTwo such examples are macros and `#[cfg]` environments.\n\nEmit a better c= ompiler error if a macro is passed invalid values. Without the final branch= ,\nthe compiler would still emit an error, but the error's message would no= t mention the two\nvalid values.\n\n```rust\nmacro_rules! give_me_foo_or_ba= r {\n (foo) =3D> {};\n (bar) =3D> {};\n ($x:ident) =3D> {\n = compile_error!(\"This macro only accepts `foo` or `bar`\");\n }\n}\n\ng= ive_me_foo_or_bar!(neither);\n// ^ will fail at compile time with message \= "This macro only accepts `foo` or `bar`\"\n```\n\nEmit a compiler error if = one of a number of features isn't available.\n\n```rust\n#[cfg(not(any(feat= ure =3D \"foo\", feature =3D \"bar\")))]\ncompile_error!(\"Either feature \= \\"foo\\\" or \\\"bar\\\" must be enabled for this crate.\");\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "compile_error!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "compile_error!") :additionalTextEdits []) (:label "matches!" :kind 3 :detail "macro_rules! matches" :documentati= on (:kind "markdown" :value "Returns whether the given expression matche= s the provided pattern.\n\nThe pattern syntax is exactly the same as found = in a match arm. The optional if guard can be\nused to add additional checks= that must be true for the matched value, otherwise this macro will\nreturn= `false`.\n\nWhen testing that a value matches a pattern, it's generally pr= eferable to use\n[`assert_matches!`] as it will print the debug representat= ion of the value if the assertion\nfails.\n\n# Examples\n\n```rust\nlet foo= =3D 'f';\nassert!(matches!(foo, 'A'..=3D'Z' | 'a'..=3D'z'));\n\nlet bar = =3D Some(4);\nassert!(matches!(bar, Some(x) if x > 2));\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "matches!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "matches!") :additionalTextEdits []) (:label "format_args!" :kind 3 :detail "macro_rules! format_args" :doc= umentation (:kind "markdown" :value "Constructs parameters for the other string-= formatting macros.\n\nThis macro functions by taking a formatting string li= teral containing\n`{}` for each additional argument passed. `format_args!` = prepares the\nadditional parameters to ensure the output can be interpreted= as a string\nand canonicalizes the arguments into a single type. Any value= that implements\nthe [`Display`] trait can be passed to `format_args!`, as= can any\n[`Debug`] implementation be passed to a `{:?}` within the formatt= ing string.\n\nThis macro produces a value of type [`fmt::Arguments`]. This= value can be\npassed to the macros within [`std::fmt`] for performing usef= ul redirection.\nAll other formatting macros ([`format!`], [`write!`], [`pr= intln!`], etc) are\nproxied through this one. `format_args!`, unlike its de= rived macros, avoids\nheap allocations.\n\nYou can use the [`fmt::Arguments= `] value that `format_args!` returns\nin `Debug` and `Display` contexts as = seen below. The example also shows\nthat `Debug` and `Display` format to th= e same thing: the interpolated\nformat string in `format_args!`.\n\n```rust= \nlet debug =3D format!(\"{:?}\", format_args!(\"{} foo {:?}\", 1, 2));\nle= t display =3D format!(\"{}\", format_args!(\"{} foo {:?}\", 1, 2));\nassert= _eq!(\"1 foo 2\", display);\nassert_eq!(display, debug);\n```\n\nSee [the f= ormatting documentation in `std::fmt`](../std/fmt/index.html)\nfor details = of the macro argument syntax, and further information.\n\n[`Display`]: crat= e::fmt::Display\n[`Debug`]: crate::fmt::Debug\n[`fmt::Arguments`]: crate::f= mt::Arguments\n[`std::fmt`]: ../std/fmt/index.html\n[`format!`]: ../std/mac= ro.format.html\n[`println!`]: ../std/macro.println.html\n\n# Examples\n\n``= `rust\nuse std::fmt;\n\nlet s =3D fmt::format(format_args!(\"hello {}\", \"= world\"));\nassert_eq!(s, format!(\"hello {}\", \"world\"));\n```\n\n# Life= time limitation\n\nExcept when no formatting arguments are used,\nthe produ= ced `fmt::Arguments` value borrows temporary values,\nwhich means it can on= ly be used within the same expression\nand cannot be stored for later use.\= nThis is a known limitation, see [#92698](https://github.com/rust-lang/rust= /issues/92698).") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "format_args!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "format_args!") :additionalTextEdits []) (:label "is_x86_feature_detected!" :kind 3 :detail "macro_rules! is_x8= 6_feature_detected" :documentation (:kind "markdown" :value "A macro to test at *runtime* whether a CPU = feature is available on\nx86/x86-64 platforms.\n\nThis macro is provided in= the standard library and will detect at runtime\nwhether the specified CPU= feature is detected. This does **not** resolve at\ncompile time unless the= specified feature is already enabled for the entire\ncrate. Runtime detect= ion currently relies mostly on the `cpuid` instruction.\n\nThis macro only = takes one argument which is a string literal of the feature\nbeing tested f= or. The feature names supported are the lowercase versions of\nthe ones def= ined by Intel in [their documentation][docs].\n\n## Supported arguments\n\n= This macro supports the same names that `#[target_feature]` supports. Unlik= e\n`#[target_feature]`, however, this macro does not support names separate= d\nwith a comma. Instead testing for multiple features must be done through= \nseparate macro invocations for now.\n\nSupported arguments are:\n\n* `\"a= es\"`\n* `\"pclmulqdq\"`\n* `\"rdrand\"`\n* `\"rdseed\"`\n* `\"tsc\"`\n* `\= "mmx\"`\n* `\"sse\"`\n* `\"sse2\"`\n* `\"sse3\"`\n* `\"ssse3\"`\n* `\"sse4.= 1\"`\n* `\"sse4.2\"`\n* `\"sse4a\"`\n* `\"sha\"`\n* `\"avx\"`\n* `\"avx2\"`= \n* `\"avx512f\"`\n* `\"avx512cd\"`\n* `\"avx512er\"`\n* `\"avx512pf\"`\n* = `\"avx512bw\"`\n* `\"avx512dq\"`\n* `\"avx512vl\"`\n* `\"avx512ifma\"`\n* `= \"avx512vbmi\"`\n* `\"avx512vpopcntdq\"`\n* `\"avx512vbmi2\"`\n* `\"gfni\"`= \n* `\"vaes\"`\n* `\"vpclmulqdq\"`\n* `\"avx512vnni\"`\n* `\"avx512bitalg\"= `\n* `\"avx512bf16\"`\n* `\"avx512vp2intersect\"`\n* `\"avx512fp16\"`\n* `\= "f16c\"`\n* `\"fma\"`\n* `\"bmi1\"`\n* `\"bmi2\"`\n* `\"abm\"`\n* `\"lzcnt\= "`\n* `\"tbm\"`\n* `\"popcnt\"`\n* `\"fxsr\"`\n* `\"xsave\"`\n* `\"xsaveopt= \"`\n* `\"xsaves\"`\n* `\"xsavec\"`\n* `\"cmpxchg16b\"`\n* `\"adx\"`\n* `\"= rtm\"`\n* `\"movbe\"`\n* `\"ermsb\"`\n\n[docs]: https://software.intel.com/= sites/landingpage/IntrinsicsGuide") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "is_x86_feature_detected!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "is_x86_feature_detected!") :additionalTextEdits []) (:label "eprint!" :kind 3 :detail "macro_rules! eprint" :documentation (:kind "markdown" :value "Prints to the standard error.\n\nEquivalent= to the [`print!`] macro, except that output goes to\n[`io::stderr`] instea= d of [`io::stdout`]. See [`print!`] for\nexample usage.\n\nUse `eprint!` on= ly for error and progress messages. Use `print!`\ninstead for the primary o= utput of your program.\n\n[`io::stderr`]: crate::io::stderr\n[`io::stdout`]= : crate::io::stdout\n\nSee [the formatting documentation in `std::fmt`](../= std/fmt/index.html)\nfor details of the macro argument syntax.\n\n# Panics\= n\nPanics if writing to `io::stderr` fails.\n\nWriting to non-blocking stde= rr can cause an error, which will lead\nthis macro to panic.\n\n# Examples\= n\n```rust\neprint!(\"Error: Could not complete task\");\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "eprint!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "eprint!") :additionalTextEdits []) (:label "debug_assert_ne!" :kind 3 :detail "macro_rules! debug_assert_= ne" :documentation (:kind "markdown" :value "Asserts that two expressions are not equal = to each other.\n\nOn panic, this macro will print the values of the express= ions with their\ndebug representations.\n\nUnlike [`assert_ne!`], `debug_as= sert_ne!` statements are only enabled in non\noptimized builds by default. = An optimized build will not execute\n`debug_assert_ne!` statements unless `= -C debug-assertions` is passed to the\ncompiler. This makes `debug_assert_n= e!` useful for checks that are too\nexpensive to be present in a release bu= ild but may be helpful during\ndevelopment. The result of expanding `debug_= assert_ne!` is always type checked.\n\n# Examples\n\n```rust\nlet a =3D 3;\= nlet b =3D 2;\ndebug_assert_ne!(a, b);\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "debug_assert_ne!" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "debug_assert_ne!") :additionalTextEdits []) (:label "std" :kind 9 :documentation (:kind "markdown" :value "# The Rust Standard Library\n\nThe Rust Sta= ndard Library is the foundation of portable Rust software, a\nset of minima= l and battle-tested shared abstractions for the [broader Rust\necosystem][c= rates.io]. It offers core types, like [`Vec`] and\n[`Option`], librar= y-defined [operations on language\nprimitives](#primitives), [standard macr= os](#macros), [I/O] and\n[multithreading], among [many other things][other]= .\n\n`std` is available to all Rust crates by default. Therefore, the\nstan= dard library can be accessed in [`use`] statements through the path\n`std`,= as in [`use std::env`].\n\n# How to read this documentation\n\nIf you alre= ady know the name of what you are looking for, the fastest way to\nfind it = is to use the sea= rch\nbar at the top of the page.\n\nOtherwise, you may want to jump to = one of these useful sections:\n\n* [`std::*` modules](#modules)\n* [Primiti= ve types](#primitives)\n* [Standard macros](#macros)\n* [The Rust Prelude]\= n\nIf this is your first time, the documentation for the standard library i= s\nwritten to be casually perused. Clicking on interesting things should\ng= enerally lead you to interesting places. Still, there are important bits\ny= ou don't want to miss, so read on for a tour of the standard library and\ni= ts documentation!\n\nOnce you are familiar with the contents of the standar= d library you may\nbegin to find the verbosity of the prose distracting. At= this stage in your\ndevelopment you may want to press the `[-]` button nea= r the top of the\npage to collapse it into a more skimmable view.\n\nWhile = you are looking at that `[-]` button also notice the `source`\nlink. Rust's= API documentation comes with the source code and you are\nencouraged to re= ad it. The standard library source is generally high\nquality and a peek be= hind the curtains is often enlightening.\n\n# What is in the standard libra= ry documentation?\n\nFirst of all, The Rust Standard Library is divided int= o a number of focused\nmodules, [all listed further down this page](#module= s). These modules are\nthe bedrock upon which all of Rust is forged, and th= ey have mighty names\nlike [`std::slice`] and [`std::cmp`]. Modules' docume= ntation typically\nincludes an overview of the module along with examples, = and are a smart\nplace to start familiarizing yourself with the library.\n\= nSecond, implicit methods on [primitive types] are documented here. This ca= n\nbe a source of confusion for two reasons:\n\n1. While primitives are imp= lemented by the compiler, the standard library\n implements methods direc= tly on the primitive types (and it is the only\n library that does so), w= hich are [documented in the section on\n primitives](#primitives).\n2. Th= e standard library exports many modules *with the same name as\n primitiv= e types*. These define additional items related to the primitive\n type, = but not the all-important methods.\n\nSo for example there is a [page for t= he primitive type\n`i32`](primitive::i32) that lists all the methods that c= an be called on\n32-bit integers (very useful), and there is a [page for th= e module\n`std::i32`] that documents the constant values [`MIN`] and [`MAX`= ] (rarely\nuseful).\n\nNote the documentation for the primitives [`str`] an= d [`[T]`][prim@slice] (also\ncalled 'slice'). Many method calls on [`String= `] and [`Vec`] are actually\ncalls to methods on [`str`] and [`[T]`][pri= m@slice] respectively, via [deref\ncoercions][deref-coercions].\n\nThird, t= he standard library defines [The Rust Prelude], a small collection\nof item= s - mostly traits - that are imported into every module of every\ncrate. Th= e traits in the prelude are pervasive, making the prelude\ndocumentation a = good entry point to learning about the library.\n\nAnd finally, the standar= d library exports a number of standard macros, and\n[lists them on this pag= e](#macros) (technically, not all of the standard\nmacros are defined by th= e standard library - some are defined by the\ncompiler - but they are docum= ented here the same). Like the prelude, the\nstandard macros are imported b= y default into all crates.\n\n# Contributing changes to the documentation\n= \nCheck out the Rust contribution guidelines [here](\nhttps://rustc-dev-gui= de.rust-lang.org/contributing.html#writing-documentation).\nThe source for = this documentation can be found on\n[GitHub](https://github.com/rust-lang/r= ust).\nTo contribute changes, make sure you read the guidelines first, then= submit\npull-requests for your suggested changes.\n\nContributions are app= reciated! If you see a part of the docs that can be\nimproved, submit a PR,= or chat with us first on [Discord][rust-discord]\n#docs.\n\n# A Tour of Th= e Rust Standard Library\n\nThe rest of this crate documentation is dedicate= d to pointing out notable\nfeatures of The Rust Standard Library.\n\n## Con= tainers and collections\n\nThe [`option`] and [`result`] modules define opt= ional and error-handling\ntypes, [`Option`] and [`Result`]. The [`= iter`] module defines\nRust's iterator trait, [`Iterator`], which works wit= h the [`for`] loop to\naccess collections.\n\nThe standard library exposes = three common ways to deal with contiguous\nregions of memory:\n\n* [`Vec= `] - A heap-allocated *vector* that is resizable at runtime.\n* [`[T; N]`][= prim@array] - An inline *array* with a fixed size at compile time.\n* [`[T]= `][prim@slice] - A dynamically sized *slice* into any other kind of contigu= ous\n storage, whether heap-allocated or not.\n\nSlices can only be handle= d through some kind of *pointer*, and as such come\nin many flavors such as= :\n\n* `&[T]` - *shared slice*\n* `&mut [T]` - *mutable slice*\n* [`Box<[T]= >`][owned slice] - *owned slice*\n\n[`str`], a UTF-8 string slice, is a pri= mitive type, and the standard library\ndefines many methods for it. Rust [`= str`]s are typically accessed as\nimmutable references: `&str`. Use the own= ed [`String`] for building and\nmutating strings.\n\nFor converting to stri= ngs use the [`format!`] macro, and for converting from\nstrings use the [`F= romStr`] trait.\n\nData may be shared by placing it in a reference-counted = box or the [`Rc`]\ntype, and if further contained in a [`Cell`] or [`RefCel= l`], may be mutated\nas well as shared. Likewise, in a concurrent setting i= t is common to pair an\natomically-reference-counted box, [`Arc`], with a [= `Mutex`] to get the same\neffect.\n\nThe [`collections`] module defines map= s, sets, linked lists and other\ntypical collection types, including the co= mmon [`HashMap`].\n\n## Platform abstractions and I/O\n\nBesides basi= c data types, the standard library is largely concerned with\nabstracting o= ver differences in common platforms, most notably Windows and\nUnix derivat= ives.\n\nCommon types of I/O, including [files], [TCP], and [UDP], are defi= ned in\nthe [`io`], [`fs`], and [`net`] modules.\n\nThe [`thread`] module c= ontains Rust's threading abstractions. [`sync`]\ncontains further primitive= shared memory types, including [`atomic`] and\n[`mpsc`], which contains th= e channel types for message passing.\n\n# Use before and after `main()`\n\n= Many parts of the standard library are expected to work before and after `m= ain()`;\nbut this is not guaranteed or ensured by tests. It is recommended = that you write your own tests\nand run them on each platform you wish to su= pport.\nThis means that use of `std` before/after main, especially of featu= res that interact with the\nOS or global state, is exempted from stability = and portability guarantees and instead only\nprovided on a best-effort basi= s. Nevertheless bug reports are appreciated.\n\nOn the other hand `core` an= d `alloc` are most likely to work in such environments with\nthe caveat tha= t any hookable behavior such as panics, oom handling or allocators will als= o\ndepend on the compatibility of the hooks.\n\nSome features may also beha= ve differently outside main, e.g. stdio could become unbuffered,\nsome pani= cs might turn into aborts, backtraces might not get symbolicated or similar= .\n\nNon-exhaustive list of known limitations:\n\n- after-main use of threa= d-locals, which also affects additional features:\n - [`thread::current()`= ]\n - [`thread::scope()`]\n - [`sync::mpsc`]\n- before-main stdio file de= scriptors are not guaranteed to be open on unix platforms\n\n\n[I/O]: io\n[= `MIN`]: i32::MIN\n[`MAX`]: i32::MAX\n[page for the module `std::i32`]: crat= e::i32\n[TCP]: net::TcpStream\n[The Rust Prelude]: prelude\n[UDP]: net::Udp= Socket\n[`Arc`]: sync::Arc\n[owned slice]: boxed\n[`Cell`]: cell::Cell\n[`F= romStr`]: str::FromStr\n[`HashMap`]: collections::HashMap\n[`Mutex`]:= sync::Mutex\n[`Option`]: option::Option\n[`Rc`]: rc::Rc\n[`RefCell`]: c= ell::RefCell\n[`Result`]: result::Result\n[`Vec`]: vec::Vec\n[`ato= mic`]: sync::atomic\n[`for`]: ../book/ch03-05-control-flow.html#looping-thr= ough-a-collection-with-for\n[`str`]: prim@str\n[`mpsc`]: sync::mpsc\n[`std:= :cmp`]: cmp\n[`std::slice`]: mod@slice\n[`use std::env`]: env/index.html\n[= `use`]: ../book/ch07-02-defining-modules-to-control-scope-and-privacy.html\= n[crates.io]: https://crates.io\n[deref-coercions]: ../book/ch15-02-deref.h= tml#implicit-deref-coercions-with-functions-and-methods\n[files]: fs::File\= n[multithreading]: thread\n[other]: #what-is-in-the-standard-library-docume= ntation\n[primitive types]: ../book/ch03-02-data-types.html\n[rust-discord]= : https://discord.gg/rust-lang\n[array]: prim@array\n[slice]: prim@slice") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "std" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "std") :additionalTextEdits []) (:label "core" :kind 9 :documentation (:kind "markdown" :value "# The Rust Core Library\n\nThe Rust Core Li= brary is the dependency-free[^free] foundation of [The\nRust Standard Libra= ry](../std/index.html). It is the portable glue\nbetween the language and i= ts libraries, defining the intrinsic and\nprimitive building blocks of all = Rust code. It links to no\nupstream libraries, no system libraries, and no = libc.\n\n[^free]: Strictly speaking, there are some symbols which are neede= d but\n they aren't always necessary.\n\nThe core library is *minim= al*: it isn't even aware of heap allocation,\nnor does it provide concurren= cy or I/O. These things require\nplatform integration, and this library is = platform-agnostic.\n\n# How to use the core library\n\nPlease note that all= of these details are currently not considered stable.\n\nThis library is b= uilt on the assumption of a few existing symbols:\n\n* `memcpy`, `memmove`,= `memset`, `memcmp`, `bcmp`, `strlen` - These are core memory routines\n w= hich are generated by Rust codegen backends. Additionally, this library can= make explicit\n calls to `strlen`. Their signatures are the same as found= in C, but there are extra\n assumptions about their semantics: For `memcp= y`, `memmove`, `memset`, `memcmp`, and `bcmp`, if\n the `n` parameter is 0= , the function is assumed to not be UB, even if the pointers are NULL or\n = dangling. (Note that making extra assumptions about these functions is com= mon among compilers:\n [clang](https://reviews.llvm.org/D86993) and [GCC](= https://gcc.gnu.org/onlinedocs/gcc/Standards.html#C-Language) do the same.)= \n These functions are often provided by the system libc, but can also be = provided by the\n [compiler-builtins crate](https://crates.io/crates/compi= ler_builtins).\n Note that the library does not guarantee that it will alw= ays make these assumptions, so Rust\n user code directly calling the C fun= ctions should follow the C specification! The advice for\n Rust user code = is to call the functions provided by this library instead (such as\n `ptr:= :copy`).\n\n* Panic handler - This function takes one argument, a `&panic::= PanicInfo`. It is up to consumers of this core\n library to define this pa= nic function; it is only required to never\n return. You should mark your = implementation using `#[panic_handler]`.\n\n* `rust_eh_personality` - is us= ed by the failure mechanisms of the\n compiler. This is often mapped to G= CC's personality function, but crates\n which do not trigger a panic can = be assured that this function is never\n called. The `lang` attribute is = called `eh_personality`.") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "core" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "core") :additionalTextEdits []) (:label "u32" :kind 22 :detail "u32" :deprecated :json-false :preselec= t t :sortText "ffffffef" :filterText "u32" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "u32") :additionalTextEdits []) (:label "bool" :kind 22 :detail "bool" :deprecated :json-false :presel= ect t :sortText "ffffffef" :filterText "bool" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "bool") :additionalTextEdits []) (:label "u8" :kind 22 :detail "u8" :deprecated :json-false :preselect = t :sortText "ffffffef" :filterText "u8" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "u8") :additionalTextEdits []) (:label "isize" :kind 22 :detail "isize" :deprecated :json-false :pres= elect t :sortText "ffffffef" :filterText "isize" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "isize") :additionalTextEdits []) (:label "u16" :kind 22 :detail "u16" :deprecated :json-false :preselec= t t :sortText "ffffffef" :filterText "u16" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "u16") :additionalTextEdits []) (:label "u64" :kind 22 :detail "u64" :deprecated :json-false :preselec= t t :sortText "ffffffef" :filterText "u64" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "u64") :additionalTextEdits []) (:label "u128" :kind 22 :detail "u128" :deprecated :json-false :presel= ect t :sortText "ffffffef" :filterText "u128" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "u128") :additionalTextEdits []) (:label "f32" :kind 22 :detail "f32" :deprecated :json-false :preselec= t t :sortText "ffffffef" :filterText "f32" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "f32") :additionalTextEdits []) (:label "i128" :kind 22 :detail "i128" :deprecated :json-false :presel= ect t :sortText "ffffffef" :filterText "i128" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "i128") :additionalTextEdits []) (:label "i16" :kind 22 :detail "i16" :deprecated :json-false :preselec= t t :sortText "ffffffef" :filterText "i16" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "i16") :additionalTextEdits []) (:label "str" :kind 22 :detail "str" :deprecated :json-false :preselec= t t :sortText "ffffffef" :filterText "str" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "str") :additionalTextEdits []) (:label "i64" :kind 22 :detail "i64" :deprecated :json-false :preselec= t t :sortText "ffffffef" :filterText "i64" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "i64") :additionalTextEdits []) (:label "char" :kind 22 :detail "char" :deprecated :json-false :presel= ect t :sortText "ffffffef" :filterText "char" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "char") :additionalTextEdits []) (:label "f128" :kind 22 :detail "f128" :deprecated :json-false :presel= ect t :sortText "ffffffef" :filterText "f128" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "f128") :additionalTextEdits []) (:label "f64" :kind 22 :detail "f64" :deprecated :json-false :preselec= t t :sortText "ffffffef" :filterText "f64" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "f64") :additionalTextEdits []) (:label "f16" :kind 22 :detail "f16" :deprecated :json-false :preselec= t t :sortText "ffffffef" :filterText "f16" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "f16") :additionalTextEdits []) (:label "i32" :kind 22 :detail "i32" :deprecated :json-false :preselec= t t :sortText "ffffffef" :filterText "i32" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "i32") :additionalTextEdits []) (:label "i8" :kind 22 :detail "i8" :deprecated :json-false :preselect = t :sortText "ffffffef" :filterText "i8" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "i8") :additionalTextEdits []) (:label "usize" :kind 22 :detail "usize" :deprecated :json-false :pres= elect t :sortText "ffffffef" :filterText "usize" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "usize") :additionalTextEdits []) (:label "AsMut" :kind 8 :documentation (:kind "markdown" :value "Used to do a cheap mutable-to-mutable refer= ence conversion.\n\nThis trait is similar to [`AsRef`] but used for convert= ing between mutable\nreferences. If you need to do a costly conversion it i= s better to\nimplement [`From`] with type `&mut T` or write a custom functi= on.\n\n**Note: This trait must not fail**. If the conversion can fail, use = a\ndedicated method which returns an [`Option`] or a [`Result`].\n= \n# Generic Implementations\n\n`AsMut` auto-dereferences if the inner type = is a mutable reference\n(e.g.: `foo.as_mut()` will work the same if `foo` h= as type `&mut Foo` or `&mut &mut Foo`).\n\nNote that due to historic reason= s, the above currently does not hold generally for all\n[mutably dereferenc= eable types], e.g. `foo.as_mut()` will *not* work the same as\n`Box::new(fo= o).as_mut()`. Instead, many smart pointers provide an `as_mut` implementati= on which\nsimply returns a reference to the [pointed-to value] (but do not = perform a cheap\nreference-to-reference conversion for that value). However= , [`AsMut::as_mut`] should not be\nused for the sole purpose of mutable der= eferencing; instead ['`Deref` coercion'] can be used:\n\n[mutably dereferen= ceable types]: core::ops::DerefMut\n[pointed-to value]: core::ops::Deref::T= arget\n['`Deref` coercion']: core::ops::DerefMut#mutable-deref-coercion\n\n= ```rust\nlet mut x =3D Box::new(5i32);\n// Avoid this:\n// let y: &mut i32 = =3D x.as_mut();\n// Better just write:\nlet y: &mut i32 =3D &mut x;\n```\n\= nTypes which implement [`DerefMut`] should consider to add an implementatio= n of `AsMut` as\nfollows:\n\n[`DerefMut`]: core::ops::DerefMut\n\n```rus= t\nimpl AsMut for SomeType\nwhere\n ::Target: A= sMut,\n{\n fn as_mut(&mut self) -> &mut T {\n self.deref_mut()= .as_mut()\n }\n}\n```\n\n# Reflexivity\n\nIdeally, `AsMut` would be refl= exive, i.e. there would be an `impl AsMut for T`\nwith [`as_m= ut`] simply returning its argument unchanged.\nSuch a blanket implementatio= n is currently *not* provided due to technical restrictions of\nRust's type= system (it would be overlapping with another existing blanket implementati= on for\n`&mut T where T: AsMut` which allows `AsMut` to auto-dereference= , see \"Generic\nImplementations\" above).\n\n[`as_mut`]: AsMut::as_mut\n\n= A trivial implementation of `AsMut for T` must be added explicitly for a= particular type `T`\nwhere needed or desired. Note, however, that not all = types from `std` contain such an\nimplementation, and those cannot be added= by external code due to orphan rules.\n\n# Examples\n\nUsing `AsMut` as tr= ait bound for a generic function, we can accept all mutable references that= \ncan be converted to type `&mut T`. Unlike [dereference], which has a sing= le [target type],\nthere can be multiple implementations of `AsMut` for a t= ype. In particular, `Vec` implements\nboth `AsMut>` and `AsMut<[T= ]>`.\n\nIn the following, the example functions `caesar` and `null_terminat= e` provide a generic\ninterface which work with any type that can be conver= ted by cheap mutable-to-mutable conversion\ninto a byte slice (`[u8]`) or b= yte vector (`Vec`), respectively.\n\n[dereference]: core::ops::DerefMut= \n[target type]: core::ops::Deref::Target\n\n```rust\nstruct Document {\n = info: String,\n content: Vec,\n}\n\nimpl AsMut for D= ocument\nwhere\n Vec: AsMut,\n{\n fn as_mut(&mut self) -> &mut= T {\n self.content.as_mut()\n }\n}\n\nfn caesar>(= data: &mut T, key: u8) {\n for byte in data.as_mut() {\n *byte = =3D byte.wrapping_add(key);\n }\n}\n\nfn null_terminate= >>(data: &mut T) {\n // Using a non-generic inner function, which contai= ns most of the\n // functionality, helps to minimize monomorphization ov= erhead.\n fn doit(data: &mut Vec) {\n let len =3D data.len();= \n if len =3D=3D 0 || data[len-1] !=3D 0 {\n data.push(0)= ;\n }\n }\n doit(data.as_mut());\n}\n\nfn main() {\n let mu= t v: Vec =3D vec![1, 2, 3];\n caesar(&mut v, 5);\n assert_eq!(v, = [6, 7, 8]);\n null_terminate(&mut v);\n assert_eq!(v, [6, 7, 8, 0]);\= n let mut doc =3D Document {\n info: String::from(\"Example\"),\n= content: vec![17, 19, 8],\n };\n caesar(&mut doc, 1);\n as= sert_eq!(doc.content, [18, 20, 9]);\n null_terminate(&mut doc);\n ass= ert_eq!(doc.content, [18, 20, 9, 0]);\n}\n```\n\nNote, however, that APIs d= on't need to be generic. In many cases taking a `&mut [u8]` or\n`&mut Vec`, for example, is the better choice (callers need to pass the correct ty= pe then).") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "AsMut" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "AsMut") :additionalTextEdits []) (:label "AsRef" :kind 8 :documentation (:kind "markdown" :value "Used to do a cheap reference-to-reference c= onversion.\n\nThis trait is similar to [`AsMut`] which is used for converti= ng between mutable references.\nIf you need to do a costly conversion it is= better to implement [`From`] with type\n`&T` or write a custom function.\n= \n# Relation to `Borrow`\n\n`AsRef` has the same signature as [`Borrow`], b= ut [`Borrow`] is different in a few aspects:\n\n- Unlike `AsRef`, [`Borrow`= ] has a blanket impl for any `T`, and can be used to accept either\n a ref= erence or a value. (See also note on `AsRef`'s reflexibility below.)\n- [`B= orrow`] also requires that [`Hash`], [`Eq`] and [`Ord`] for a borrowed valu= e are\n equivalent to those of the owned value. For this reason, if you wa= nt to\n borrow only a single field of a struct you can implement `AsRef`, = but not [`Borrow`].\n\n**Note: This trait must not fail**. If the conversio= n can fail, use a\ndedicated method which returns an [`Option`] or a [`R= esult`].\n\n# Generic Implementations\n\n`AsRef` auto-dereferences if= the inner type is a reference or a mutable reference\n(e.g.: `foo.as_ref()= ` will work the same if `foo` has type `&mut Foo` or `&&mut Foo`).\n\nNote = that due to historic reasons, the above currently does not hold generally f= or all\n[dereferenceable types], e.g. `foo.as_ref()` will *not* work the sa= me as\n`Box::new(foo).as_ref()`. Instead, many smart pointers provide an `a= s_ref` implementation which\nsimply returns a reference to the [pointed-to = value] (but do not perform a cheap\nreference-to-reference conversion for t= hat value). However, [`AsRef::as_ref`] should not be\nused for the sole pur= pose of dereferencing; instead ['`Deref` coercion'] can be used:\n\n[derefe= renceable types]: core::ops::Deref\n[pointed-to value]: core::ops::Deref::T= arget\n['`Deref` coercion']: core::ops::Deref#deref-coercion\n\n```rust\nle= t x =3D Box::new(5i32);\n// Avoid this:\n// let y: &i32 =3D x.as_ref();\n//= Better just write:\nlet y: &i32 =3D &x;\n```\n\nTypes which implement [`De= ref`] should consider implementing `AsRef` as follows:\n\n[`Deref`]: cor= e::ops::Deref\n\n```rust\nimpl AsRef for SomeType\nwhere\n T: ?Siz= ed,\n ::Target: AsRef,\n{\n fn as_ref(&self) ->= &T {\n self.deref().as_ref()\n }\n}\n```\n\n# Reflexivity\n\nIde= ally, `AsRef` would be reflexive, i.e. there would be an `impl A= sRef for T`\nwith [`as_ref`] simply returning its argument unchanged.\nS= uch a blanket implementation is currently *not* provided due to technical r= estrictions of\nRust's type system (it would be overlapping with another ex= isting blanket implementation for\n`&T where T: AsRef` which allows `AsR= ef` to auto-dereference, see \"Generic Implementations\"\nabove).\n\n[`as_r= ef`]: AsRef::as_ref\n\nA trivial implementation of `AsRef for T` must be= added explicitly for a particular type `T`\nwhere needed or desired. Note,= however, that not all types from `std` contain such an\nimplementation, an= d those cannot be added by external code due to orphan rules.\n\n# Examples= \n\nBy using trait bounds we can accept arguments of different types as lon= g as they can be\nconverted to the specified type `T`.\n\nFor example: By c= reating a generic function that takes an `AsRef` we express that we\nw= ant to accept all references that can be converted to [`&str`] as an argume= nt.\nSince both [`String`] and [`&str`] implement `AsRef` we can accep= t both as input argument.\n\n[`&str`]: primitive@str\n[`Borrow`]: crate::bo= rrow::Borrow\n[`Eq`]: crate::cmp::Eq\n[`Ord`]: crate::cmp::Ord\n[`String`]:= ../../std/string/struct.String.html\n\n```rust\nfn is_hello>= (s: T) {\n assert_eq!(\"hello\", s.as_ref());\n}\n\nlet s =3D \"hello\";\= nis_hello(s);\n\nlet s =3D \"hello\".to_string();\nis_hello(s);\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "AsRef" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "AsRef") :additionalTextEdits []) (:label "Box" :kind 22 :detail "Box<{unknown}, {unknown}>" :documentat= ion (:kind "markdown" :value "A pointer type that uniquely owns a heap al= location of type `T`.\n\nSee the [module-level documentation](../../std/box= ed/index.html) for more.") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Box" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Box") :additionalTextEdits []) (:label "Clone" :kind 8 :documentation (:kind "markdown" :value "A common trait for the ability to explicitl= y duplicate an object.\n\nDiffers from [`Copy`] in that [`Copy`] is implici= t and an inexpensive bit-wise copy, while\n`Clone` is always explicit and m= ay or may not be expensive. In order to enforce\nthese characteristics, Rus= t does not allow you to reimplement [`Copy`], but you\nmay reimplement `Clo= ne` and run arbitrary code.\n\nSince `Clone` is more general than [`Copy`],= you can automatically make anything\n[`Copy`] be `Clone` as well.\n\n## De= rivable\n\nThis trait can be used with `#[derive]` if all fields are `Clone= `. The `derive`d\nimplementation of [`Clone`] calls [`clone`] on each field= .\n\n[`clone`]: Clone::clone\n\nFor a generic struct, `#[derive]` implement= s `Clone` conditionally by adding bound `Clone` on\ngeneric parameters.\n\n= ```rust\n// `derive` implements Clone for Reading when T is Clone.\n#[de= rive(Clone)]\nstruct Reading {\n frequency: T,\n}\n```\n\n## How can = I implement `Clone`?\n\nTypes that are [`Copy`] should have a trivial imple= mentation of `Clone`. More formally:\nif `T: Copy`, `x: T`, and `y: &T`, th= en `let x =3D y.clone();` is equivalent to `let x =3D *y;`.\nManual impleme= ntations should be careful to uphold this invariant; however, unsafe code\n= must not rely on it to ensure memory safety.\n\nAn example is a generic str= uct holding a function pointer. In this case, the\nimplementation of `Clone= ` cannot be `derive`d, but can be implemented as:\n\n```rust\nstruct Genera= te(fn() -> T);\n\nimpl Copy for Generate {}\n\nimpl Clone for G= enerate {\n fn clone(&self) -> Self {\n *self\n }\n}\n```\n= \nIf we `derive`:\n\n```rust\n#[derive(Copy, Clone)]\nstruct Generate(fn= () -> T);\n```\n\nthe auto-derived implementations will have unnecessary `T= : Copy` and `T: Clone` bounds:\n\n```rust\n\n// Automatically derived\nimpl= Copy for Generate { }\n\n// Automatically derived\nimpl Clone for Generate {\n fn clone(&self) -> Generate {\n = Generate(Clone::clone(&self.0))\n }\n}\n```\n\nThe bounds are unnecessar= y because clearly the function itself should be\ncopy- and cloneable even i= f its return type is not:\n\n```rust\n#[derive(Copy, Clone)]\nstruct Genera= te(fn() -> T);\n\nstruct NotCloneable;\n\nfn generate_not_cloneable() ->= NotCloneable {\n NotCloneable\n}\n\nGenerate(generate_not_cloneable).cl= one(); // error: trait bounds were not satisfied\n// Note: With the manual = implementations the above line will compile.\n```\n\n## Additional implemen= tors\n\nIn addition to the [implementors listed below][impls],\nthe followi= ng types also implement `Clone`:\n\n* Function item types (i.e., the distin= ct types defined for each function)\n* Function pointer types (e.g., `fn() = -> i32`)\n* Closure types, if they capture no value from the environment\n = or if all such captured values implement `Clone` themselves.\n Note that = variables captured by shared reference always implement `Clone`\n (even if= the referent doesn't),\n while variables captured by mutable reference ne= ver implement `Clone`.\n\n[impls]: #implementors") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Clone" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Clone") :additionalTextEdits []) (:label "Copy" :kind 8 :documentation (:kind "markdown" :value "Types whose values can be duplicated simply= by copying bits.\n\nBy default, variable bindings have 'move semantics.' I= n other\nwords:\n\n```rust\n#[derive(Debug)]\nstruct Foo;\n\nlet x =3D Foo;= \n\nlet y =3D x;\n\n// `x` has moved into `y`, and so cannot be used\n\n// = println!(\"{x:?}\"); // error: use of moved value\n```\n\nHowever, if a typ= e implements `Copy`, it instead has 'copy semantics':\n\n```rust\n// We can= derive a `Copy` implementation. `Clone` is also required, as it's\n// a su= pertrait of `Copy`.\n#[derive(Debug, Copy, Clone)]\nstruct Foo;\n\nlet x = =3D Foo;\n\nlet y =3D x;\n\n// `y` is a copy of `x`\n\nprintln!(\"{x:?}\");= // A-OK!\n```\n\nIt's important to note that in these two examples, the on= ly difference is whether you\nare allowed to access `x` after the assignmen= t. Under the hood, both a copy and a move\ncan result in bits being copied = in memory, although this is sometimes optimized away.\n\n## How can I imple= ment `Copy`?\n\nThere are two ways to implement `Copy` on your type. The si= mplest is to use `derive`:\n\n```rust\n#[derive(Copy, Clone)]\nstruct MyStr= uct;\n```\n\nYou can also implement `Copy` and `Clone` manually:\n\n```rust= \nstruct MyStruct;\n\nimpl Copy for MyStruct { }\n\nimpl Clone for MyStruct= {\n fn clone(&self) -> MyStruct {\n *self\n }\n}\n```\n\nTher= e is a small difference between the two: the `derive` strategy will also pl= ace a `Copy`\nbound on type parameters, which isn't always desired.\n\n## W= hat's the difference between `Copy` and `Clone`?\n\nCopies happen implicitl= y, for example as part of an assignment `y =3D x`. The behavior of\n`Copy` = is not overloadable; it is always a simple bit-wise copy.\n\nCloning is an = explicit action, `x.clone()`. The implementation of [`Clone`] can\nprovide = any type-specific behavior necessary to duplicate values safely. For exampl= e,\nthe implementation of [`Clone`] for [`String`] needs to copy the pointe= d-to string\nbuffer in the heap. A simple bitwise copy of [`String`] values= would merely copy the\npointer, leading to a double free down the line. Fo= r this reason, [`String`] is [`Clone`]\nbut not `Copy`.\n\n[`Clone`] is a s= upertrait of `Copy`, so everything which is `Copy` must also implement\n[`C= lone`]. If a type is `Copy` then its [`Clone`] implementation only needs to= return `*self`\n(see the example above).\n\n## When can my type be `Copy`?= \n\nA type can implement `Copy` if all of its components implement `Copy`. = For example, this\nstruct can be `Copy`:\n\n```rust\n#[derive(Copy, Clone)]= \nstruct Point {\n x: i32,\n y: i32,\n}\n```\n\nA struct can be `Copy`,= and [`i32`] is `Copy`, therefore `Point` is eligible to be `Copy`.\nBy con= trast, consider\n\n```rust\nstruct PointList {\n points: Vec,\n}\= n```\n\nThe struct `PointList` cannot implement `Copy`, because [`Vec`] = is not `Copy`. If we\nattempt to derive a `Copy` implementation, we'll get = an error:\n\n```text\nthe trait `Copy` cannot be implemented for this type;= field `points` does not implement `Copy`\n```\n\nShared references (`&T`) = are also `Copy`, so a type can be `Copy`, even when it holds\nshared refere= nces of types `T` that are *not* `Copy`. Consider the following struct,\nwh= ich can implement `Copy`, because it only holds a *shared reference* to our= non-`Copy`\ntype `PointList` from above:\n\n```rust\n#[derive(Copy, Clone)= ]\nstruct PointListWrapper<'a> {\n point_list_ref: &'a PointList,\n}\n``= `\n\n## When *can't* my type be `Copy`?\n\nSome types can't be copied safel= y. For example, copying `&mut T` would create an aliased\nmutable reference= . Copying [`String`] would duplicate responsibility for managing the\n[`Str= ing`]'s buffer, leading to a double free.\n\nGeneralizing the latter case, = any type implementing [`Drop`] can't be `Copy`, because it's\nmanaging some= resource besides its own [`size_of::`] bytes.\n\nIf you try to implemen= t `Copy` on a struct or enum containing non-`Copy` data, you will get\nthe = error [E0204].\n\n[E0204]: ../../error_codes/E0204.html\n\n## When *should*= my type be `Copy`?\n\nGenerally speaking, if your type _can_ implement `Co= py`, it should. Keep in mind, though,\nthat implementing `Copy` is part of = the public API of your type. If the type might become\nnon-`Copy` in the fu= ture, it could be prudent to omit the `Copy` implementation now, to\navoid = a breaking API change.\n\n## Additional implementors\n\nIn addition to the = [implementors listed below][impls],\nthe following types also implement `Co= py`:\n\n* Function item types (i.e., the distinct types defined for each fu= nction)\n* Function pointer types (e.g., `fn() -> i32`)\n* Closure types, i= f they capture no value from the environment\n or if all such captured val= ues implement `Copy` themselves.\n Note that variables captured by shared = reference always implement `Copy`\n (even if the referent doesn't),\n whi= le variables captured by mutable reference never implement `Copy`.\n\n[`Vec= `]: ../../std/vec/struct.Vec.html\n[`String`]: ../../std/string/struct.S= tring.html\n[`size_of::`]: crate::mem::size_of\n[impls]: #implementors") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Copy" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Copy") :additionalTextEdits []) (:label "Default" :kind 8 :documentation (:kind "markdown" :value "A trait for giving a type a useful default = value.\n\nSometimes, you want to fall back to some kind of default value, a= nd\ndon't particularly care what it is. This comes up often with `struct`s\= nthat define a set of options:\n\n```rust\nstruct SomeOptions {\n foo: i= 32,\n bar: f32,\n}\n```\n\nHow can we define some default values? You ca= n use `Default`:\n\n```rust\n#[derive(Default)]\nstruct SomeOptions {\n = foo: i32,\n bar: f32,\n}\n\nfn main() {\n let options: SomeOptions = =3D Default::default();\n}\n```\n\nNow, you get all of the default values. = Rust implements `Default` for various primitives types.\n\nIf you want to o= verride a particular option, but still retain the other defaults:\n\n```rus= t\nfn main() {\n let options =3D SomeOptions { foo: 42, ..Default::defau= lt() };\n}\n```\n\n## Derivable\n\nThis trait can be used with `#[derive]` = if all of the type's fields implement\n`Default`. When `derive`d, it will u= se the default value for each field's type.\n\n### `enum`s\n\nWhen using `#= [derive(Default)]` on an `enum`, you need to choose which unit variant will= be\ndefault. You do this by placing the `#[default]` attribute on the vari= ant.\n\n```rust\n#[derive(Default)]\nenum Kind {\n #[default]\n A,\n = B,\n C,\n}\n```\n\nYou cannot use the `#[default]` attribute on non-u= nit or non-exhaustive variants.\n\nThe `#[default]` attribute was stabilize= d in Rust 1.62.0.\n\n## How can I implement `Default`?\n\nProvide an implem= entation for the `default()` method that returns the value of\nyour type th= at should be the default:\n\n```rust\nenum Kind {\n A,\n B,\n C,\n= }\n\nimpl Default for Kind {\n fn default() -> Self { Kind::A }\n}\n```\= n\n# Examples\n\n```rust\n#[derive(Default)]\nstruct SomeOptions {\n foo= : i32,\n bar: f32,\n}\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Default" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Default") :additionalTextEdits []) (:label "DoubleEndedIterator" :kind 8 :documentation (:kind "markdown" :value "An iterator able to yield elements from bot= h ends.\n\nSomething that implements `DoubleEndedIterator` has one extra ca= pability\nover something that implements [`Iterator`]: the ability to also = take\n`Item`s from the back, as well as the front.\n\nIt is important to no= te that both back and forth work on the same range,\nand do not cross: iter= ation is over when they meet in the middle.\n\nIn a similar fashion to the = [`Iterator`] protocol, once a\n`DoubleEndedIterator` returns [`None`] from = a [`next_back()`], calling it\nagain may or may not ever return [`Some`] ag= ain. [`next()`] and\n[`next_back()`] are interchangeable for this purpose.\= n\n[`next_back()`]: DoubleEndedIterator::next_back\n[`next()`]: Iterator::n= ext\n\n# Examples\n\nBasic usage:\n\n```rust\nlet numbers =3D vec![1, 2, 3,= 4, 5, 6];\n\nlet mut iter =3D numbers.iter();\n\nassert_eq!(Some(&1), iter= .next());\nassert_eq!(Some(&6), iter.next_back());\nassert_eq!(Some(&5), it= er.next_back());\nassert_eq!(Some(&2), iter.next());\nassert_eq!(Some(&3), = iter.next());\nassert_eq!(Some(&4), iter.next());\nassert_eq!(None, iter.ne= xt());\nassert_eq!(None, iter.next_back());\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "DoubleEndedIterator" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "DoubleEndedIterator") :additionalTextEdits []) (:label "Drop" :kind 8 :documentation (:kind "markdown" :value "Custom code within the destructor.\n\nWhen = a value is no longer needed, Rust will run a \"destructor\" on that value.\= nThe most common way that a value is no longer needed is when it goes out o= f\nscope. Destructors may still run in other circumstances, but we're going= to\nfocus on scope for the examples here. To learn about some of those oth= er cases,\nplease see [the reference] section on destructors.\n\n[the refer= ence]: https://doc.rust-lang.org/reference/destructors.html\n\nThis destruc= tor consists of two components:\n- A call to `Drop::drop` for that value, i= f this special `Drop` trait is implemented for its type.\n- The automatical= ly generated \"drop glue\" which recursively calls the destructors\n of = all the fields of this value.\n\nAs Rust automatically calls the destructor= s of all contained fields,\nyou don't have to implement `Drop` in most case= s. But there are some cases where\nit is useful, for example for types whic= h directly manage a resource.\nThat resource may be memory, it may be a fil= e descriptor, it may be a network socket.\nOnce a value of that type is no = longer going to be used, it should \"clean up\" its\nresource by freeing th= e memory or closing the file or socket. This is\nthe job of a destructor, a= nd therefore the job of `Drop::drop`.\n\n## Examples\n\nTo see destructors = in action, let's take a look at the following program:\n\n```rust\nstruct H= asDrop;\n\nimpl Drop for HasDrop {\n fn drop(&mut self) {\n print= ln!(\"Dropping HasDrop!\");\n }\n}\n\nstruct HasTwoDrops {\n one: Has= Drop,\n two: HasDrop,\n}\n\nimpl Drop for HasTwoDrops {\n fn drop(&mu= t self) {\n println!(\"Dropping HasTwoDrops!\");\n }\n}\n\nfn mai= n() {\n let _x =3D HasTwoDrops { one: HasDrop, two: HasDrop };\n prin= tln!(\"Running!\");\n}\n```\n\nRust will first call `Drop::drop` for `_x` a= nd then for both `_x.one` and `_x.two`,\nmeaning that running this will pri= nt\n\n```text\nRunning!\nDropping HasTwoDrops!\nDropping HasDrop!\nDropping= HasDrop!\n```\n\nEven if we remove the implementation of `Drop` for `HasTw= oDrop`, the destructors of its fields are still called.\nThis would result = in\n\n```test\nRunning!\nDropping HasDrop!\nDropping HasDrop!\n```\n\n## Yo= u cannot call `Drop::drop` yourself\n\nBecause `Drop::drop` is used to clea= n up a value, it may be dangerous to use this value after\nthe method has b= een called. As `Drop::drop` does not take ownership of its input,\nRust pre= vents misuse by not allowing you to call `Drop::drop` directly.\n\nIn other= words, if you tried to explicitly call `Drop::drop` in the above example, = you'd get a compiler error.\n\nIf you'd like to explicitly call the destruc= tor of a value, [`mem::drop`] can be used instead.\n\n[`mem::drop`]: drop\n= \n## Drop order\n\nWhich of our two `HasDrop` drops first, though? For stru= cts, it's the same\norder that they're declared: first `one`, then `two`. I= f you'd like to try\nthis yourself, you can modify `HasDrop` above to conta= in some data, like an\ninteger, and then use it in the `println!` inside of= `Drop`. This behavior is\nguaranteed by the language.\n\nUnlike for struct= s, local variables are dropped in reverse order:\n\n```rust\nstruct Foo;\n\= nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"Dropping= Foo!\")\n }\n}\n\nstruct Bar;\n\nimpl Drop for Bar {\n fn drop(&mut = self) {\n println!(\"Dropping Bar!\")\n }\n}\n\nfn main() {\n = let _foo =3D Foo;\n let _bar =3D Bar;\n}\n```\n\nThis will print\n\n```t= ext\nDropping Bar!\nDropping Foo!\n```\n\nPlease see [the reference] for th= e full rules.\n\n[the reference]: https://doc.rust-lang.org/reference/destr= uctors.html\n\n## `Copy` and `Drop` are exclusive\n\nYou cannot implement b= oth [`Copy`] and `Drop` on the same type. Types that\nare `Copy` get implic= itly duplicated by the compiler, making it very\nhard to predict when, and = how often destructors will be executed. As such,\nthese types cannot have d= estructors.\n\n## Drop check\n\nDropping interacts with the borrow checker = in subtle ways: when a type `T` is being implicitly\ndropped as some variab= le of this type goes out of scope, the borrow checker needs to ensure that\= ncalling `T`'s destructor at this moment is safe. In particular, it also ne= eds to be safe to\nrecursively drop all the fields of `T`. For example, it = is crucial that code like the following\nis being rejected:\n\n```rust\nuse= std::cell::Cell;\n\nstruct S<'a>(Cell>>, Box);\nimpl= Drop for S<'_> {\n fn drop(&mut self) {\n if let Some(r) =3D sel= f.0.get() {\n // Print the contents of the `Box` in `r`.\n = println!(\"{}\", r.1);\n }\n }\n}\n\nfn main() {\n // Se= t up two `S` that point to each other.\n let s1 =3D S(Cell::new(None), B= ox::new(42));\n let s2 =3D S(Cell::new(Some(&s1)), Box::new(42));\n s= 1.0.set(Some(&s2));\n // Now they both get dropped. But whichever is the= 2nd one\n // to be dropped will access the `Box` in the first one,\n = // which is a use-after-free!\n}\n```\n\nThe Nomicon discusses the need fo= r [drop check in more detail][drop check].\n\nTo reject such code, the \"dr= op check\" analysis determines which types and lifetimes need to\nstill be = live when `T` gets dropped. The exact details of this analysis are not yet\= nstably guaranteed and **subject to change**. Currently, the analysis works= as follows:\n- If `T` has no drop glue, then trivially nothing is required= to be live. This is the case if\n neither `T` nor any of its (recursive) = fields have a destructor (`impl Drop`). [`PhantomData`]\n and [`ManuallyDr= op`] are considered to never have a destructor, no matter their field type.= \n- If `T` has drop glue, then, for all types `U` that are *owned* by any f= ield of `T`,\n recursively add the types and lifetimes that need to be liv= e when `U` gets dropped. The set of\n owned types is determined by recursi= vely traversing `T`:\n - Recursively descend through `PhantomData`, `Box`,= tuples, and arrays (including arrays of\n length 0).\n - Stop at refer= ence and raw pointer types as well as function pointers and function items;= \n they do not own anything.\n - Stop at non-composite types (type para= meters that remain generic in the current context and\n base types such = as integers and `bool`); these types are owned.\n - When hitting an ADT wi= th `impl Drop`, stop there; this type is owned.\n - When hitting an ADT wi= thout `impl Drop`, recursively descend to its fields. (For an `enum`,\n = consider all fields of all variants.)\n- Furthermore, if `T` implements `Dr= op`, then all generic (lifetime and type) parameters of `T`\n must be live= .\n\nIn the above example, the last clause implies that `'a` must be live w= hen `S<'a>` is dropped,\nand hence the example is rejected. If we remove th= e `impl Drop`, the liveness requirement\ndisappears and the example is acce= pted.\n\nThere exists an unstable way for a type to opt-out of the last cla= use; this is called \"drop\ncheck eyepatch\" or `may_dangle`. For more deta= ils on this nightly-only feature, see the\n[discussion in the Nomicon][nomi= con].\n\n[`ManuallyDrop`]: crate::mem::ManuallyDrop\n[`PhantomData`]: crate= ::marker::PhantomData\n[drop check]: ../../nomicon/dropck.html\n[nomicon]: = ../../nomicon/phantom-data.html#an-exception-the-special-case-of-the-standa= rd-library-and-its-unstable-may_dangle") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Drop" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Drop") :additionalTextEdits []) (:label "Eq (alias =3D=3D, !=3D)" :kind 8 :documentation (:kind "markdown" :value "Trait for comparisons corresponding to [equ= ivalence relations](\nhttps://en.wikipedia.org/wiki/Equivalence_relation).\= n\nThis means, that in addition to `a =3D=3D b` and `a !=3D b` being strict= inverses,\nthe relation must be (for all `a`, `b` and `c`):\n\n- reflexive= : `a =3D=3D a`;\n- symmetric: `a =3D=3D b` implies `b =3D=3D a` (required b= y `PartialEq` as well); and\n- transitive: `a =3D=3D b` and `b =3D=3D c` im= plies `a =3D=3D c` (required by `PartialEq` as well).\n\nThis property cann= ot be checked by the compiler, and therefore `Eq` implies\n[`PartialEq`], a= nd has no extra methods.\n\nViolating this property is a logic error. The b= ehavior resulting from a logic error is not\nspecified, but users of the tr= ait must ensure that such logic errors do *not* result in\nundefined behavi= or. This means that `unsafe` code **must not** rely on the correctness of t= hese\nmethods.\n\nImplement `Eq` in addition to `PartialEq` if it's guarant= eed that\n`PartialEq::eq(a, a)` always returns `true` (reflexivity), in add= ition to\nthe symmetric and transitive properties already required by `Part= ialEq`.\n\n## Derivable\n\nThis trait can be used with `#[derive]`. When `d= erive`d, because `Eq` has\nno extra methods, it is only informing the compi= ler that this is an\nequivalence relation rather than a partial equivalence= relation. Note that\nthe `derive` strategy requires all fields are `Eq`, w= hich isn't\nalways desired.\n\n## How can I implement `Eq`?\n\nIf you canno= t use the `derive` strategy, specify that your type implements\n`Eq`, which= has no methods:\n\n```rust\nenum BookFormat { Paperback, Hardback, Ebook }= \nstruct Book {\n isbn: i32,\n format: BookFormat,\n}\nimpl PartialEq= for Book {\n fn eq(&self, other: &Self) -> bool {\n self.isbn = =3D=3D other.isbn\n }\n}\nimpl Eq for Book {}\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Eq" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Eq") :additionalTextEdits []) (:label "ExactSizeIterator" :kind 8 :documentation (:kind "markdown" :value "An iterator that knows its exact length.\n\= nMany [`Iterator`]s don't know how many times they will iterate, but some d= o.\nIf an iterator knows how many times it can iterate, providing access to= \nthat information can be useful. For example, if you want to iterate\nback= wards, a good start is to know where the end is.\n\nWhen implementing an `E= xactSizeIterator`, you must also implement\n[`Iterator`]. When doing so, th= e implementation of [`Iterator::size_hint`]\n*must* return the exact size o= f the iterator.\n\nThe [`len`] method has a default implementation, so you = usually shouldn't\nimplement it. However, you may be able to provide a more= performant\nimplementation than the default, so overriding it in this case= makes sense.\n\nNote that this trait is a safe trait and as such does *not= * and *cannot*\nguarantee that the returned length is correct. This means t= hat `unsafe`\ncode **must not** rely on the correctness of [`Iterator::size= _hint`]. The\nunstable and unsafe [`TrustedLen`](super::marker::TrustedLen)= trait gives\nthis additional guarantee.\n\n[`len`]: ExactSizeIterator::len= \n\n# When *shouldn't* an adapter be `ExactSizeIterator`?\n\nIf an adapter = makes an iterator *longer*, then it's usually incorrect for\nthat adapter t= o implement `ExactSizeIterator`. The inner exact-sized\niterator might alr= eady be `usize::MAX`-long, and thus the length of the\nlonger adapted itera= tor would no longer be exactly representable in `usize`.\n\nThis is why [`C= hain`](crate::iter::Chain) isn't `ExactSizeIterator`,\neven when `A` = and `B` are both `ExactSizeIterator`.\n\n# Examples\n\nBasic usage:\n\n```r= ust\n// a finite range knows exactly how many times it will iterate\nlet fi= ve =3D 0..5;\n\nassert_eq!(5, five.len());\n```\n\nIn the [module-level doc= s], we implemented an [`Iterator`], `Counter`.\nLet's implement `ExactSizeI= terator` for it as well:\n\n[module-level docs]: crate::iter\n\n```rust\nim= pl ExactSizeIterator for Counter {\n // We can easily calculate the rema= ining number of iterations.\n fn len(&self) -> usize {\n 5 - self= .count\n }\n}\n\n// And now we can use it!\n\nlet mut counter =3D Counte= r::new();\n\nassert_eq!(5, counter.len());\nlet _ =3D counter.next();\nasse= rt_eq!(4, counter.len());\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "ExactSizeIterator" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "ExactSizeIterator") :additionalTextEdits []) (:label "Extend" :kind 8 :documentation (:kind "markdown" :value "Extend a collection with the contents of an= iterator.\n\nIterators produce a series of values, and collections can als= o be thought\nof as a series of values. The `Extend` trait bridges this gap= , allowing you\nto extend a collection by including the contents of that it= erator. When\nextending a collection with an already existing key, that ent= ry is updated\nor, in the case of collections that permit multiple entries = with equal\nkeys, that entry is inserted.\n\n# Examples\n\nBasic usage:\n\n= ```rust\n// You can extend a String with some chars:\nlet mut message =3D S= tring::from(\"The first three letters are: \");\n\nmessage.extend(&['a', 'b= ', 'c']);\n\nassert_eq!(\"abc\", &message[29..32]);\n```\n\nImplementing `E= xtend`:\n\n```rust\n// A sample collection, that's just a wrapper over Vec<= T>\n#[derive(Debug)]\nstruct MyCollection(Vec);\n\n// Let's give it so= me methods so we can create one and add things\n// to it.\nimpl MyCollectio= n {\n fn new() -> MyCollection {\n MyCollection(Vec::new())\n = }\n\n fn add(&mut self, elem: i32) {\n self.0.push(elem);\n }\= n}\n\n// since MyCollection has a list of i32s, we implement Extend for i32= \nimpl Extend for MyCollection {\n\n // This is a bit simpler with = the concrete type signature: we can call\n // extend on anything which c= an be turned into an Iterator which gives\n // us i32s. Because we need = i32s to put into MyCollection.\n fn extend>(= &mut self, iter: T) {\n\n // The implementation is very straightforw= ard: loop through the\n // iterator, and add() each element to ourse= lves.\n for elem in iter {\n self.add(elem);\n }\n= }\n}\n\nlet mut c =3D MyCollection::new();\n\nc.add(5);\nc.add(6);\nc.a= dd(7);\n\n// let's extend our collection with three more numbers\nc.extend(= vec![1, 2, 3]);\n\n// we've added these elements onto the end\nassert_eq!(\= "MyCollection([5, 6, 7, 1, 2, 3])\", format!(\"{c:?}\"));\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Extend" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Extend") :additionalTextEdits []) (:label "Fn" :kind 8 :documentation (:kind "markdown" :value "The version of the call operator that takes= an immutable receiver.\n\nInstances of `Fn` can be called repeatedly witho= ut mutating state.\n\n*This trait (`Fn`) is not to be confused with [functi= on pointers]\n(`fn`).*\n\n`Fn` is implemented automatically by closures whi= ch only take immutable\nreferences to captured variables or don't capture a= nything at all, as well\nas (safe) [function pointers] (with some caveats, = see their documentation\nfor more details). Additionally, for any type `F` = that implements `Fn`, `&F`\nimplements `Fn`, too.\n\nSince both [`FnMut`] a= nd [`FnOnce`] are supertraits of `Fn`, any\ninstance of `Fn` can be used as= a parameter where a [`FnMut`] or [`FnOnce`]\nis expected.\n\nUse `Fn` as a= bound when you want to accept a parameter of function-like\ntype and need = to call it repeatedly and without mutating state (e.g., when\ncalling it co= ncurrently). If you do not need such strict requirements, use\n[`FnMut`] or= [`FnOnce`] as bounds.\n\nSee the [chapter on closures in *The Rust Program= ming Language*][book] for\nsome more information on this topic.\n\nAlso of = note is the special syntax for `Fn` traits (e.g.\n`Fn(usize, bool) -> usize= `). Those interested in the technical details of\nthis can refer to [the re= levant section in the *Rustonomicon*][nomicon].\n\n[book]: ../../book/ch13-= 01-closures.html\n[function pointers]: fn\n[nomicon]: ../../nomicon/hrtb.ht= ml\n\n# Examples\n\n## Calling a closure\n\n```rust\nlet square =3D |x| x *= x;\nassert_eq!(square(5), 25);\n```\n\n## Using a `Fn` parameter\n\n```rus= t\nfn call_with_one(func: F) -> usize\n where F: Fn(usize) -> usize {= \n func(1)\n}\n\nlet double =3D |x| x * 2;\nassert_eq!(call_with_one(dou= ble), 2);\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Fn" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Fn") :additionalTextEdits []) (:label "FnMut" :kind 8 :documentation (:kind "markdown" :value "The version of the call operator that takes= a mutable receiver.\n\nInstances of `FnMut` can be called repeatedly and m= ay mutate state.\n\n`FnMut` is implemented automatically by closures which = take mutable\nreferences to captured variables, as well as all types that i= mplement\n[`Fn`], e.g., (safe) [function pointers] (since `FnMut` is a supe= rtrait of\n[`Fn`]). Additionally, for any type `F` that implements `FnMut`,= `&mut F`\nimplements `FnMut`, too.\n\nSince [`FnOnce`] is a supertrait of = `FnMut`, any instance of `FnMut` can be\nused where a [`FnOnce`] is expecte= d, and since [`Fn`] is a subtrait of\n`FnMut`, any instance of [`Fn`] can b= e used where `FnMut` is expected.\n\nUse `FnMut` as a bound when you want t= o accept a parameter of function-like\ntype and need to call it repeatedly,= while allowing it to mutate state.\nIf you don't want the parameter to mut= ate state, use [`Fn`] as a\nbound; if you don't need to call it repeatedly,= use [`FnOnce`].\n\nSee the [chapter on closures in *The Rust Programming L= anguage*][book] for\nsome more information on this topic.\n\nAlso of note i= s the special syntax for `Fn` traits (e.g.\n`Fn(usize, bool) -> usize`). Th= ose interested in the technical details of\nthis can refer to [the relevant= section in the *Rustonomicon*][nomicon].\n\n[book]: ../../book/ch13-01-clo= sures.html\n[function pointers]: fn\n[nomicon]: ../../nomicon/hrtb.html\n\n= # Examples\n\n## Calling a mutably capturing closure\n\n```rust\nlet mut x = =3D 5;\n{\n let mut square_x =3D || x *=3D x;\n square_x();\n}\nasser= t_eq!(x, 25);\n```\n\n## Using a `FnMut` parameter\n\n```rust\nfn do_twice<= F>(mut func: F)\n where F: FnMut()\n{\n func();\n func();\n}\n\nle= t mut x: usize =3D 1;\n{\n let add_two_to_x =3D || x +=3D 2;\n do_twi= ce(add_two_to_x);\n}\n\nassert_eq!(x, 5);\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "FnMut" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "FnMut") :additionalTextEdits []) (:label "FnOnce" :kind 8 :documentation (:kind "markdown" :value "The version of the call operator that takes= a by-value receiver.\n\nInstances of `FnOnce` can be called, but might not= be callable multiple\ntimes. Because of this, if the only thing known abou= t a type is that it\nimplements `FnOnce`, it can only be called once.\n\n`F= nOnce` is implemented automatically by closures that might consume captured= \nvariables, as well as all types that implement [`FnMut`], e.g., (safe)\n[= function pointers] (since `FnOnce` is a supertrait of [`FnMut`]).\n\nSince = both [`Fn`] and [`FnMut`] are subtraits of `FnOnce`, any instance of\n[`Fn`= ] or [`FnMut`] can be used where a `FnOnce` is expected.\n\nUse `FnOnce` as= a bound when you want to accept a parameter of function-like\ntype and onl= y need to call it once. If you need to call the parameter\nrepeatedly, use = [`FnMut`] as a bound; if you also need it to not mutate\nstate, use [`Fn`].= \n\nSee the [chapter on closures in *The Rust Programming Language*][book] = for\nsome more information on this topic.\n\nAlso of note is the special sy= ntax for `Fn` traits (e.g.\n`Fn(usize, bool) -> usize`). Those interested i= n the technical details of\nthis can refer to [the relevant section in the = *Rustonomicon*][nomicon].\n\n[book]: ../../book/ch13-01-closures.html\n[fun= ction pointers]: fn\n[nomicon]: ../../nomicon/hrtb.html\n\n# Examples\n\n##= Using a `FnOnce` parameter\n\n```rust\nfn consume_with_relish(func: F)\= n where F: FnOnce() -> String\n{\n // `func` consumes its captured va= riables, so it cannot be run more\n // than once.\n println!(\"Consum= ed: {}\", func());\n\n println!(\"Delicious!\");\n\n // Attempting to= invoke `func()` again will throw a `use of moved\n // value` error for = `func`.\n}\n\nlet x =3D String::from(\"x\");\nlet consume_and_return_x =3D = move || x;\nconsume_with_relish(consume_and_return_x);\n\n// `consume_and_r= eturn_x` can no longer be invoked at this point\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "FnOnce" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "FnOnce") :additionalTextEdits []) (:label "From" :kind 8 :documentation (:kind "markdown" :value "Used to do value-to-value conversions while= consuming the input value. It is the reciprocal of\n[`Into`].\n\nOne shoul= d always prefer implementing `From` over [`Into`]\nbecause implementing `Fr= om` automatically provides one with an implementation of [`Into`]\nthanks t= o the blanket implementation in the standard library.\n\nOnly implement [`I= nto`] when targeting a version prior to Rust 1.41 and converting to a type\= noutside the current crate.\n`From` was not able to do these types of conve= rsions in earlier versions because of Rust's\norphaning rules.\nSee [`Into`= ] for more details.\n\nPrefer using [`Into`] over using `From` when specify= ing trait bounds on a generic function.\nThis way, types that directly impl= ement [`Into`] can be used as arguments as well.\n\nThe `From` trait is als= o very useful when performing error handling. When constructing a function\= nthat is capable of failing, the return type will generally be of the form = `Result`.\n`From` simplifies error handling by allowing a function to= return a single error type\nthat encapsulates multiple error types. See th= e \"Examples\" section and [the book][book] for more\ndetails.\n\n**Note: T= his trait must not fail**. The `From` trait is intended for perfect convers= ions.\nIf the conversion can fail or is not perfect, use [`TryFrom`].\n\n# = Generic Implementations\n\n- `From for U` implies [`Into`]` for T`\n-= `From` is reflexive, which means that `From for T` is implemented\n\n# = When to implement `From`\n\nWhile there's no technical restrictions on whic= h conversions can be done using\na `From` implementation, the general expec= tation is that the conversions\nshould typically be restricted as follows:\= n\n* The conversion is *infallible*: if the conversion can fail, use [`TryF= rom`]\n instead; don't provide a `From` impl that panics.\n\n* The convers= ion is *lossless*: semantically, it should not lose or discard\n informati= on. For example, `i32: From` exists, where the original\n value can b= e recovered using `u16: TryFrom`. And `String: From<&str>`\n exists,= where you can get something equivalent to the original value via\n `Deref= `. But `From` cannot be used to convert from `u32` to `u16`, since\n that= cannot succeed in a lossless way. (There's some wiggle room here for\n i= nformation not considered semantically relevant. For example,\n `Box<[T]>= : From>` exists even though it might not preserve capacity,\n like = how two vectors can be equal despite differing capacities.)\n\n* The conver= sion is *value-preserving*: the conceptual kind and meaning of\n the resul= ting value is the same, even though the Rust type and technical\n represen= tation might be different. For example `-1_i8 as u8` is *lossless*,\n sin= ce `as` casting back can recover the original value, but that conversion\n = is *not* available via `From` because `-1` and `255` are different concept= ual\n values (despite being identical bit patterns technically). But\n `= f32: From` *is* available because `1_i16` and `1.0_f32` are conceptual= ly\n the same real number (despite having very different bit patterns tech= nically).\n `String: From` is available because they're both *text*,= but\n `String: From` is *not* available, since `1` (a number) and `\= "1\"`\n (text) are too different. (Converting values to text is instead c= overed\n by the [`Display`](crate::fmt::Display) trait.)\n\n* The conversi= on is *obvious*: it's the only reasonable conversion between\n the two typ= es. Otherwise it's better to have it be a named method or\n constructor, = like how [`str::as_bytes`] is a method and how integers have\n methods lik= e [`u32::from_ne_bytes`], [`u32::from_le_bytes`], and\n [`u32::from_be_byt= es`], none of which are `From` implementations. Whereas\n there's only on= e reasonable way to wrap an [`Ipv6Addr`](crate::net::Ipv6Addr)\n into an [= `IpAddr`](crate::net::IpAddr), thus `IpAddr: From` exists.\n\n# E= xamples\n\n[`String`] implements `From<&str>`:\n\nAn explicit conversion fr= om a `&str` to a String is done as follows:\n\n```rust\nlet string =3D \"he= llo\".to_string();\nlet other_string =3D String::from(\"hello\");\n\nassert= _eq!(string, other_string);\n```\n\nWhile performing error handling it is o= ften useful to implement `From` for your own error type.\nBy converting und= erlying error types to our own custom error type that encapsulates the\nund= erlying error type, we can return a single error type without losing inform= ation on the\nunderlying cause. The '?' operator automatically converts the= underlying error type to our\ncustom error type with `From::from`.\n\n```r= ust\nuse std::fs;\nuse std::io;\nuse std::num;\n\nenum CliError {\n IoEr= ror(io::Error),\n ParseError(num::ParseIntError),\n}\n\nimpl From for CliError {\n fn from(error: io::Error) -> Self {\n CliEr= ror::IoError(error)\n }\n}\n\nimpl From for CliError= {\n fn from(error: num::ParseIntError) -> Self {\n CliError::Par= seError(error)\n }\n}\n\nfn open_and_parse_file(file_name: &str) -> Resu= lt {\n let mut contents =3D fs::read_to_string(&file_name= )?;\n let num: i32 =3D contents.trim().parse()?;\n Ok(num)\n}\n```\n\= n[`String`]: ../../std/string/struct.String.html\n[`from`]: From::from\n[bo= ok]: ../../book/ch09-00-error-handling.html") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "From" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "From") :additionalTextEdits []) (:label "FromIterator" :kind 8 :documentation (:kind "markdown" :value "Conversion from an [`Iterator`].\n\nBy impl= ementing `FromIterator` for a type, you define how it will be\ncreated from= an iterator. This is common for types which describe a\ncollection of some= kind.\n\nIf you want to create a collection from the contents of an iterat= or, the\n[`Iterator::collect()`] method is preferred. However, when you nee= d to\nspecify the container type, [`FromIterator::from_iter()`] can be more= \nreadable than using a turbofish (e.g. `::>()`). See the\n[`Iterato= r::collect()`] documentation for more examples of its use.\n\nSee also: [`I= ntoIterator`].\n\n# Examples\n\nBasic usage:\n\n```rust\nlet five_fives =3D= std::iter::repeat(5).take(5);\n\nlet v =3D Vec::from_iter(five_fives);\n\n= assert_eq!(v, vec![5, 5, 5, 5, 5]);\n```\n\nUsing [`Iterator::collect()`] t= o implicitly use `FromIterator`:\n\n```rust\nlet five_fives =3D std::iter::= repeat(5).take(5);\n\nlet v: Vec =3D five_fives.collect();\n\nassert_e= q!(v, vec![5, 5, 5, 5, 5]);\n```\n\nUsing [`FromIterator::from_iter()`] as = a more readable alternative to\n[`Iterator::collect()`]:\n\n```rust\nuse st= d::collections::VecDeque;\nlet first =3D (0..10).collect::>()= ;\nlet second =3D VecDeque::from_iter(0..10);\n\nassert_eq!(first, second);= \n```\n\nImplementing `FromIterator` for your type:\n\n```rust\n// A sample= collection, that's just a wrapper over Vec\n#[derive(Debug)]\nstruct My= Collection(Vec);\n\n// Let's give it some methods so we can create one= and add things\n// to it.\nimpl MyCollection {\n fn new() -> MyCollecti= on {\n MyCollection(Vec::new())\n }\n\n fn add(&mut self, elem= : i32) {\n self.0.push(elem);\n }\n}\n\n// and we'll implement Fr= omIterator\nimpl FromIterator for MyCollection {\n fn from_iter>(iter: I) -> Self {\n let mut c =3D MyColle= ction::new();\n\n for i in iter {\n c.add(i);\n }\= n\n c\n }\n}\n\n// Now we can make a new iterator...\nlet iter = =3D (0..5).into_iter();\n\n// ... and make a MyCollection out of it\nlet c = =3D MyCollection::from_iter(iter);\n\nassert_eq!(c.0, vec![0, 1, 2, 3, 4]);= \n\n// collect works too!\n\nlet iter =3D (0..5).into_iter();\nlet c: MyCol= lection =3D iter.collect();\n\nassert_eq!(c.0, vec![0, 1, 2, 3, 4]);\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "FromIterator" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "FromIterator") :additionalTextEdits []) (:label "Into" :kind 8 :documentation (:kind "markdown" :value "A value-to-value conversion that consumes t= he input value. The\nopposite of [`From`].\n\nOne should avoid implementing= [`Into`] and implement [`From`] instead.\nImplementing [`From`] automatica= lly provides one with an implementation of [`Into`]\nthanks to the blanket = implementation in the standard library.\n\nPrefer using [`Into`] over [`Fro= m`] when specifying trait bounds on a generic function\nto ensure that type= s that only implement [`Into`] can be used as well.\n\n**Note: This trait m= ust not fail**. If the conversion can fail, use [`TryInto`].\n\n# Generic I= mplementations\n\n- [`From`]` for U` implies `Into for T`\n- [`Into`]= is reflexive, which means that `Into for T` is implemented\n\n# Impleme= nting [`Into`] for conversions to external types in old versions of Rust\n\= nPrior to Rust 1.41, if the destination type was not part of the current cr= ate\nthen you couldn't implement [`From`] directly.\nFor example, take this= code:\n\n```rust\nstruct Wrapper(Vec);\nimpl From> for= Vec {\n fn from(w: Wrapper) -> Vec {\n w.0\n }\n}\n`= ``\nThis will fail to compile in older versions of the language because Rus= t's orphaning rules\nused to be a little bit more strict. To bypass this, y= ou could implement [`Into`] directly:\n\n```rust\nstruct Wrapper(Vec)= ;\nimpl Into> for Wrapper {\n fn into(self) -> Vec {\n = self.0\n }\n}\n```\n\nIt is important to understand that [`Into`] = does not provide a [`From`] implementation\n(as [`From`] does with [`Into`]= ). Therefore, you should always try to implement [`From`]\nand then fall ba= ck to [`Into`] if [`From`] can't be implemented.\n\n# Examples\n\n[`String`= ] implements [`Into`]`<`[`Vec`]`<`[`u8`]`>>`:\n\nIn order to express that w= e want a generic function to take all arguments that can be\nconverted to a= specified type `T`, we can use a trait bound of [`Into`]``.\nFor exampl= e: The function `is_hello` takes all arguments that can be converted into a= \n[`Vec`]`<`[`u8`]`>`.\n\n```rust\nfn is_hello>>(s: T) {\n = let bytes =3D b\"hello\".to_vec();\n assert_eq!(bytes, s.into());\n}\n\= nlet s =3D \"hello\".to_string();\nis_hello(s);\n```\n\n[`String`]: ../../s= td/string/struct.String.html\n[`Vec`]: ../../std/vec/struct.Vec.html") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Into" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Into") :additionalTextEdits []) (:label "IntoIterator" :kind 8 :documentation (:kind "markdown" :value "Conversion into an [`Iterator`].\n\nBy impl= ementing `IntoIterator` for a type, you define how it will be\nconverted to= an iterator. This is common for types which describe a\ncollection of some= kind.\n\nOne benefit of implementing `IntoIterator` is that your type will= [work\nwith Rust's `for` loop syntax](crate::iter#for-loops-and-intoiterat= or).\n\nSee also: [`FromIterator`].\n\n# Examples\n\nBasic usage:\n\n```rus= t\nlet v =3D [1, 2, 3];\nlet mut iter =3D v.into_iter();\n\nassert_eq!(Some= (1), iter.next());\nassert_eq!(Some(2), iter.next());\nassert_eq!(Some(3), = iter.next());\nassert_eq!(None, iter.next());\n```\nImplementing `IntoItera= tor` for your type:\n\n```rust\n// A sample collection, that's just a wrapp= er over Vec\n#[derive(Debug)]\nstruct MyCollection(Vec);\n\n// Let'= s give it some methods so we can create one and add things\n// to it.\nimpl= MyCollection {\n fn new() -> MyCollection {\n MyCollection(Vec::= new())\n }\n\n fn add(&mut self, elem: i32) {\n self.0.push(el= em);\n }\n}\n\n// and we'll implement IntoIterator\nimpl IntoIterator fo= r MyCollection {\n type Item =3D i32;\n type IntoIter =3D std::vec::I= ntoIter;\n\n fn into_iter(self) -> Self::IntoIter {\n = self.0.into_iter()\n }\n}\n\n// Now we can make a new collection...\nle= t mut c =3D MyCollection::new();\n\n// ... add some stuff to it ...\nc.add(= 0);\nc.add(1);\nc.add(2);\n\n// ... and then turn it into an Iterator:\nfor= (i, n) in c.into_iter().enumerate() {\n assert_eq!(i as i32, n);\n}\n``= `\n\nIt is common to use `IntoIterator` as a trait bound. This allows\nthe = input collection type to change, so long as it is still an\niterator. Addit= ional bounds can be specified by restricting on\n`Item`:\n\n```rust\nfn col= lect_as_strings(collection: T) -> Vec\nwhere\n T: IntoIterato= r,\n T::Item: std::fmt::Debug,\n{\n collection\n .into_iter()\= n .map(|item| format!(\"{item:?}\"))\n .collect()\n}\n```") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "IntoIterator" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "IntoIterator") :additionalTextEdits []) (:label "Iterator" :kind 8 :documentation (:kind "markdown" :value "A trait for dealing with iterators.\n\nThis= is the main iterator trait. For more about the concept of iterators\ngener= ally, please see the [module-level documentation]. In particular, you\nmay = want to know how to [implement `Iterator`][impl].\n\n[module-level document= ation]: crate::iter\n[impl]: crate::iter#implementing-iterator") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Iterator" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Iterator") :additionalTextEdits []) (:label "Option" :kind 13 :detail "Option<{unknown}>" :documentation (:kind "markdown" :value "The `Option` type. See [the module level do= cumentation](self) for more.") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Option" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Option") :additionalTextEdits []) (:label "Ord (alias <, >, <=3D, >=3D)" :kind 8 :documentation (:kind "markdown" :value "Trait for types that form a [total order](h= ttps://en.wikipedia.org/wiki/Total_order).\n\nImplementations must be consi= stent with the [`PartialOrd`] implementation, and ensure\n`max`, `min`, and= `clamp` are consistent with `cmp`:\n\n- `partial_cmp(a, b) =3D=3D Some(cmp= (a, b))`.\n- `max(a, b) =3D=3D max_by(a, b, cmp)` (ensured by the default i= mplementation).\n- `min(a, b) =3D=3D min_by(a, b, cmp)` (ensured by the def= ault implementation).\n- For `a.clamp(min, max)`, see the [method docs](#me= thod.clamp)\n (ensured by the default implementation).\n\nIt's easy to acc= identally make `cmp` and `partial_cmp` disagree by\nderiving some of the tr= aits and manually implementing others.\n\nViolating these requirements is a= logic error. The behavior resulting from a logic error is not\nspecified, = but users of the trait must ensure that such logic errors do *not* result i= n\nundefined behavior. This means that `unsafe` code **must not** rely on t= he correctness of these\nmethods.\n\n## Corollaries\n\nFrom the above and t= he requirements of `PartialOrd`, it follows that for\nall `a`, `b` and `c`:= \n\n- exactly one of `a < b`, `a =3D=3D b` or `a > b` is true; and\n- `<` i= s transitive: `a < b` and `b < c` implies `a < c`. The same must hold for b= oth `=3D=3D` and `>`.\n\nMathematically speaking, the `<` operator defines = a strict [weak order]. In\ncases where `=3D=3D` conforms to mathematical eq= uality, it also defines a\nstrict [total order].\n\n[weak order]: https://e= n.wikipedia.org/wiki/Weak_ordering\n[total order]: https://en.wikipedia.org= /wiki/Total_order\n\n## Derivable\n\nThis trait can be used with `#[derive]= `.\n\nWhen `derive`d on structs, it will produce a\n[lexicographic](https:/= /en.wikipedia.org/wiki/Lexicographic_order) ordering\nbased on the top-to-b= ottom declaration order of the struct's members.\n\nWhen `derive`d on enums= , variants are ordered primarily by their discriminants.\nSecondarily, they= are ordered by their fields.\nBy default, the discriminant is smallest for= variants at the top, and\nlargest for variants at the bottom. Here's an ex= ample:\n\n```rust\n#[derive(PartialEq, Eq, PartialOrd, Ord)]\nenum E {\n = Top,\n Bottom,\n}\n\nassert!(E::Top < E::Bottom);\n```\n\nHowever, manu= ally setting the discriminants can override this default\nbehavior:\n\n```r= ust\n#[derive(PartialEq, Eq, PartialOrd, Ord)]\nenum E {\n Top =3D 2,\n = Bottom =3D 1,\n}\n\nassert!(E::Bottom < E::Top);\n```\n\n## Lexicographi= cal comparison\n\nLexicographical comparison is an operation with the follo= wing properties:\n - Two sequences are compared element by element.\n - The= first mismatching element defines which sequence is lexicographically less= or greater than the other.\n - If one sequence is a prefix of another, the= shorter sequence is lexicographically less than the other.\n - If two sequ= ences have equivalent elements and are of the same length, then the sequenc= es are lexicographically equal.\n - An empty sequence is lexicographically = less than any non-empty sequence.\n - Two empty sequences are lexicographic= ally equal.\n\n## How can I implement `Ord`?\n\n`Ord` requires that the typ= e also be [`PartialOrd`] and [`Eq`] (which requires [`PartialEq`]).\n\nThen= you must define an implementation for [`cmp`]. You may find it useful to u= se\n[`cmp`] on your type's fields.\n\nHere's an example where you want to s= ort people by height only, disregarding `id`\nand `name`:\n\n```rust\nuse s= td::cmp::Ordering;\n\n#[derive(Eq)]\nstruct Person {\n id: u32,\n nam= e: String,\n height: u32,\n}\n\nimpl Ord for Person {\n fn cmp(&self,= other: &Self) -> Ordering {\n self.height.cmp(&other.height)\n }= \n}\n\nimpl PartialOrd for Person {\n fn partial_cmp(&self, other: &Self= ) -> Option {\n Some(self.cmp(other))\n }\n}\n\nimpl Pa= rtialEq for Person {\n fn eq(&self, other: &Self) -> bool {\n sel= f.height =3D=3D other.height\n }\n}\n```\n\n[`cmp`]: Ord::cmp") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Ord" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Ord") :additionalTextEdits []) (:label "PartialEq (alias =3D=3D, !=3D)" :kind 8 :documentation (:kind "markdown" :value "Trait for comparisons using the equality op= erator.\n\nImplementing this trait for types provides the `=3D=3D` and `!= =3D` operators for\nthose types.\n\n`x.eq(y)` can also be written `x =3D=3D= y`, and `x.ne(y)` can be written `x !=3D y`.\nWe use the easier-to-read in= fix notation in the remainder of this documentation.\n\nThis trait allows f= or comparisons using the equality operator, for types\nthat do not have a f= ull equivalence relation. For example, in floating point\nnumbers `NaN !=3D= NaN`, so floating point types implement `PartialEq` but not\n[`trait@Eq`].= Formally speaking, when `Rhs =3D=3D Self`, this trait corresponds\nto a [p= artial equivalence relation].\n\n[partial equivalence relation]: https://en= .wikipedia.org/wiki/Partial_equivalence_relation\n\nImplementations must en= sure that `eq` and `ne` are consistent with each other:\n\n- `a !=3D b` if = and only if `!(a =3D=3D b)`.\n\nThe default implementation of `ne` provides= this consistency and is almost\nalways sufficient. It should not be overri= dden without very good reason.\n\nIf [`PartialOrd`] or [`Ord`] are also imp= lemented for `Self` and `Rhs`, their methods must also\nbe consistent with = `PartialEq` (see the documentation of those traits for the exact\nrequireme= nts). It's easy to accidentally make them disagree by deriving some of the = traits and\nmanually implementing others.\n\nThe equality relation `=3D=3D`= must satisfy the following conditions\n(for all `a`, `b`, `c` of type `A`,= `B`, `C`):\n\n- **Symmetry**: if `A: PartialEq` and `B: PartialEq`, = then **`a =3D=3D b`\n implies `b =3D=3D a`**; and\n\n- **Transitivity**: i= f `A: PartialEq` and `B: PartialEq` and `A:\n PartialEq`, then **= `a =3D=3D b` and `b =3D=3D c` implies `a =3D=3D c`**.\n This must also wor= k for longer chains, such as when `A: PartialEq`, `B: PartialEq`,\n = `C: PartialEq`, and `A: PartialEq` all exist.\n\nNote that the `B: Pa= rtialEq` (symmetric) and `A: PartialEq`\n(transitive) impls are not f= orced to exist, but these requirements apply\nwhenever they do exist.\n\nVi= olating these requirements is a logic error. The behavior resulting from a = logic error is not\nspecified, but users of the trait must ensure that such= logic errors do *not* result in\nundefined behavior. This means that `unsa= fe` code **must not** rely on the correctness of these\nmethods.\n\n## Cros= s-crate considerations\n\nUpholding the requirements stated above can becom= e tricky when one crate implements `PartialEq`\nfor a type of another crate= (i.e., to allow comparing one of its own types with a type from the\nstand= ard library). The recommendation is to never implement this trait for a for= eign type. In\nother words, such a crate should do `impl PartialEq for LocalType`, but it should\n*not* do `impl PartialEq for= ForeignType`.\n\nThis avoids the problem of transitive chains that criss-c= ross crate boundaries: for all local\ntypes `T`, you may assume that no oth= er crate will add `impl`s that allow comparing `T =3D=3D U`. In\nother word= s, if other crates add `impl`s that allow building longer transitive chains= `U1 =3D=3D ...\n=3D=3D T =3D=3D V1 =3D=3D ...`, then all the types that ap= pear to the right of `T` must be types that the\ncrate defining `T` already= knows about. This rules out transitive chains where downstream crates\ncan= add new `impl`s that \"stitch together\" comparisons of foreign types in w= ays that violate\ntransitivity.\n\nNot having such foreign `impl`s also avo= ids forward compatibility issues where one crate adding\nmore `PartialEq` i= mplementations can cause build failures in downstream crates.\n\n## Derivab= le\n\nThis trait can be used with `#[derive]`. When `derive`d on structs, t= wo\ninstances are equal if all fields are equal, and not equal if any field= s\nare not equal. When `derive`d on enums, two instances are equal if they\= nare the same variant and all fields are equal.\n\n## How can I implement `= PartialEq`?\n\nAn example implementation for a domain in which two books ar= e considered\nthe same book if their ISBN matches, even if the formats diff= er:\n\n```rust\nenum BookFormat {\n Paperback,\n Hardback,\n Ebook= ,\n}\n\nstruct Book {\n isbn: i32,\n format: BookFormat,\n}\n\nimpl P= artialEq for Book {\n fn eq(&self, other: &Self) -> bool {\n self= .isbn =3D=3D other.isbn\n }\n}\n\nlet b1 =3D Book { isbn: 3, format: Boo= kFormat::Paperback };\nlet b2 =3D Book { isbn: 3, format: BookFormat::Ebook= };\nlet b3 =3D Book { isbn: 10, format: BookFormat::Paperback };\n\nassert= !(b1 =3D=3D b2);\nassert!(b1 !=3D b3);\n```\n\n## How can I compare two dif= ferent types?\n\nThe type you can compare with is controlled by `PartialEq`= 's type parameter.\nFor example, let's tweak our previous code a bit:\n\n``= `rust\n// The derive implements =3D=3D comparison= s\n#[derive(PartialEq)]\nenum BookFormat {\n Paperback,\n Hardback,\n= Ebook,\n}\n\nstruct Book {\n isbn: i32,\n format: BookFormat,\n}\= n\n// Implement =3D=3D comparisons\nimpl PartialEq for Book {\n fn eq(&self, other: &BookFormat) -> bool {\n = self.format =3D=3D *other\n }\n}\n\n// Implement =3D=3D comparisons\nimpl PartialEq for BookFormat {\n fn eq(&self, o= ther: &Book) -> bool {\n *self =3D=3D other.format\n }\n}\n\nlet = b1 =3D Book { isbn: 3, format: BookFormat::Paperback };\n\nassert!(b1 =3D= =3D BookFormat::Paperback);\nassert!(BookFormat::Ebook !=3D b1);\n```\n\nBy= changing `impl PartialEq for Book` to `impl PartialEq for Book= `,\nwe allow `BookFormat`s to be compared with `Book`s.\n\nA comparison lik= e the one above, which ignores some fields of the struct,\ncan be dangerous= . It can easily lead to an unintended violation of the\nrequirements for a = partial equivalence relation. For example, if we kept\nthe above implementa= tion of `PartialEq` for `BookFormat` and added an\nimplementation of = `PartialEq` for `Book` (either via a `#[derive]` or\nvia the manual i= mplementation from the first example) then the result would\nviolate transi= tivity:\n\n```rust\n#[derive(PartialEq)]\nenum BookFormat {\n Paperback,= \n Hardback,\n Ebook,\n}\n\n#[derive(PartialEq)]\nstruct Book {\n = isbn: i32,\n format: BookFormat,\n}\n\nimpl PartialEq for Bo= ok {\n fn eq(&self, other: &BookFormat) -> bool {\n self.format = =3D=3D *other\n }\n}\n\nimpl PartialEq for BookFormat {\n fn eq= (&self, other: &Book) -> bool {\n *self =3D=3D other.format\n }\n= }\n\nfn main() {\n let b1 =3D Book { isbn: 1, format: BookFormat::Paperb= ack };\n let b2 =3D Book { isbn: 2, format: BookFormat::Paperback };\n\n= assert!(b1 =3D=3D BookFormat::Paperback);\n assert!(BookFormat::Pape= rback =3D=3D b2);\n\n // The following should hold by transitivity but d= oesn't.\n assert!(b1 =3D=3D b2); // <-- PANICS\n}\n```\n\n# Examples\n\n= ```rust\nlet x: u32 =3D 0;\nlet y: u32 =3D 1;\n\nassert_eq!(x =3D=3D y, fal= se);\nassert_eq!(x.eq(&y), false);\n```\n\n[`eq`]: PartialEq::eq\n[`ne`]: P= artialEq::ne") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "PartialEq" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "PartialEq") :additionalTextEdits []) (:label "PartialOrd (alias >, <, <=3D, >=3D)" :kind 8 :documentation (:kind "markdown" :value "Trait for types that form a [partial order]= (https://en.wikipedia.org/wiki/Partial_order).\n\nThe `lt`, `le`, `gt`, and= `ge` methods of this trait can be called using\nthe `<`, `<=3D`, `>`, and = `>=3D` operators, respectively.\n\nThe methods of this trait must be consis= tent with each other and with those of [`PartialEq`].\nThe following condit= ions must hold:\n\n1. `a =3D=3D b` if and only if `partial_cmp(a, b) =3D=3D= Some(Equal)`.\n2. `a < b` if and only if `partial_cmp(a, b) =3D=3D Some(Le= ss)`\n3. `a > b` if and only if `partial_cmp(a, b) =3D=3D Some(Greater)`\n4= . `a <=3D b` if and only if `a < b || a =3D=3D b`\n5. `a >=3D b` if and onl= y if `a > b || a =3D=3D b`\n6. `a !=3D b` if and only if `!(a =3D=3D b)`.\n= \nConditions 2=E2=80=935 above are ensured by the default implementation.\n= Condition 6 is already ensured by [`PartialEq`].\n\nIf [`Ord`] is also impl= emented for `Self` and `Rhs`, it must also be consistent with\n`partial_cmp= ` (see the documentation of that trait for the exact requirements). It's\ne= asy to accidentally make them disagree by deriving some of the traits and m= anually\nimplementing others.\n\nThe comparison relations must satisfy the = following conditions\n(for all `a`, `b`, `c` of type `A`, `B`, `C`):\n\n- *= *Transitivity**: if `A: PartialOrd` and `B: PartialOrd` and `A:\n Pa= rtialOrd`, then `a < b` and `b < c` implies `a < c`. The same must hold = for both `=3D=3D` and `>`.\n This must also work for longer chains, such a= s when `A: PartialOrd`, `B: PartialOrd`,\n `C: PartialOrd`, and `= A: PartialOrd` all exist.\n- **Duality**: if `A: PartialOrd` and `B: = PartialOrd`, then `a < b` if and only if `b > a`.\n\nNote that the `B: P= artialOrd` (dual) and `A: PartialOrd`\n(transitive) impls are not for= ced to exist, but these requirements apply\nwhenever they do exist.\n\nViol= ating these requirements is a logic error. The behavior resulting from a lo= gic error is not\nspecified, but users of the trait must ensure that such l= ogic errors do *not* result in\nundefined behavior. This means that `unsafe= ` code **must not** rely on the correctness of these\nmethods.\n\n## Cross-= crate considerations\n\nUpholding the requirements stated above can become = tricky when one crate implements `PartialOrd`\nfor a type of another crate = (i.e., to allow comparing one of its own types with a type from the\nstanda= rd library). The recommendation is to never implement this trait for a fore= ign type. In\nother words, such a crate should do `impl PartialOrd for LocalType`, but it should\n*not* do `impl PartialOrd fo= r ForeignType`.\n\nThis avoids the problem of transitive chains that criss-= cross crate boundaries: for all local\ntypes `T`, you may assume that no ot= her crate will add `impl`s that allow comparing `T < U`. In\nother words, i= f other crates add `impl`s that allow building longer transitive chains `U1= < ...\n< T < V1 < ...`, then all the types that appear to the right of `T`= must be types that the crate\ndefining `T` already knows about. This rules= out transitive chains where downstream crates can\nadd new `impl`s that \"= stitch together\" comparisons of foreign types in ways that violate\ntransi= tivity.\n\nNot having such foreign `impl`s also avoids forward compatibilit= y issues where one crate adding\nmore `PartialOrd` implementations can caus= e build failures in downstream crates.\n\n## Corollaries\n\nThe following c= orollaries follow from the above requirements:\n\n- irreflexivity of `<` an= d `>`: `!(a < a)`, `!(a > a)`\n- transitivity of `>`: if `a > b` and `b > c= ` then `a > c`\n- duality of `partial_cmp`: `partial_cmp(a, b) =3D=3D parti= al_cmp(b, a).map(Ordering::reverse)`\n\n## Strict and non-strict partial or= ders\n\nThe `<` and `>` operators behave according to a *strict* partial or= der.\nHowever, `<=3D` and `>=3D` do **not** behave according to a *non-stri= ct*\npartial order.\nThat is because mathematically, a non-strict partial o= rder would require\nreflexivity, i.e. `a <=3D a` would need to be true for = every `a`. This isn't\nalways the case for types that implement `PartialOrd= `, for example:\n\n```rust\nlet a =3D f64::sqrt(-1.0);\nassert_eq!(a <=3D a= , false);\n```\n\n## Derivable\n\nThis trait can be used with `#[derive]`.\= n\nWhen `derive`d on structs, it will produce a\n[lexicographic](https://en= .wikipedia.org/wiki/Lexicographic_order) ordering\nbased on the top-to-bott= om declaration order of the struct's members.\n\nWhen `derive`d on enums, v= ariants are primarily ordered by their discriminants.\nSecondarily, they ar= e ordered by their fields.\nBy default, the discriminant is smallest for va= riants at the top, and\nlargest for variants at the bottom. Here's an examp= le:\n\n```rust\n#[derive(PartialEq, PartialOrd)]\nenum E {\n Top,\n B= ottom,\n}\n\nassert!(E::Top < E::Bottom);\n```\n\nHowever, manually setting= the discriminants can override this default\nbehavior:\n\n```rust\n#[deriv= e(PartialEq, PartialOrd)]\nenum E {\n Top =3D 2,\n Bottom =3D 1,\n}\n= \nassert!(E::Bottom < E::Top);\n```\n\n## How can I implement `PartialOrd`?= \n\n`PartialOrd` only requires implementation of the [`partial_cmp`] method= , with the others\ngenerated from default implementations.\n\nHowever it re= mains possible to implement the others separately for types which do not ha= ve a\ntotal order. For example, for floating point numbers, `NaN < 0 =3D=3D= false` and `NaN >=3D 0 =3D=3D\nfalse` (cf. IEEE 754-2008 section 5.11).\n\= n`PartialOrd` requires your type to be [`PartialEq`].\n\nIf your type is [`= Ord`], you can implement [`partial_cmp`] by using [`cmp`]:\n\n```rust\nuse = std::cmp::Ordering;\n\n#[derive(Eq)]\nstruct Person {\n id: u32,\n na= me: String,\n height: u32,\n}\n\nimpl PartialOrd for Person {\n fn pa= rtial_cmp(&self, other: &Self) -> Option {\n Some(self.cmp= (other))\n }\n}\n\nimpl Ord for Person {\n fn cmp(&self, other: &Self= ) -> Ordering {\n self.height.cmp(&other.height)\n }\n}\n\nimpl P= artialEq for Person {\n fn eq(&self, other: &Self) -> bool {\n se= lf.height =3D=3D other.height\n }\n}\n```\n\nYou may also find it useful= to use [`partial_cmp`] on your type's fields. Here\nis an example of `Pers= on` types who have a floating-point `height` field that\nis the only field = to be used for sorting:\n\n```rust\nuse std::cmp::Ordering;\n\nstruct Perso= n {\n id: u32,\n name: String,\n height: f64,\n}\n\nimpl PartialOr= d for Person {\n fn partial_cmp(&self, other: &Self) -> Option= {\n self.height.partial_cmp(&other.height)\n }\n}\n\nimpl Partia= lEq for Person {\n fn eq(&self, other: &Self) -> bool {\n self.he= ight =3D=3D other.height\n }\n}\n```\n\n# Examples\n\n```rust\nlet x: u3= 2 =3D 0;\nlet y: u32 =3D 1;\n\nassert_eq!(x < y, true);\nassert_eq!(x.lt(&y= ), true);\n```\n\n[`partial_cmp`]: PartialOrd::partial_cmp\n[`cmp`]: Ord::c= mp") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "PartialOrd" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "PartialOrd") :additionalTextEdits []) (:label "Result" :kind 13 :detail "Result<{unknown}, {unknown}>" :docu= mentation (:kind "markdown" :value "`Result` is a type that represents either s= uccess ([`Ok`]) or failure ([`Err`]).\n\nSee the [module documentation](sel= f) for details.") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Result" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Result") :additionalTextEdits []) (:label "RustcDecodable" :kind 18 :deprecated :json-false :preselect t= :sortText "ffffffef" :filterText "RustcDecodable" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "RustcDecodable") :additionalTextEdits []) (:label "RustcEncodable" :kind 18 :deprecated :json-false :preselect t= :sortText "ffffffef" :filterText "RustcEncodable" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "RustcEncodable") :additionalTextEdits []) (:label "Send" :kind 8 :documentation (:kind "markdown" :value "Types that can be transferred across thread= boundaries.\n\nThis trait is automatically implemented when the compiler d= etermines it's\nappropriate.\n\nAn example of a non-`Send` type is the refe= rence-counting pointer\n[`rc::Rc`][`Rc`]. If two threads attempt to clone [= `Rc`]s that point to the same\nreference-counted value, they might try to u= pdate the reference count at the\nsame time, which is [undefined behavior][= ub] because [`Rc`] doesn't use atomic\noperations. Its cousin [`sync::Arc`]= [arc] does use atomic operations (incurring\nsome overhead) and thus is `Se= nd`.\n\nSee [the Nomicon](../../nomicon/send-and-sync.html) and the [`Sync`= ] trait for more details.\n\n[`Rc`]: ../../std/rc/struct.Rc.html\n[arc]: ..= /../std/sync/struct.Arc.html\n[ub]: ../../reference/behavior-considered-und= efined.html") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Send" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Send") :additionalTextEdits []) (:label "Sized (alias ?)" :kind 8 :documentation (:kind "markdown" :value "Types with a constant size known at compile= time.\n\nAll type parameters have an implicit bound of `Sized`. The specia= l syntax\n`?Sized` can be used to remove this bound if it's not appropriate= .\n\n```rust\nstruct Foo(T);\nstruct Bar(T);\n\n// struct Foo= Use(Foo<[i32]>); // error: Sized is not implemented for [i32]\nstruct BarUs= e(Bar<[i32]>); // OK\n```\n\nThe one exception is the implicit `Self` type = of a trait. A trait does not\nhave an implicit `Sized` bound as this is inc= ompatible with [trait object]s\nwhere, by definition, the trait needs to wo= rk with all possible implementors,\nand thus could be any size.\n\nAlthough= Rust will let you bind `Sized` to a trait, you won't\nbe able to use it to= form a trait object later:\n\n```rust\ntrait Foo { }\ntrait Bar: Sized { }= \n\nstruct Impl;\nimpl Foo for Impl { }\nimpl Bar for Impl { }\n\nlet x: &d= yn Foo =3D &Impl; // OK\n// let y: &dyn Bar =3D &Impl; // error: the tra= it `Bar` cannot\n // be made into an object\n```= \n\n[trait object]: ../../book/ch17-02-trait-objects.html") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Sized" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Sized") :additionalTextEdits []) (:label "String" :kind 22 :detail "String" :documentation (:kind "markdown" :value "A UTF-8=E2=80=93encoded, growable string.\n= \n`String` is the most common string type. It has ownership over the conten= ts\nof the string, stored in a heap-allocated buffer (see [Representation](= #representation)).\nIt is closely related to its borrowed counterpart, the = primitive [`str`].\n\n# Examples\n\nYou can create a `String` from [a liter= al string][`&str`] with [`String::from`]:\n\n[`String::from`]: From::from\n= \n```rust\nlet hello =3D String::from(\"Hello, world!\");\n```\n\nYou can a= ppend a [`char`] to a `String` with the [`push`] method, and\nappend a [`&s= tr`] with the [`push_str`] method:\n\n```rust\nlet mut hello =3D String::fr= om(\"Hello, \");\n\nhello.push('w');\nhello.push_str(\"orld!\");\n```\n\n[`= push`]: String::push\n[`push_str`]: String::push_str\n\nIf you have a vecto= r of UTF-8 bytes, you can create a `String` from it with\nthe [`from_utf8`]= method:\n\n```rust\n// some bytes, in a vector\nlet sparkle_heart =3D vec!= [240, 159, 146, 150];\n\n// We know these bytes are valid, so we'll use `un= wrap()`.\nlet sparkle_heart =3D String::from_utf8(sparkle_heart).unwrap();\= n\nassert_eq!(\"=F0=9F=92=96\", sparkle_heart);\n```\n\n[`from_utf8`]: Stri= ng::from_utf8\n\n# UTF-8\n\n`String`s are always valid UTF-8. If you need a= non-UTF-8 string, consider\n[`OsString`]. It is similar, but without the U= TF-8 constraint. Because UTF-8\nis a variable width encoding, `String`s are= typically smaller than an array of\nthe same `chars`:\n\n```rust\nuse std:= :mem;\n\n// `s` is ASCII which represents each `char` as one byte\nlet s = =3D \"hello\";\nassert_eq!(s.len(), 5);\n\n// A `char` array with the same = contents would be longer because\n// every `char` is four bytes\nlet s =3D = ['h', 'e', 'l', 'l', 'o'];\nlet size: usize =3D s.into_iter().map(|c| mem::= size_of_val(&c)).sum();\nassert_eq!(size, 20);\n\n// However, for non-ASCII= strings, the difference will be smaller\n// and sometimes they are the sam= e\nlet s =3D \"=F0=9F=92=96=F0=9F=92=96=F0=9F=92=96=F0=9F=92=96=F0=9F=92=96= \";\nassert_eq!(s.len(), 20);\n\nlet s =3D ['=F0=9F=92=96', '=F0=9F=92=96',= '=F0=9F=92=96', '=F0=9F=92=96', '=F0=9F=92=96'];\nlet size: usize =3D s.in= to_iter().map(|c| mem::size_of_val(&c)).sum();\nassert_eq!(size, 20);\n```\= n\nThis raises interesting questions as to how `s[i]` should work.\nWhat sh= ould `i` be here? Several options include byte indices and\n`char` indices = but, because of UTF-8 encoding, only byte indices\nwould provide constant t= ime indexing. Getting the `i`th `char`, for\nexample, is available using [`= chars`]:\n\n```rust\nlet s =3D \"hello\";\nlet third_character =3D s.chars(= ).nth(2);\nassert_eq!(third_character, Some('l'));\n\nlet s =3D \"=F0=9F=92= =96=F0=9F=92=96=F0=9F=92=96=F0=9F=92=96=F0=9F=92=96\";\nlet third_character= =3D s.chars().nth(2);\nassert_eq!(third_character, Some('=F0=9F=92=96'));\= n```\n\nNext, what should `s[i]` return? Because indexing returns a referen= ce\nto underlying data it could be `&u8`, `&[u8]`, or something else simila= r.\nSince we're only providing one index, `&u8` makes the most sense but th= at\nmight not be what the user expects and can be explicitly achieved with\= n[`as_bytes()`]:\n\n```rust\n// The first byte is 104 - the byte value of `= 'h'`\nlet s =3D \"hello\";\nassert_eq!(s.as_bytes()[0], 104);\n// or\nasser= t_eq!(s.as_bytes()[0], b'h');\n\n// The first byte is 240 which isn't obvio= usly useful\nlet s =3D \"=F0=9F=92=96=F0=9F=92=96=F0=9F=92=96=F0=9F=92=96= =F0=9F=92=96\";\nassert_eq!(s.as_bytes()[0], 240);\n```\n\nDue to these amb= iguities/restrictions, indexing with a `usize` is simply\nforbidden:\n\n```= rust\nlet s =3D \"hello\";\n\n// The following will not compile!\nprintln!(= \"The first letter of s is {}\", s[0]);\n```\n\nIt is more clear, however, = how `&s[i..j]` should work (that is,\nindexing with a range). It should acc= ept byte indices (to be constant-time)\nand return a `&str` which is UTF-8 = encoded. This is also called \"string slicing\".\nNote this will panic if t= he byte indices provided are not character\nboundaries - see [`is_char_boun= dary`] for more details. See the implementations\nfor [`SliceIndex`] f= or more details on string slicing. For a non-panicking\nversion of string s= licing, see [`get`].\n\n[`OsString`]: ../../std/ffi/struct.OsString.html \"= ffi::OsString\"\n[`SliceIndex`]: core::slice::SliceIndex\n[`as_bytes()= `]: str::as_bytes\n[`get`]: str::get\n[`is_char_boundary`]: str::is_char_bo= undary\n\nThe [`bytes`] and [`chars`] methods return iterators over the byt= es and\ncodepoints of the string, respectively. To iterate over codepoints = along\nwith byte indices, use [`char_indices`].\n\n[`bytes`]: str::bytes\n[= `chars`]: str::chars\n[`char_indices`]: str::char_indices\n\n# Deref\n\n`St= ring` implements [Deref], and so inherits al= l of [`str`]'s\nmethods. In addition, this means that you can pass a `Strin= g` to a\nfunction which takes a [`&str`] by using an ampersand (`&`):\n\n``= `rust\nfn takes_str(s: &str) { }\n\nlet s =3D String::from(\"Hello\");\n\nt= akes_str(&s);\n```\n\nThis will create a [`&str`] from the `String` and pas= s it in. This\nconversion is very inexpensive, and so generally, functions = will accept\n[`&str`]s as arguments unless they need a `String` for some sp= ecific\nreason.\n\nIn certain cases Rust doesn't have enough information to= make this\nconversion, known as [`Deref`] coercion. In the following examp= le a string\nslice [`&'a str`][`&str`] implements the trait `TraitExample`,= and the function\n`example_func` takes anything that implements the trait.= In this case Rust\nwould need to make two implicit conversions, which Rust= doesn't have the\nmeans to do. For that reason, the following example will= not compile.\n\n```rust\ntrait TraitExample {}\n\nimpl<'a> TraitExample fo= r &'a str {}\n\nfn example_func(example_arg: A) {}\n\nlet = example_string =3D String::from(\"example_string\");\nexample_func(&example= _string);\n```\n\nThere are two options that would work instead. The first = would be to\nchange the line `example_func(&example_string);` to\n`example_= func(example_string.as_str());`, using the method [`as_str()`]\nto explicit= ly extract the string slice containing the string. The second\nway changes = `example_func(&example_string);` to\n`example_func(&*example_string);`. In = this case we are dereferencing a\n`String` to a [`str`], then referencing t= he [`str`] back to\n[`&str`]. The second way is more idiomatic, however bot= h work to do the\nconversion explicitly rather than relying on the implicit= conversion.\n\n# Representation\n\nA `String` is made up of three componen= ts: a pointer to some bytes, a\nlength, and a capacity. The pointer points = to the internal buffer which `String`\nuses to store its data. The length i= s the number of bytes currently stored\nin the buffer, and the capacity is = the size of the buffer in bytes. As such,\nthe length will always be less t= han or equal to the capacity.\n\nThis buffer is always stored on the heap.\= n\nYou can look at these with the [`as_ptr`], [`len`], and [`capacity`]\nme= thods:\n\n```rust\nuse std::mem;\n\nlet story =3D String::from(\"Once upon = a time...\");\n\n// Prevent automatically dropping the String's data\nlet m= ut story =3D mem::ManuallyDrop::new(story);\n\nlet ptr =3D story.as_mut_ptr= ();\nlet len =3D story.len();\nlet capacity =3D story.capacity();\n\n// sto= ry has nineteen bytes\nassert_eq!(19, len);\n\n// We can re-build a String = out of ptr, len, and capacity. This is all\n// unsafe because we are respon= sible for making sure the components are\n// valid:\nlet s =3D unsafe { Str= ing::from_raw_parts(ptr, len, capacity) } ;\n\nassert_eq!(String::from(\"On= ce upon a time...\"), s);\n```\n\n[`as_ptr`]: str::as_ptr\n[`len`]: String:= :len\n[`capacity`]: String::capacity\n\nIf a `String` has enough capacity, = adding elements to it will not\nre-allocate. For example, consider this pro= gram:\n\n```rust\nlet mut s =3D String::new();\n\nprintln!(\"{}\", s.capaci= ty());\n\nfor _ in 0..5 {\n s.push_str(\"hello\");\n println!(\"{}\",= s.capacity());\n}\n```\n\nThis will output the following:\n\n```text\n0\n8= \n16\n16\n32\n32\n```\n\nAt first, we have no memory allocated at all, but = as we append to the\nstring, it increases its capacity appropriately. If we= instead use the\n[`with_capacity`] method to allocate the correct capacity= initially:\n\n```rust\nlet mut s =3D String::with_capacity(25);\n\nprintln= !(\"{}\", s.capacity());\n\nfor _ in 0..5 {\n s.push_str(\"hello\");\n = println!(\"{}\", s.capacity());\n}\n```\n\n[`with_capacity`]: String::wit= h_capacity\n\nWe end up with a different output:\n\n```text\n25\n25\n25\n25= \n25\n25\n```\n\nHere, there's no need to allocate more memory inside the l= oop.\n\n[str]: prim@str \"str\"\n[`str`]: prim@str \"str\"\n[`&str`]: prim@= str \"&str\"\n[Deref]: core::ops::Deref \"ops::Deref\"\n[`Deref`]: core::op= s::Deref \"ops::Deref\"\n[`as_str()`]: String::as_str") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "String" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "String") :additionalTextEdits []) (:label "Sync" :kind 8 :documentation (:kind "markdown" :value "Types for which it is safe to share referen= ces between threads.\n\nThis trait is automatically implemented when the co= mpiler determines\nit's appropriate.\n\nThe precise definition is: a type `= T` is [`Sync`] if and only if `&T` is\n[`Send`]. In other words, if there i= s no possibility of\n[undefined behavior][ub] (including data races) when p= assing\n`&T` references between threads.\n\nAs one would expect, primitive = types like [`u8`] and [`f64`]\nare all [`Sync`], and so are simple aggregat= e types containing them,\nlike tuples, structs and enums. More examples of = basic [`Sync`]\ntypes include \"immutable\" types like `&T`, and those with= simple\ninherited mutability, such as [`Box`][box], [`Vec`][vec] and= \nmost other collection types. (Generic parameters need to be [`Sync`]\nfor= their container to be [`Sync`].)\n\nA somewhat surprising consequence of t= he definition is that `&mut T`\nis `Sync` (if `T` is `Sync`) even though it= seems like that might\nprovide unsynchronized mutation. The trick is that = a mutable\nreference behind a shared reference (that is, `& &mut T`)\nbecom= es read-only, as if it were a `& &T`. Hence there is no risk\nof a data rac= e.\n\nA shorter overview of how [`Sync`] and [`Send`] relate to referencing= :\n* `&T` is [`Send`] if and only if `T` is [`Sync`]\n* `&mut T` is [`Send`= ] if and only if `T` is [`Send`]\n* `&T` and `&mut T` are [`Sync`] if and o= nly if `T` is [`Sync`]\n\nTypes that are not `Sync` are those that have \"i= nterior\nmutability\" in a non-thread-safe form, such as [`Cell`][cell]\nan= d [`RefCell`][refcell]. These types allow for mutation of\ntheir contents e= ven through an immutable, shared reference. For\nexample the `set` method o= n [`Cell`][cell] takes `&self`, so it requires\nonly a shared reference = [`&Cell`][cell]. The method performs no\nsynchronization, thus [`Cell`][= cell] cannot be `Sync`.\n\nAnother example of a non-`Sync` type is the refe= rence-counting\npointer [`Rc`][rc]. Given any reference [`&Rc`][rc], you= can clone\na new [`Rc`][rc], modifying the reference counts in a non-at= omic way.\n\nFor cases when one does need thread-safe interior mutability,\= nRust provides [atomic data types], as well as explicit locking via\n[`sync= ::Mutex`][mutex] and [`sync::RwLock`][rwlock]. These types\nensure that any= mutation cannot cause data races, hence the types\nare `Sync`. Likewise, [= `sync::Arc`][arc] provides a thread-safe\nanalogue of [`Rc`][rc].\n\nAny ty= pes with interior mutability must also use the\n[`cell::UnsafeCell`][unsafe= cell] wrapper around the value(s) which\ncan be mutated through a shared re= ference. Failing to doing this is\n[undefined behavior][ub]. For example, [= `transmute`][transmute]-ing\nfrom `&T` to `&mut T` is invalid.\n\nSee [the = Nomicon][nomicon-send-and-sync] for more details about `Sync`.\n\n[box]: ..= /../std/boxed/struct.Box.html\n[vec]: ../../std/vec/struct.Vec.html\n[cell]= : crate::cell::Cell\n[refcell]: crate::cell::RefCell\n[rc]: ../../std/rc/st= ruct.Rc.html\n[arc]: ../../std/sync/struct.Arc.html\n[atomic data types]: c= rate::sync::atomic\n[mutex]: ../../std/sync/struct.Mutex.html\n[rwlock]: ..= /../std/sync/struct.RwLock.html\n[unsafecell]: crate::cell::UnsafeCell\n[ub= ]: ../../reference/behavior-considered-undefined.html\n[transmute]: crate::= mem::transmute\n[nomicon-send-and-sync]: ../../nomicon/send-and-sync.html") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Sync" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Sync") :additionalTextEdits []) (:label "ToOwned" :kind 8 :documentation (:kind "markdown" :value "A generalization of `Clone` to borrowed dat= a.\n\nSome types make it possible to go from borrowed to owned, usually by\= nimplementing the `Clone` trait. But `Clone` works only for going from `&T`= \nto `T`. The `ToOwned` trait generalizes `Clone` to construct owned data\n= from any borrow of a given type.") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "ToOwned" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "ToOwned") :additionalTextEdits []) (:label "ToString" :kind 8 :documentation (:kind "markdown" :value "A trait for converting a value to a `String= `.\n\nThis trait is automatically implemented for any type which implements= the\n[`Display`] trait. As such, `ToString` shouldn't be implemented direc= tly:\n[`Display`] should be implemented instead, and you get the `ToString`= \nimplementation for free.\n\n[`Display`]: fmt::Display") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "ToString" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "ToString") :additionalTextEdits []) (:label "TryFrom" :kind 8 :documentation (:kind "markdown" :value "Simple and safe type conversions that may f= ail in a controlled\nway under some circumstances. It is the reciprocal of = [`TryInto`].\n\nThis is useful when you are doing a type conversion that ma= y\ntrivially succeed but may also need special handling.\nFor example, ther= e is no way to convert an [`i64`] into an [`i32`]\nusing the [`From`] trait= , because an [`i64`] may contain a value\nthat an [`i32`] cannot represent = and so the conversion would lose data.\nThis might be handled by truncating= the [`i64`] to an [`i32`] or by\nsimply returning [`i32::MAX`], or by some= other method. The [`From`]\ntrait is intended for perfect conversions, so= the `TryFrom` trait\ninforms the programmer when a type conversion could g= o bad and lets\nthem decide how to handle it.\n\n# Generic Implementations\= n\n- `TryFrom for U` implies [`TryInto`]` for T`\n- [`try_from`] is r= eflexive, which means that `TryFrom for T`\nis implemented and cannot fa= il -- the associated `Error` type for\ncalling `T::try_from()` on a value o= f type `T` is [`Infallible`].\nWhen the [`!`] type is stabilized [`Infallib= le`] and [`!`] will be\nequivalent.\n\n`TryFrom` can be implemented as f= ollows:\n\n```rust\nstruct GreaterThanZero(i32);\n\nimpl TryFrom for G= reaterThanZero {\n type Error =3D &'static str;\n\n fn try_from(value= : i32) -> Result {\n if value <=3D 0 {\n = Err(\"GreaterThanZero only accepts values greater than zero!\")\n = } else {\n Ok(GreaterThanZero(value))\n }\n }\n}\n```= \n\n# Examples\n\nAs described, [`i32`] implements `TryFrom<`[`i64`]`>`:\n\= n```rust\nlet big_number =3D 1_000_000_000_000i64;\n// Silently truncates `= big_number`, requires detecting\n// and handling the truncation after the f= act.\nlet smaller_number =3D big_number as i32;\nassert_eq!(smaller_number,= -727379968);\n\n// Returns an error because `big_number` is too big to\n//= fit in an `i32`.\nlet try_smaller_number =3D i32::try_from(big_number);\na= ssert!(try_smaller_number.is_err());\n\n// Returns `Ok(3)`.\nlet try_succes= sful_smaller_number =3D i32::try_from(3);\nassert!(try_successful_smaller_n= umber.is_ok());\n```\n\n[`try_from`]: TryFrom::try_from") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "TryFrom" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "TryFrom") :additionalTextEdits []) (:label "TryInto" :kind 8 :documentation (:kind "markdown" :value "An attempted conversion that consumes `self= `, which may or may not be\nexpensive.\n\nLibrary authors should usually no= t directly implement this trait,\nbut should prefer implementing the [`TryF= rom`] trait, which offers\ngreater flexibility and provides an equivalent `= TryInto`\nimplementation for free, thanks to a blanket implementation in th= e\nstandard library. For more information on this, see the\ndocumentation f= or [`Into`].\n\n# Implementing `TryInto`\n\nThis suffers the same restricti= ons and reasoning as implementing\n[`Into`], see there for details.") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "TryInto" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "TryInto") :additionalTextEdits []) (:label "Unpin" :kind 8 :documentation (:kind "markdown" :value "Types that do not require any pinning guara= ntees.\n\nFor information on what \"pinning\" is, see the [`pin` module] do= cumentation.\n\nImplementing the `Unpin` trait for `T` expresses the fact t= hat `T` is pinning-agnostic:\nit shall not expose nor rely on any pinning g= uarantees. This, in turn, means that a\n`Pin`-wrapped pointer to such a typ= e can feature a *fully unrestricted* API.\nIn other words, if `T: Unpin`, a= value of type `T` will *not* be bound by the invariants\nwhich pinning oth= erwise offers, even when \"pinned\" by a [`Pin`] pointing at it.\nWhen= a value of type `T` is pointed at by a [`Pin`], [`Pin`] will not rest= rict access\nto the pointee value like it normally would, thus allowing the= user to do anything that they\nnormally could with a non-[`Pin`]-wrapped `= Ptr` to that value.\n\nThe idea of this trait is to alleviate the reduced e= rgonomics of APIs that require the use\nof [`Pin`] for soundness for some t= ypes, but which also want to be used by other types that\ndon't care about = pinning. The prime example of such an API is [`Future::poll`]. There are ma= ny\n[`Future`] types that don't care about pinning. These futures can imple= ment `Unpin` and\ntherefore get around the pinning related restrictions in = the API, while still allowing the\nsubset of [`Future`]s which *do* require= pinning to be implemented soundly.\n\nFor more discussion on the consequen= ces of [`Unpin`] within the wider scope of the pinning\nsystem, see the [se= ction about `Unpin`] in the [`pin` module].\n\n`Unpin` has no consequence a= t all for non-pinned data. In particular, [`mem::replace`] happily\nmoves `= !Unpin` data, which would be immovable when pinned ([`mem::replace`] works = for any\n`&mut T`, not just when `T: Unpin`).\n\n*However*, you cannot use = [`mem::replace`] on `!Unpin` data which is *pinned* by being wrapped\ninsid= e a [`Pin`] pointing at it. This is because you cannot (safely) use a\= n[`Pin`] to get an `&mut T` to its pointee value, which you would need= to call\n[`mem::replace`], and *that* is what makes this system work.\n\nS= o this, for example, can only be done on types implementing `Unpin`:\n\n```= rust\nuse std::mem;\nuse std::pin::Pin;\n\nlet mut string =3D \"this\".to_s= tring();\nlet mut pinned_string =3D Pin::new(&mut string);\n\n// We need a = mutable reference to call `mem::replace`.\n// We can obtain such a referenc= e by (implicitly) invoking `Pin::deref_mut`,\n// but that is only possible = because `String` implements `Unpin`.\nmem::replace(&mut *pinned_string, \"o= ther\".to_string());\n```\n\nThis trait is automatically implemented for al= most every type. The compiler is free\nto take the conservative stance of m= arking types as [`Unpin`] so long as all of the types that\ncompose its fie= lds are also [`Unpin`]. This is because if a type implements [`Unpin`], the= n it\nis unsound for that type's implementation to rely on pinning-related = guarantees for soundness,\n*even* when viewed through a \"pinning\" pointer= ! It is the responsibility of the implementor of\na type that relies upon p= inning for soundness to ensure that type is *not* marked as [`Unpin`]\nby a= dding [`PhantomPinned`] field. For more details, see the [`pin` module] doc= s.\n\n[`mem::replace`]: crate::mem::replace \"mem replace\"\n[`Future`]: cr= ate::future::Future \"Future\"\n[`Future::poll`]: crate::future::Future::po= ll \"Future poll\"\n[`Pin`]: crate::pin::Pin \"Pin\"\n[`Pin`]: crate::= pin::Pin \"Pin\"\n[`pin` module]: crate::pin \"pin module\"\n[section about= `Unpin`]: crate::pin#unpin \"pin module docs about unpin\"\n[`unsafe`]: ..= /../std/keyword.unsafe.html \"keyword unsafe\"") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Unpin" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Unpin") :additionalTextEdits []) (:label "Vec" :kind 22 :detail "Vec<{unknown}, {unknown}>" :documentat= ion (:kind "markdown" :value "A contiguous growable array type, written a= s `Vec`, short for 'vector'.\n\n# Examples\n\n```rust\nlet mut vec =3D V= ec::new();\nvec.push(1);\nvec.push(2);\n\nassert_eq!(vec.len(), 2);\nassert= _eq!(vec[0], 1);\n\nassert_eq!(vec.pop(), Some(2));\nassert_eq!(vec.len(), = 1);\n\nvec[0] =3D 7;\nassert_eq!(vec[0], 7);\n\nvec.extend([1, 2, 3]);\n\nf= or x in &vec {\n println!(\"{x}\");\n}\nassert_eq!(vec, [7, 1, 2, 3]);\n= ```\n\nThe [`vec!`] macro is provided for convenient initialization:\n\n```= rust\nlet mut vec1 =3D vec![1, 2, 3];\nvec1.push(4);\nlet vec2 =3D Vec::fro= m([1, 2, 3, 4]);\nassert_eq!(vec1, vec2);\n```\n\nIt can also initialize ea= ch element of a `Vec` with a given value.\nThis may be more efficient th= an performing allocation and initialization\nin separate steps, especially = when initializing a vector of zeros:\n\n```rust\nlet vec =3D vec![0; 5];\na= ssert_eq!(vec, [0, 0, 0, 0, 0]);\n\n// The following is equivalent, but pot= entially slower:\nlet mut vec =3D Vec::with_capacity(5);\nvec.resize(5, 0);= \nassert_eq!(vec, [0, 0, 0, 0, 0]);\n```\n\nFor more information, see\n[Cap= acity and Reallocation](#capacity-and-reallocation).\n\nUse a `Vec` as a= n efficient stack:\n\n```rust\nlet mut stack =3D Vec::new();\n\nstack.push(= 1);\nstack.push(2);\nstack.push(3);\n\nwhile let Some(top) =3D stack.pop() = {\n // Prints 3, 2, 1\n println!(\"{top}\");\n}\n```\n\n# Indexing\n\= nThe `Vec` type allows access to values by index, because it implements the= \n[`Index`] trait. An example will be more explicit:\n\n```rust\nlet v =3D = vec![0, 2, 4, 6];\nprintln!(\"{}\", v[1]); // it will display '2'\n```\n\nH= owever be careful: if you try to access an index which isn't in the `Vec`,\= nyour software will panic! You cannot do this:\n\n```rust\nlet v =3D vec![0= , 2, 4, 6];\nprintln!(\"{}\", v[6]); // it will panic!\n```\n\nUse [`get`] = and [`get_mut`] if you want to check whether the index is in\nthe `Vec`.\n\= n# Slicing\n\nA `Vec` can be mutable. On the other hand, slices are read-on= ly objects.\nTo get a [slice][prim@slice], use [`&`]. Example:\n\n```rust\n= fn read_slice(slice: &[usize]) {\n // ...\n}\n\nlet v =3D vec![0, 1];\nr= ead_slice(&v);\n\n// ... and that's all!\n// you can also do it like this:\= nlet u: &[usize] =3D &v;\n// or like this:\nlet u: &[_] =3D &v;\n```\n\nIn = Rust, it's more common to pass slices as arguments rather than vectors\nwhe= n you just want to provide read access. The same goes for [`String`] and\n[= `&str`].\n\n# Capacity and reallocation\n\nThe capacity of a vector is the = amount of space allocated for any future\nelements that will be added onto = the vector. This is not to be confused with\nthe *length* of a vector, whic= h specifies the number of actual elements\nwithin the vector. If a vector's= length exceeds its capacity, its capacity\nwill automatically be increased= , but its elements will have to be\nreallocated.\n\nFor example, a vector w= ith capacity 10 and length 0 would be an empty vector\nwith space for 10 mo= re elements. Pushing 10 or fewer elements onto the\nvector will not change = its capacity or cause reallocation to occur. However,\nif the vector's leng= th is increased to 11, it will have to reallocate, which\ncan be slow. For = this reason, it is recommended to use [`Vec::with_capacity`]\nwhenever poss= ible to specify how big the vector is expected to get.\n\n# Guarantees\n\nD= ue to its incredibly fundamental nature, `Vec` makes a lot of guarantees\na= bout its design. This ensures that it's as low-overhead as possible in\nthe= general case, and can be correctly manipulated in primitive ways\nby unsaf= e code. Note that these guarantees refer to an unqualified `Vec`.\nIf ad= ditional type parameters are added (e.g., to support custom allocators),\no= verriding their defaults may change the behavior.\n\nMost fundamentally, `V= ec` is and always will be a (pointer, capacity, length)\ntriplet. No more, = no less. The order of these fields is completely\nunspecified, and you shou= ld use the appropriate methods to modify these.\nThe pointer will never be = null, so this type is null-pointer-optimized.\n\nHowever, the pointer might= not actually point to allocated memory. In particular,\nif you construct a= `Vec` with capacity 0 via [`Vec::new`], [`vec![]`][`vec!`],\n[`Vec::with_c= apacity(0)`][`Vec::with_capacity`], or by calling [`shrink_to_fit`]\non an = empty Vec, it will not allocate memory. Similarly, if you store zero-sized\= ntypes inside a `Vec`, it will not allocate space for them. *Note that in t= his case\nthe `Vec` might not report a [`capacity`] of 0*. `Vec` will alloc= ate if and only\nif [mem::size_of::\\]\\() * [capacity]\\() > 0. In general, `Vec`'s allocation\ndetails are very subtle --- if you in= tend to allocate memory using a `Vec`\nand use it for something else (eithe= r to pass to unsafe code, or to build your\nown memory-backed collection), = be sure to deallocate this memory by using\n`from_raw_parts` to recover the= `Vec` and then dropping it.\n\nIf a `Vec` *has* allocated memory, then the= memory it points to is on the heap\n(as defined by the allocator Rust is c= onfigured to use by default), and its\npointer points to [`len`] initialize= d, contiguous elements in order (what\nyou would see if you coerced it to a= slice), followed by [capacity] - [len]\nlogically uninitializ= ed, contiguous elements.\n\nA vector containing the elements `'a'` and `'b'= ` with capacity 4 can be\nvisualized as below. The top part is the `Vec` st= ruct, it contains a\npointer to the head of the allocation in the heap, len= gth and capacity.\nThe bottom part is the allocation on the heap, a contigu= ous memory block.\n\n```text\n ptr len capacity\n +-= -------+--------+--------+\n | 0x0123 | 2 | 4 |\n +--= ------+--------+--------+\n |\n v\nHeap +--------+-= -------+--------+--------+\n | 'a' | 'b' | uninit | uninit |\n = +--------+--------+--------+--------+\n```\n\n- **uninit** represents= memory that is not initialized, see [`MaybeUninit`].\n- Note: the ABI is n= ot stable and `Vec` makes no guarantees about its memory\n layout (includi= ng the order of fields).\n\n`Vec` will never perform a \"small optimization= \" where elements are actually\nstored on the stack for two reasons:\n\n* I= t would make it more difficult for unsafe code to correctly manipulate\n a= `Vec`. The contents of a `Vec` wouldn't have a stable address if it were\n= only moved, and it would be more difficult to determine if a `Vec` had\n = actually allocated memory.\n\n* It would penalize the general case, incurr= ing an additional branch\n on every access.\n\n`Vec` will never automatica= lly shrink itself, even if completely empty. This\nensures no unnecessary a= llocations or deallocations occur. Emptying a `Vec`\nand then filling it ba= ck up to the same [`len`] should incur no calls to\nthe allocator. If you w= ish to free up unused memory, use\n[`shrink_to_fit`] or [`shrink_to`].\n\n[= `push`] and [`insert`] will never (re)allocate if the reported capacity is\= nsufficient. [`push`] and [`insert`] *will* (re)allocate if\n[len] = =3D=3D [capacity]. That is, the reported capacity is completely\nacc= urate, and can be relied on. It can even be used to manually free the memor= y\nallocated by a `Vec` if desired. Bulk insertion methods *may* reallocate= , even\nwhen not necessary.\n\n`Vec` does not guarantee any particular grow= th strategy when reallocating\nwhen full, nor when [`reserve`] is called. T= he current strategy is basic\nand it may prove desirable to use a non-const= ant growth factor. Whatever\nstrategy is used will of course guarantee *O*(= 1) amortized [`push`].\n\n`vec![x; n]`, `vec![a, b, c, d]`, and\n[`Vec::wit= h_capacity(n)`][`Vec::with_capacity`], will all produce a `Vec`\nwith at le= ast the requested capacity. If [len] =3D=3D [capacity],\n(as i= s the case for the [`vec!`] macro), then a `Vec` can be converted to\nan= d from a [`Box<[T]>`][owned slice] without reallocating or moving the eleme= nts.\n\n`Vec` will not specifically overwrite any data that is removed from= it,\nbut also won't specifically preserve it. Its uninitialized memory is\= nscratch space that it may use however it wants. It will generally just do\= nwhatever is most efficient or otherwise easy to implement. Do not rely on\= nremoved data to be erased for security purposes. Even if you drop a `Vec`,= its\nbuffer may simply be reused by another allocation. Even if you zero a= `Vec`'s memory\nfirst, that might not actually happen because the optimize= r does not consider\nthis a side-effect that must be preserved. There is on= e case which we will\nnot break, however: using `unsafe` code to write to t= he excess capacity,\nand then increasing the length to match, is always val= id.\n\nCurrently, `Vec` does not guarantee the order in which elements are = dropped.\nThe order has changed in the past and may change again.\n\n[`get`= ]: slice::get\n[`get_mut`]: slice::get_mut\n[`String`]: crate::string::Stri= ng\n[`&str`]: type@str\n[`shrink_to_fit`]: Vec::shrink_to_fit\n[`shrink_to`= ]: Vec::shrink_to\n[capacity]: Vec::capacity\n[`capacity`]: Vec::capacity\n= [mem::size_of::\\]: core::mem::size_of\n[len]: Vec::len\n[`len`]: Vec::l= en\n[`push`]: Vec::push\n[`insert`]: Vec::insert\n[`reserve`]: Vec::reserve= \n[`MaybeUninit`]: core::mem::MaybeUninit\n[owned slice]: Box") :deprecated :json-false :preselect t :sortText "ffffffef" :filterText= "Vec" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "Vec") :additionalTextEdits []) (:label "alloc_error_handler" :kind 18 :deprecated :json-false :presel= ect t :sortText "ffffffef" :filterText "alloc_error_handler" :textEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "alloc_error_handler") :additionalTextEdits [])])) [client-notification] Mon Sep 16 12:50:08 2024: (:jsonrpc "2.0" :method "textDocument/didChange" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs" :version 1) :contentChanges [(:range (:start (:line 4 :character 17) :end (:line 4 :character 17)) :rangeLength 0 :text " (use std::collections::HashSet)")])) [client-request] (id:13) Mon Sep 16 12:50:08 2024: (:jsonrpc "2.0" :id 13 :method "completionItem/resolve" :params (:label #("HashSet (use std::collections::HashSet)" 0 1 (eglot--lsp-item #1)) :kind 22 :detail "HashSet<{unknown}, {unknown}>" :documentation (:kind "markdown" :value "A [hash set] implemented as a `HashMap` where= the value is `()`.\n\nAs with the [`HashMap`] type, a `HashSet` requires t= hat the elements\nimplement the [`Eq`] and [`Hash`] traits. This can freque= ntly be achieved by\nusing `#[derive(PartialEq, Eq, Hash)]`. If you impleme= nt these yourself,\nit is important that the following property holds:\n\n`= ``text\nk1 =3D=3D k2 -> hash(k1) =3D=3D hash(k2)\n```\n\nIn other words, if= two keys are equal, their hashes must be equal.\nViolating this property i= s a logic error.\n\nIt is also a logic error for a key to be modified in su= ch a way that the key's\nhash, as determined by the [`Hash`] trait, or its = equality, as determined by\nthe [`Eq`] trait, changes while it is in the ma= p. This is normally only\npossible through [`Cell`], [`RefCell`], global st= ate, I/O, or unsafe code.\n\nThe behavior resulting from either logic error= is not specified, but will\nbe encapsulated to the `HashSet` that observed= the logic error and not\nresult in undefined behavior. This could include = panics, incorrect results,\naborts, memory leaks, and non-termination.\n\n#= Examples\n\n```rust\nuse std::collections::HashSet;\n// Type inference let= s us omit an explicit type signature (which\n// would be `HashSet` = in this example).\nlet mut books =3D HashSet::new();\n\n// Add some books.\= nbooks.insert(\"A Dance With Dragons\".to_string());\nbooks.insert(\"To Kil= l a Mockingbird\".to_string());\nbooks.insert(\"The Odyssey\".to_string());= \nbooks.insert(\"The Great Gatsby\".to_string());\n\n// Check for a specifi= c one.\nif !books.contains(\"The Winds of Winter\") {\n println!(\"We ha= ve {} books, but The Winds of Winter ain't one.\",\n books.len(= ));\n}\n\n// Remove a book.\nbooks.remove(\"The Odyssey\");\n\n// Iterate o= ver everything.\nfor book in &books {\n println!(\"{book}\");\n}\n```\n\= nThe easiest way to use `HashSet` with a custom type is to derive\n[`Eq`] a= nd [`Hash`]. We must also derive [`PartialEq`],\nwhich is required if [`Eq`= ] is derived.\n\n```rust\nuse std::collections::HashSet;\n#[derive(Hash, Eq= , PartialEq, Debug)]\nstruct Viking {\n name: String,\n power: usize,= \n}\n\nlet mut vikings =3D HashSet::new();\n\nvikings.insert(Viking { name:= \"Einar\".to_string(), power: 9 });\nvikings.insert(Viking { name: \"Einar= \".to_string(), power: 9 });\nvikings.insert(Viking { name: \"Olaf\".to_str= ing(), power: 4 });\nvikings.insert(Viking { name: \"Harald\".to_string(), = power: 8 });\n\n// Use derived implementation to print the vikings.\nfor x = in &vikings {\n println!(\"{x:?}\");\n}\n```\n\nA `HashSet` with a known= list of items can be initialized from an array:\n\n```rust\nuse std::colle= ctions::HashSet;\n\nlet viking_names =3D HashSet::from([\"Einar\", \"Olaf\"= , \"Harald\"]);\n```\n\n[hash set]: crate::collections#use-the-set-variant-= of-any-of-these-maps-when\n[`HashMap`]: crate::collections::HashMap\n[`RefC= ell`]: crate::cell::RefCell\n[`Cell`]: crate::cell::Cell") :deprecated :json-false :sortText "fffffff0" :filterText "HashSet" :tex= tEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "HashSet") :additionalTextEdits [] :data (:position (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 17)) :imports [(:full_import_path "std::collections::HashSet" :imported_name "HashSe= t")] :version 0))) [client-notification] Mon Sep 16 12:50:08 2024: (:jsonrpc "2.0" :method "workspace/didChangeWatchedFiles" :params (:changes [(:uri "file:///home/brennan/test_rust/src/brennan@taipei.1664968%3A172= 6418014" :type 1)])) [server-reply] (id:13) Mon Sep 16 12:50:08 2024: (:jsonrpc "2.0" :id 13 :result (:label "HashSet (use std::collections::HashSet)" :kind 22 :detail "Hash= Set<{unknown}, {unknown}>" :documentation (:kind "markdown" :value "A [hash set] implemented as a `HashMap` where= the value is `()`.\n\nAs with the [`HashMap`] type, a `HashSet` requires t= hat the elements\nimplement the [`Eq`] and [`Hash`] traits. This can freque= ntly be achieved by\nusing `#[derive(PartialEq, Eq, Hash)]`. If you impleme= nt these yourself,\nit is important that the following property holds:\n\n`= ``text\nk1 =3D=3D k2 -> hash(k1) =3D=3D hash(k2)\n```\n\nIn other words, if= two keys are equal, their hashes must be equal.\nViolating this property i= s a logic error.\n\nIt is also a logic error for a key to be modified in su= ch a way that the key's\nhash, as determined by the [`Hash`] trait, or its = equality, as determined by\nthe [`Eq`] trait, changes while it is in the ma= p. This is normally only\npossible through [`Cell`], [`RefCell`], global st= ate, I/O, or unsafe code.\n\nThe behavior resulting from either logic error= is not specified, but will\nbe encapsulated to the `HashSet` that observed= the logic error and not\nresult in undefined behavior. This could include = panics, incorrect results,\naborts, memory leaks, and non-termination.\n\n#= Examples\n\n```rust\nuse std::collections::HashSet;\n// Type inference let= s us omit an explicit type signature (which\n// would be `HashSet` = in this example).\nlet mut books =3D HashSet::new();\n\n// Add some books.\= nbooks.insert(\"A Dance With Dragons\".to_string());\nbooks.insert(\"To Kil= l a Mockingbird\".to_string());\nbooks.insert(\"The Odyssey\".to_string());= \nbooks.insert(\"The Great Gatsby\".to_string());\n\n// Check for a specifi= c one.\nif !books.contains(\"The Winds of Winter\") {\n println!(\"We ha= ve {} books, but The Winds of Winter ain't one.\",\n books.len(= ));\n}\n\n// Remove a book.\nbooks.remove(\"The Odyssey\");\n\n// Iterate o= ver everything.\nfor book in &books {\n println!(\"{book}\");\n}\n```\n\= nThe easiest way to use `HashSet` with a custom type is to derive\n[`Eq`] a= nd [`Hash`]. We must also derive [`PartialEq`],\nwhich is required if [`Eq`= ] is derived.\n\n```rust\nuse std::collections::HashSet;\n#[derive(Hash, Eq= , PartialEq, Debug)]\nstruct Viking {\n name: String,\n power: usize,= \n}\n\nlet mut vikings =3D HashSet::new();\n\nvikings.insert(Viking { name:= \"Einar\".to_string(), power: 9 });\nvikings.insert(Viking { name: \"Einar= \".to_string(), power: 9 });\nvikings.insert(Viking { name: \"Olaf\".to_str= ing(), power: 4 });\nvikings.insert(Viking { name: \"Harald\".to_string(), = power: 8 });\n\n// Use derived implementation to print the vikings.\nfor x = in &vikings {\n println!(\"{x:?}\");\n}\n```\n\nA `HashSet` with a known= list of items can be initialized from an array:\n\n```rust\nuse std::colle= ctions::HashSet;\n\nlet viking_names =3D HashSet::from([\"Einar\", \"Olaf\"= , \"Harald\"]);\n```\n\n[hash set]: crate::collections#use-the-set-variant-= of-any-of-these-maps-when\n[`HashMap`]: crate::collections::HashMap\n[`RefC= ell`]: crate::cell::RefCell\n[`Cell`]: crate::cell::Cell") :deprecated :json-false :sortText "fffffff0" :filterText "HashSet" :tex= tEdit (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :newText "HashSet") :additionalTextEdits [])) [client-notification] Mon Sep 16 12:50:08 2024: (:jsonrpc "2.0" :method "textDocument/didChange" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs" :version 4) :contentChanges [(:range (:start (:line 4 :character 17) :end (:line 4 :character 49)) :rangeLength 32 :text "") (:range (:start (:line 4 :character 10) :end (:line 4 :character 17)) :rangeLength 7 :text "") (:range (:start (:line 4 :character 10) :end (:line 4 :character 10)) :rangeLength 0 :text "HashSet")])) [client-request] (id:14) Mon Sep 16 12:50:08 2024: (:jsonrpc "2.0" :id 14 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 17))) [client-request] (id:15) Mon Sep 16 12:50:08 2024: (:jsonrpc "2.0" :id 15 :method "textDocument/hover" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 17))) [client-request] (id:16) Mon Sep 16 12:50:08 2024: (:jsonrpc "2.0" :id 16 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 17))) [server-reply] (id:15) Mon Sep 16 12:50:08 2024: (:jsonrpc "2.0" :id 15 :result nil) [server-reply] (id:16) Mon Sep 16 12:50:08 2024: (:jsonrpc "2.0" :id 16 :result nil) [server-reply] (id:14) Mon Sep 16 12:50:08 2024: (:jsonrpc "2.0" :id 14 :result (:signatures [(:label "struct S" :parameters [(:label [9 10])] :activeParameter 0)] :activeSignature 0 :activeParameter 0)) [client-request] (id:17) Mon Sep 16 12:50:09 2024: (:jsonrpc "2.0" :id 17 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 17))) [client-request] (id:18) Mon Sep 16 12:50:09 2024: (:jsonrpc "2.0" :id 18 :method "textDocument/hover" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 17))) [client-request] (id:19) Mon Sep 16 12:50:09 2024: (:jsonrpc "2.0" :id 19 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 17))) [client-request] (id:20) Mon Sep 16 12:50:09 2024: (:jsonrpc "2.0" :id 20 :method "textDocument/inlayHint" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :range (:start (:line 4 :character 0) :end (:line 8 :character 0)))) [server-reply] (id:17) Mon Sep 16 12:50:09 2024: (:jsonrpc "2.0" :id 17 :result (:signatures [(:label "struct S" :parameters [(:label [9 10])] :activeParameter 0)] :activeSignature 0 :activeParameter 0)) [server-reply] (id:18) Mon Sep 16 12:50:09 2024: (:jsonrpc "2.0" :id 18 :result nil) [server-reply] (id:19) Mon Sep 16 12:50:09 2024: (:jsonrpc "2.0" :id 19 :result nil) [server-reply] (id:20) Mon Sep 16 12:50:09 2024: (:jsonrpc "2.0" :id 20 :result []) [client-request] (id:21) Mon Sep 16 12:50:11 2024: (:jsonrpc "2.0" :id 21 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 17))) [client-request] (id:22) Mon Sep 16 12:50:11 2024: (:jsonrpc "2.0" :id 22 :method "textDocument/hover" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 17))) [client-request] (id:23) Mon Sep 16 12:50:11 2024: (:jsonrpc "2.0" :id 23 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///home/brennan/test_rust/src/main.rs") :position (:line 4 :character 17))) [server-reply] (id:21) Mon Sep 16 12:50:11 2024: (:jsonrpc "2.0" :id 21 :result (:signatures [(:label "struct S" :parameters [(:label [9 10])] :activeParameter 0)] :activeSignature 0 :activeParameter 0)) [server-reply] (id:22) Mon Sep 16 12:50:11 2024: (:jsonrpc "2.0" :id 22 :result nil) [server-reply] (id:23) Mon Sep 16 12:50:11 2024: (:jsonrpc "2.0" :id 23 :result nil) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > It should highlight what has changed in the client-server > communication, if anything. > > Jo=C3=A3o --=-=-=--