[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-size 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 :didSave 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 :tagSupport (: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 :implementationProvider t :referencesProvider t :documentHighlightProvider t :documentSymbolProvider t :workspaceSymbolProvider t :codeActionProvider (:codeActionKinds ["" "quickfix" "refactor" "refactor.extract" "refactor.inline" "refactor.rewrite"] :resolveProvider t) :codeLensProvider (:resolveProvider t) :documentFormattingProvider t :documentRangeFormattingProvider :json-false :documentOnTypeFormattingProvider (:firstTriggerCharacter "=" :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" "keyword" "macro" "method" "namespace" "number" "operator" "parameter" "property" "string" "struct" "typeParameter" "variable" "angle" "arithmetic" "attributeBracket" "attribute" "bitwise" "boolean" "brace" "bracket" "builtinAttribute" "builtinType" "character" "colon" "comma" "comparison" "constParameter" "const" "deriveHelper" "derive" "dot" "escapeSequence" "formatSpecifier" "generic" "invalidEscapeSequence" "label" "lifetime" "logical" "macroBang" "parenthesis" "procMacro" "punctuation" "selfKeyword" "selfTypeKeyword" "semicolon" "static" "toolModule" "typeAlias" "union" "unresolvedReference"] :tokenModifiers ["async" "documentation" "declaration" "static" "defaultLibrary" "associated" "attribute" "callable" "constant" "consuming" "controlFlow" "crateRoot" "injected" "intraDocLink" "library" "macro" "mutable" "procMacro" "public" "reference" "trait" "unsafe"]) :range t :full (:delta t)) :inlayHintProvider (:resolveProvider t) :experimental (:externalDocs t :hoverRange t :joinLines t :matchingBrace t :moveItem 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 :languageId "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-threshold 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/didChangeWatchedFiles" :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/library" :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/library" :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/library/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/library/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/library/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/library/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/library/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/library/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/library/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/library/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/library/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/library/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/library/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/library/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/library/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/library/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/library/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/library/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/library/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 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 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: src" :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 "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)" :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 :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::HashSet;\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::collections::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-false))) [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)" :percentage 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::HashSet;\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::collections::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/didChangeWatchedFiles" :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 -32801) [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 -32801) [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 -32801) [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/library" :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/library" :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/library/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/library/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/library/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/library/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/library/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/library/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/library/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/library/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/library/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/library/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/library/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/library/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/library/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/library/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)" :percentage 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/library/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/library/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/library/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 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 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: src" :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 "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::HashSet;\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::collections::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)" :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 :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)" :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 :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 "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 that the elements\nimplement the [`Eq`] and [`Hash`] traits. This can frequently be achieved by\nusing `#[derive(PartialEq, Eq, Hash)]`. If you implement these yourself,\nit is important that the following property holds:\n\n```text\nk1 == k2 -> hash(k1) == 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 its 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 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 lets us omit an explicit type signature (which\n// would be `HashSet` in this example).\nlet mut books = HashSet::new();\n\n// Add some books.\nbooks.insert(\"A Dance With Dragons\".to_string());\nbooks.insert(\"To Kill a Mockingbird\".to_string());\nbooks.insert(\"The Odyssey\".to_string());\nbooks.insert(\"The Great Gatsby\".to_string());\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```\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 [`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 = 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_string(), 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::collections::HashSet;\n\nlet viking_names = 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[`RefCell`]: crate::cell::RefCell\n[`Cell`]: crate::cell::Cell") :deprecated :json-false :sortText "fffffff0" :filterText "HashSet" :textEdit (: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 "HashSet")] :version 0)) (:label "self::" :kind 14 :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 "crate::" :kind 14 :deprecated :json-false :preselect t :sortText "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 "ffffffef" :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 :preselect 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 :json-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" :documentation (:kind "markdown" :value "Prints to the standard output, with a newline.\n\nOn all platforms, the newline is the LINE FEED character (`\\n`/`U+000A`) alone\n(no additional CARRIAGE RETURN (`\\r`/`U+000D`)).\n\nThis macro uses the same syntax as [`format!`], but writes to the standard output instead.\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 hot loop, this behavior 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\nlet mut lock = stdout().lock();\nwriteln!(lock, \"hello world\").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)\nfor details of the macro argument syntax.\n\n[`std::fmt`]: crate::fmt\n[`eprintln!`]: 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`]: crate::io::stdout\n\n# Examples\n\n```rust\nprintln!(); // prints just a newline\nprintln!(\"hello there!\");\nprintln!(\"format {} arguments\", \"some\");\nlet local_variable = \"some\";\nprintln!(\"format {local_variable} arguments\");\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 each 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 optimized build will not execute\n`debug_assert_eq!` statements unless `-C debug-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_assert_eq!` is always type checked.\n\n# Examples\n\n```rust\nlet a = 3;\nlet b = 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" :documentation (: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\nmodules are found). The provided path is interpreted in a platform-specific\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 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ós\n```\n\nFile 'main.rs':\n\n```rust\nfn main() {\n let my_str = include_str!(\"spanish.in\");\n assert_eq!(my_str, \"adiós\\n\");\n print!(\"{my_str}\");\n}\n```\n\nCompiling 'main.rs' and running the resulting binary will print \"adiós\".") :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 [stringified](core::stringify) in order to be\nconcatenated.\n\n# Examples\n\n```rust\nlet s = concat!(\"test\", 10, 'b', true);\nassert_eq!(s, \"test10btrue\");\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 runtime expressions.\n\nThe first argument `format!` receives is a format string. 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 documentation in `std::fmt`](../std/fmt/index.html)\nfor details.\n\nA common use for `format!` is concatenation and interpolation of strings.\nThe same convention is used with [`print!`] and [`write!`] macros,\ndepending on the intended 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 literals into a `&'static str`, use the [`concat!`] macro.\n\n[`print!`]: ../std/macro.print.html\n[`write!`]: core::write\n[`format_args!`]: core::format_args\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 implementation\nsince `fmt::Write for String` never returns an error itself.\n\n# Examples\n\n```rust\nformat!(\"test\"); // => \"test\"\nformat!(\"hello {}\", \"world!\"); // => \"hello world!\"\nformat!(\"x = {}, y = {val}\", 10, val = 30); // => \"x = 10, y = 30\"\nlet (x, y) = (1, 2);\nformat!(\"{x} + {y} = 3\"); // => \"1 + 2 = 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" :documentation (:kind "markdown" :value "Stringifies its arguments.\n\nThis macro will 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 rely on the output.\n\n# Examples\n\n```rust\nlet one_plus_one = 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" :documentation (: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 [`assert!`], this macro has a second form, where a custom\npanic message can be provided.\n\n# Examples\n\n```rust\nlet a = 3;\nlet b = 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 expression for quick and dirty\ndebugging.\n\nAn example:\n\n```rust\nlet a = 2;\nlet b = dbg!(a * 2) + 1;\n// ^-- prints: [src/main.rs:2:9] a * 2 = 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 in 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\nshould avoid having uses of it in version control for long periods\n(other than in tests and similar).\nDebug output from production code is better done with other facilities\nsuch as the [`debug!`] macro from the [`log`] crate.\n\n# Stability\n\nThe exact output printed by this macro should not be relied upon\nand is subject to future changes.\n\n# Panics\n\nPanics if writing to `io::stderr` fails.\n\n# Further examples\n\nWith a method call:\n\n```rust\nfn foo(n: usize) {\n if let Some(_) = 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) = None\n```\n\nNaive factorial implementation:\n\n```rust\nfn factorial(n: u32) -> u32 {\n if dbg!(n <= 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 <= 1 = false\n[src/main.rs:2:8] n <= 1 = false\n[src/main.rs:2:8] n <= 1 = false\n[src/main.rs:2:8] n <= 1 = true\n[src/main.rs:3:9] 1 = 1\n[src/main.rs:7:9] n * factorial(n - 1) = 2\n[src/main.rs:7:9] n * factorial(n - 1) = 6\n[src/main.rs:7:9] n * factorial(n - 1) = 24\n[src/main.rs:9:1] factorial(4) = 24\n```\n\nThe `dbg!(..)` macro moves the input:\n\n```rust\n/// A wrapper around `usize` which importantly is not Copyable.\n#[derive(Debug)]\nstruct NoCopy(usize);\n\nlet a = NoCopy(42);\nlet _ = dbg!(a); // <-- `a` is moved here.\nlet _ = dbg!(a); // <-- `a` is moved again; error!\n```\n\nYou can also use `dbg!()` without a value to just print the\nfile and line whenever 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!(dbg!(1usize, 2u32), (1, 2));\n```\n\nHowever, a single argument with a trailing comma will still not be treated\nas a tuple, following the convention of ignoring trailing commas in macro\ninvocations. You can use a 1-tuple directly 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://crates.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 expressions.\nThere are two forms of this macro:\n\n- Create a [`Vec`] containing a given list of elements:\n\n```rust\nlet v = 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 = vec![1; 3];\nassert_eq!(v, [1, 1, 1]);\n```\n\nNote that unlike array expressions this syntax supports all elements\nwhich implement [`Clone`] and the number of elements 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 nonstandard `Clone` implementation. For\nexample, `vec![Rc::new(1); 5]` will create a vector of five references\nto the same boxed integer value, not five 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" :documentation (:kind "markdown" :value "Parses a file as an expression or an item according 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-privacy.html).\n\nThe included file is placed in the surrounding code\n[unhygienically](https://doc.rust-lang.org/reference/macros-by-example.html#hygiene). If\nthe included file is parsed as an expression and variables or functions share names across\nboth files, it could result in variables or functions being different from what the\nincluded file expected.\n\nThe included file is located relative to the current file (similarly to how modules are\nfound). The provided path is interpreted in a platform-specific way at compile time. So,\nfor instance, an invocation with a Windows path containing backslashes `\\` would not\ncompile correctly on Unix.\n\n# Uses\n\nThe `include!` macro is primarily used for two purposes. It is used to include\ndocumentation that is written in a separate file and it is used to include [build artifacts\nusually as a result from the `build.rs`\nscript](https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script).\n\nWhen using the `include` macro to include stretches of documentation, remember that the\nincluded file still needs to be a valid Rust syntax. It is also possible to\nuse the [`include_str`] macro as `#![doc = include_str!(\"...\")]` (at the module level) or\n`#[doc = include_str!(\"...\")]` (at the item level) to include documentation from a plain\ntext or markdown 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['🙈', '🙊', '🙉']\n .iter()\n .cycle()\n .take(6)\n .collect::()\n```\n\nFile 'main.rs':\n\n```rust\nfn main() {\n let my_string = include!(\"monkeys.in\");\n assert_eq!(\"🙈🙊🙉🙈🙊🙉\", my_string);\n println!(\"{my_string}\");\n}\n```\n\nCompiling 'main.rs' and running the resulting binary will print\n\"🙈🙊🙉🙈🙊🙉\".") :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\nEquivalent to the [`println!`] macro except that a newline is not printed at\nthe end of the message.\n\nNote that stdout is frequently line-buffered by default 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 standard output on each call. If you call\n`print!` within a hot loop, this behavior 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\nlet mut lock = stdout().lock();\nwrite!(lock, \"hello world\").unwrap();\n```\n\nUse `print!` only for the primary output of your program. Use\n[`eprint!`] instead to print error and progress messages.\n\nSee [the formatting documentation in `std::fmt`](../std/fmt/index.html)\nfor details of the macro argument syntax.\n\n[flush]: crate::io::Write::flush\n[`println!`]: crate::println\n[`eprint!`]: crate::eprint\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# Examples\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\nio::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\nThis macro accepts a 'writer', a format string, and a list of arguments. Arguments will be\nformatted according to the specified format string and the result will be passed to the writer.\nThe writer may be any value with a `write_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::Result\n[`io::Result`]: ../std/io/type.Result.html\n\n# Examples\n\n```rust\nuse std::io::Write;\n\nfn main() -> std::io::Result<()> {\n let mut w = 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 between the trait names, such as by importing them as `_` or otherwise renaming\nthem:\n\n```rust\nuse std::fmt::Write as _;\nuse std::io::Write as _;\n\nfn main() -> Result<(), Box> {\n let mut s = String::new();\n let mut v = Vec::new();\n\n write!(&mut s, \"{} {}\", \"abc\", 123)?; // uses fmt::Write::write_fmt\n write!(&mut v, \"s = {:?}\", s)?; // uses io::Write::write_fmt\n assert_eq!(v, b\"s = \\\"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 containing 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) -> core::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\nuse core::fmt::Write;\n\nstruct Example;\n\nimpl Write for Example {\n fn write_str(&mut self, _s: &str) -> core::fmt::Result {\n unimplemented!();\n }\n}\n\nlet mut m = 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 expanded 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 first macro invocation leading up to the invocation\nof the `line!` macro.\n\n# Examples\n\n```rust\nlet current_line = line!();\nprintln!(\"defined on 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" :documentation (:kind "markdown" :value "Asserts that a boolean expression is `true` at runtime.\n\nThis will invoke the [`panic!`] macro if the provided expression cannot be\nevaluated to `true` at runtime.\n\nLike [`assert!`], this macro also has a second version, where a custom panic\nmessage can be provided.\n\n# Uses\n\nUnlike [`assert!`], `debug_assert!` statements are only enabled in non\noptimized builds by default. An optimized build will not execute\n`debug_assert!` statements unless `-C debug-assertions` is passed to the\ncompiler. This makes `debug_assert!` 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_assert!` is always type checked.\n\nAn unchecked assertion allows a program in an inconsistent state to keep\nrunning, which might have unexpected consequences but does not introduce\nunsafety as long as this only happens in safe code. The performance cost\nof assertions, however, is not measurable in general. Replacing [`assert!`]\nwith `debug_assert!` is thus only encouraged after thorough profiling, and\nmore 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 = true;\ndebug_assert!(x, \"x wasn't true!\");\n\nlet a = 3; let b = 27;\ndebug_assert!(a + b == 30, \"a = {}, b = {}\", 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 array.\n\nThe file is located relative to the current file (similarly to how\nmodules are found). The provided path is interpreted in a platform-specific\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 contents 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ós\n```\n\nFile 'main.rs':\n\n```rust\nfn main() {\n let bytes = include_bytes!(\"spanish.in\");\n assert_eq!(bytes, b\"adi\\xc3\\xb3s\\n\");\n print!(\"{}\", String::from_utf8_lossy(bytes));\n}\n```\n\nCompiling 'main.rs' and running the resulting binary will print \"adiós\".") :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 variable 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[`std::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 also be emitted if the\nenvironment variable is not a vaild Unicode string.\n\n# Examples\n\n```rust\nlet path: &'static str = 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\nparameter:\n\n```rust\nlet doc: &'static str = env!(\"documentation\", \"what's that?!\");\n```\n\nIf the `documentation` environment variable is not defined, 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 should 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][ris]: `r#try`.\n\n[propagating-errors]: https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html#a-shortcut-for-propagating-errors-the--operator\n[ris]: https://doc.rust-lang.org/nightly/rust-by-example/compatibility/raw_identifiers.html\n\n`try!` matches the given [`Result`]. In case 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\nbetween specialized errors and more general ones. The resulting\nerror is then immediately returned.\n\nBecause of the early return, `try!` can only be used 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 preferred method of quick returning Errors\nfn write_to_file_question() -> Result<(), MyError> {\n let mut file = File::create(\"my_best_friends.txt\")?;\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 = r#try!(File::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 = r#try!(File::create(\"my_best_friends.txt\"));\n match file.write_all(b\"This is a list of my best friends.\") {\n Ok(v) => v,\n Err(e) => return Err(From::from(e)),\n }\n Ok(())\n}\n```") :deprecated t :preselect t :sortText "ffffffef" :filterText "try!" :textEdit (: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 invoked.\n\nWith [`line!`] and [`column!`], these macros provide debugging information for\ndevelopers about the location within the source.\n\nThe expanded expression has type `&'static str`, and the returned file\nis not the invocation of the `file!` macro itself, but rather the\nfirst macro invocation leading up to the invocation of the `file!`\nmacro.\n\n# Examples\n\n```rust\nlet this_file = 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" :documentation (:kind "markdown" :value "Declare a new thread local storage key of type [`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, RefCell};\n\nthread_local! {\n pub static FOO: Cell = Cell::new(1);\n\n static BAR: RefCell> = 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 obtained, so a\ntype such as [`Cell`] or [`RefCell`] is typically used to allow mutating access.\n\nThis macro supports a special `const {}` syntax that can be used\nwhen the initialization expression can be evaluated as a constant.\nThis can enable a more efficient thread local implementation that\ncan avoid lazy initialization. For types that do not\n[need to be dropped][crate::mem::needs_drop], this can enable an\neven more efficient implementation that does not need to\ntrack any additional state.\n\n```rust\nuse std::cell::RefCell;\n\nthread_local! {\n pub static FOO: RefCell> = const { RefCell::new(Vec::new()) };\n}\n\nFOO.with_borrow(|v| assert_eq!(v.len(), 0));\n```\n\nSee [`LocalKey` documentation][`std::thread::LocalKey`] for more\ninformation.\n\n[`std::thread::LocalKey`]: crate::thread::LocalKey") :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 expression cannot be\nevaluated to `true` at runtime.\n\n# Uses\n\nAssertions are always checked in both debug and release builds, and cannot\nbe disabled. See [`debug_assert!`] for assertions that are not enabled in\nrelease builds by default.\n\nUnsafe code may rely on `assert!` to enforce run-time invariants that, if\nviolated could lead to unsafety.\n\nOther use-cases of `assert!` include testing and enforcing run-time\ninvariants in safe code (whose violation cannot result in unsafety).\n\n# Custom Messages\n\nThis macro 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 form. Expressions used as format arguments will only\nbe evaluated if the assertion fails.\n\n[`std::fmt`]: ../std/fmt/index.html\n\n# Examples\n\n```rust\n// the panic message for these assertions is the stringified value of the\n// expression given.\nassert!(true);\n\nfn some_computation() -> bool { true } // a very simple function\n\nassert!(some_computation());\n\n// assert with a custom message\nlet x = true;\nassert!(x, \"x wasn't true!\");\n\nlet a = 3; let b = 27;\nassert!(a + b == 30, \"a = {}, b = {}\", 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 was invoked.\n\nWith [`line!`] and [`file!`], these macros provide debugging information for\ndevelopers about the location within the source.\n\nThe expanded expression has type `u32` and is 1-based, so the first column\nin each line evaluates to 1, the second to 2, etc. This is consistent\nwith error 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!` macro.\n\n# Examples\n\n```rust\nlet current_col = 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 return the same value, but the third does not.\n\n```rust\nlet a = (\"foobar\", column!()).1;\nlet b = (\"人之初性本善\", column!()).1;\nlet c = (\"f̅o̅o̅b̅a̅r̅\", column!()).1; // Uses combining overline (U+0305)\n\nassert_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" :documentation (:kind "markdown" :value "Indicates unreachable code.\n\nThis is useful 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 dynamically terminate.\n* Iterators that dynamically terminate.\n\nIf the determination that the code is unreachable proves incorrect, the\nprogram immediately terminates with a [`panic!`].\n\nThe unsafe counterpart of this macro is the [`unreachable_unchecked`] function, which\nwill cause undefined behavior if the code is reached.\n\n[`unreachable_unchecked`]: crate::hint::unreachable_unchecked\n\n# Panics\n\nThis will always [`panic!`] because `unreachable!` 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 match x {\n Some(n) if n >= 0 => println!(\"Some(Non-negative)\"),\n Some(n) if n < 0 => println!(\"Some(Negative)\"),\n Some(_) => unreachable!(), // compile error if commented out\n None => println!(\"None\")\n }\n}\n```\n\nIterators:\n\n```rust\nfn divide_by_three(x: u32) -> u32 { // one of the poorest implementations of x/3\n for i in 0.. {\n if 3*i < i { panic!(\"u32 overflow\"); }\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" :documentation (:kind "markdown" :value "Prints to the standard error, with a newline.\n\nEquivalent to the [`println!`] macro, except that output goes to\n[`io::stderr`] instead of [`io::stdout`]. See [`println!`] for\nexample usage.\n\nUse `eprintln!` only for error and progress messages. Use `println!`\ninstead for the primary output of your program.\n\nSee [the formatting documentation in `std::fmt`](../std/fmt/index.html)\nfor details of the macro argument 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 with a message of \"not implemented\".\n\nThis allows your code to type-check, which is useful if you are prototyping or\nimplementing a trait that requires multiple methods which you don't plan to use all of.\n\nThe difference 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 \"not implemented\".\n\nAlso, some IDEs will mark `todo!`s.\n\n# Panics\n\nThis will always [`panic!`] because `unimplemented!` 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[`todo!`]: crate::todo\n\n# Examples\n\nSay 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` for 'MyStruct', but for some reason it only 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 still 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) -> Result {\n // We have some logic here,\n // We can add a message to unimplemented! to display our omission.\n // This will display:\n // \"thread 'main' panicked at 'not implemented: MyStruct isn't quxable'\".\n unimplemented!(\"MyStruct isn't quxable\");\n }\n}\n\nfn main() {\n let s = 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 configuration 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!`, unlike `#[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 `cfg!` 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 = 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 useful 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 functionality later and the message is \"not yet\nimplemented\", `unimplemented!` makes no such claims. Its message is \"not implemented\".\n\nAlso, some IDEs will 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# Examples\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 order 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 not yet quxable'\".\n todo!(\"MyStruct is not yet quxable\");\n }\n}\n\nfn main() {\n let s = 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" :documentation (:kind "markdown" :value "Expands to a string that represents the current module path.\n\nThe current module path can be thought of as the hierarchy 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" :documentation (:kind "markdown" :value "Optionally inspects an environment variable at compile time.\n\nIf the named environment variable is present at compile 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 environment\nvariable is not present, then this will expand to `None`. See\n[`Option`][Option] for more information on this type. Use\n[`std::env::var`] 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 using this macro regardless\nof whether the environment variable is present or not.\nTo emit a compile error if the environment variable is not present,\nuse the [`env!`] macro instead.\n\n# Examples\n\n```rust\nlet key: Option<&'static str> = option_env!(\"SECRET_KEY\");\nprintln!(\"the secret key might 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" :documentation (:kind "markdown" :value "Write formatted data into a buffer, with a newline appended.\n\nOn all platforms, the newline is the LINE FEED character (`\\n`/`U+000A`) alone\n(no additional CARRIAGE RETURN (`\\r`/`U+000D`).\n\nFor more information, see [`write!`]. For information on the format string 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 = 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" :documentation (:kind "markdown" :value "Asserts that two expressions are equal to each other (using [`PartialEq`]).\n\nOn panic, this macro will print the values of the expressions with their\ndebug representations.\n\nLike [`assert!`], this macro has a second form, where a custom\npanic message can be provided.\n\n# Examples\n\n```rust\nlet a = 3;\nlet b = 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 error message when encountered.\n\nThis macro should be used when a crate uses a conditional compilation strategy to provide\nbetter error messages for erroneous conditions. It's the compiler-level form of [`panic!`],\nbut emits an error during *compilation* rather than at *runtime*.\n\n# Examples\n\nTwo such examples are macros and `#[cfg]` environments.\n\nEmit a better compiler 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 not mention the two\nvalid values.\n\n```rust\nmacro_rules! give_me_foo_or_bar {\n (foo) => {};\n (bar) => {};\n ($x:ident) => {\n compile_error!(\"This macro only accepts `foo` or `bar`\");\n }\n}\n\ngive_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(feature = \"foo\", feature = \"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" :documentation (:kind "markdown" :value "Returns whether the given expression matches 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 preferable to use\n[`assert_matches!`] as it will print the debug representation of the value if the assertion\nfails.\n\n# Examples\n\n```rust\nlet foo = 'f';\nassert!(matches!(foo, 'A'..='Z' | 'a'..='z'));\n\nlet bar = 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" :documentation (:kind "markdown" :value "Constructs parameters for the other string-formatting macros.\n\nThis macro functions by taking a formatting string literal 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 formatting string.\n\nThis macro produces a value of type [`fmt::Arguments`]. This value can be\npassed to the macros within [`std::fmt`] for performing useful redirection.\nAll other formatting macros ([`format!`], [`write!`], [`println!`], etc) are\nproxied through this one. `format_args!`, unlike its derived 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 the same thing: the interpolated\nformat string in `format_args!`.\n\n```rust\nlet debug = format!(\"{:?}\", format_args!(\"{} foo {:?}\", 1, 2));\nlet display = format!(\"{}\", format_args!(\"{} foo {:?}\", 1, 2));\nassert_eq!(\"1 foo 2\", display);\nassert_eq!(display, debug);\n```\n\nSee [the formatting documentation in `std::fmt`](../std/fmt/index.html)\nfor details of the macro argument syntax, and further information.\n\n[`Display`]: crate::fmt::Display\n[`Debug`]: crate::fmt::Debug\n[`fmt::Arguments`]: crate::fmt::Arguments\n[`std::fmt`]: ../std/fmt/index.html\n[`format!`]: ../std/macro.format.html\n[`println!`]: ../std/macro.println.html\n\n# Examples\n\n```rust\nuse std::fmt;\n\nlet s = fmt::format(format_args!(\"hello {}\", \"world\"));\nassert_eq!(s, format!(\"hello {}\", \"world\"));\n```\n\n# Lifetime limitation\n\nExcept when no formatting arguments are used,\nthe produced `fmt::Arguments` value borrows temporary values,\nwhich means it can only 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_x86_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 detection currently relies mostly on the `cpuid` instruction.\n\nThis macro only takes one argument which is a string literal of the feature\nbeing tested for. The feature names supported are the lowercase versions of\nthe ones defined by Intel in [their documentation][docs].\n\n## Supported arguments\n\nThis macro supports the same names that `#[target_feature]` supports. Unlike\n`#[target_feature]`, however, this macro does not support names separated\nwith a comma. Instead testing for multiple features must be done through\nseparate macro invocations for now.\n\nSupported arguments are:\n\n* `\"aes\"`\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`] instead of [`io::stdout`]. See [`print!`] for\nexample usage.\n\nUse `eprint!` only for error and progress messages. Use `print!`\ninstead for the primary output 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 stderr 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 expressions with their\ndebug representations.\n\nUnlike [`assert_ne!`], `debug_assert_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_ne!` 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_assert_ne!` is always type checked.\n\n# Examples\n\n```rust\nlet a = 3;\nlet b = 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 Standard Library is the foundation of portable Rust software, a\nset of minimal and battle-tested shared abstractions for the [broader Rust\necosystem][crates.io]. It offers core types, like [`Vec`] and\n[`Option`], library-defined [operations on language\nprimitives](#primitives), [standard macros](#macros), [I/O] and\n[multithreading], among [many other things][other].\n\n`std` is available to all Rust crates by default. Therefore, the\nstandard 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 already know the name of what you are looking for, the fastest way to\nfind it is to use the search\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* [Primitive types](#primitives)\n* [Standard macros](#macros)\n* [The Rust Prelude]\n\nIf this is your first time, the documentation for the standard library is\nwritten to be casually perused. Clicking on interesting things should\ngenerally lead you to interesting places. Still, there are important bits\nyou don't want to miss, so read on for a tour of the standard library and\nits documentation!\n\nOnce you are familiar with the contents of the standard 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 near 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 read it. The standard library source is generally high\nquality and a peek behind the curtains is often enlightening.\n\n# What is in the standard library documentation?\n\nFirst of all, The Rust Standard Library is divided into a number of focused\nmodules, [all listed further down this page](#modules). These modules are\nthe bedrock upon which all of Rust is forged, and they have mighty names\nlike [`std::slice`] and [`std::cmp`]. Modules' documentation 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 can\nbe a source of confusion for two reasons:\n\n1. While primitives are implemented by the compiler, the standard library\n implements methods directly on the primitive types (and it is the only\n library that does so), which are [documented in the section on\n primitives](#primitives).\n2. The standard library exports many modules *with the same name as\n primitive 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 the primitive type\n`i32`](primitive::i32) that lists all the methods that can be called on\n32-bit integers (very useful), and there is a [page for the module\n`std::i32`] that documents the constant values [`MIN`] and [`MAX`] (rarely\nuseful).\n\nNote the documentation for the primitives [`str`] and [`[T]`][prim@slice] (also\ncalled 'slice'). Many method calls on [`String`] and [`Vec`] are actually\ncalls to methods on [`str`] and [`[T]`][prim@slice] respectively, via [deref\ncoercions][deref-coercions].\n\nThird, the standard library defines [The Rust Prelude], a small collection\nof items - mostly traits - that are imported into every module of every\ncrate. The traits in the prelude are pervasive, making the prelude\ndocumentation a good entry point to learning about the library.\n\nAnd finally, the standard library exports a number of standard macros, and\n[lists them on this page](#macros) (technically, not all of the standard\nmacros are defined by the standard library - some are defined by the\ncompiler - but they are documented here the same). Like the prelude, the\nstandard macros are imported by default into all crates.\n\n# Contributing changes to the documentation\n\nCheck out the Rust contribution guidelines [here](\nhttps://rustc-dev-guide.rust-lang.org/contributing.html#writing-documentation).\nThe source for this documentation can be found on\n[GitHub](https://github.com/rust-lang/rust).\nTo contribute changes, make sure you read the guidelines first, then submit\npull-requests for your suggested changes.\n\nContributions are appreciated! 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 The Rust Standard Library\n\nThe rest of this crate documentation is dedicated to pointing out notable\nfeatures of The Rust Standard Library.\n\n## Containers and collections\n\nThe [`option`] and [`result`] modules define optional and error-handling\ntypes, [`Option`] and [`Result`]. The [`iter`] module defines\nRust's iterator trait, [`Iterator`], which works with 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 contiguous\n storage, whether heap-allocated or not.\n\nSlices can only be handled 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 primitive type, and the standard library\ndefines many methods for it. Rust [`str`]s are typically accessed as\nimmutable references: `&str`. Use the owned [`String`] for building and\nmutating strings.\n\nFor converting to strings use the [`format!`] macro, and for converting from\nstrings use the [`FromStr`] 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 [`RefCell`], may be mutated\nas well as shared. Likewise, in a concurrent setting it is common to pair an\natomically-reference-counted box, [`Arc`], with a [`Mutex`] to get the same\neffect.\n\nThe [`collections`] module defines maps, sets, linked lists and other\ntypical collection types, including the common [`HashMap`].\n\n## Platform abstractions and I/O\n\nBesides basic data types, the standard library is largely concerned with\nabstracting over differences in common platforms, most notably Windows and\nUnix derivatives.\n\nCommon types of I/O, including [files], [TCP], and [UDP], are defined in\nthe [`io`], [`fs`], and [`net`] modules.\n\nThe [`thread`] module contains Rust's threading abstractions. [`sync`]\ncontains further primitive shared memory types, including [`atomic`] and\n[`mpsc`], which contains the channel types for message passing.\n\n# Use before and after `main()`\n\nMany parts of the standard library are expected to work before and after `main()`;\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 support.\nThis means that use of `std` before/after main, especially of features that interact with the\nOS or global state, is exempted from stability and portability guarantees and instead only\nprovided on a best-effort basis. Nevertheless bug reports are appreciated.\n\nOn the other hand `core` and `alloc` are most likely to work in such environments with\nthe caveat that any hookable behavior such as panics, oom handling or allocators will also\ndepend on the compatibility of the hooks.\n\nSome features may also behave differently outside main, e.g. stdio could become unbuffered,\nsome panics might turn into aborts, backtraces might not get symbolicated or similar.\n\nNon-exhaustive list of known limitations:\n\n- after-main use of thread-locals, which also affects additional features:\n - [`thread::current()`]\n - [`thread::scope()`]\n - [`sync::mpsc`]\n- before-main stdio file descriptors 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`]: crate::i32\n[TCP]: net::TcpStream\n[The Rust Prelude]: prelude\n[UDP]: net::UdpSocket\n[`Arc`]: sync::Arc\n[owned slice]: boxed\n[`Cell`]: cell::Cell\n[`FromStr`]: str::FromStr\n[`HashMap`]: collections::HashMap\n[`Mutex`]: sync::Mutex\n[`Option`]: option::Option\n[`Rc`]: rc::Rc\n[`RefCell`]: cell::RefCell\n[`Result`]: result::Result\n[`Vec`]: vec::Vec\n[`atomic`]: sync::atomic\n[`for`]: ../book/ch03-05-control-flow.html#looping-through-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.html#implicit-deref-coercions-with-functions-and-methods\n[files]: fs::File\n[multithreading]: thread\n[other]: #what-is-in-the-standard-library-documentation\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 Library is the dependency-free[^free] foundation of [The\nRust Standard Library](../std/index.html). It is the portable glue\nbetween the language and its 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 needed but\n they aren't always necessary.\n\nThe core library is *minimal*: it isn't even aware of heap allocation,\nnor does it provide concurrency 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 built on the assumption of a few existing symbols:\n\n* `memcpy`, `memmove`, `memset`, `memcmp`, `bcmp`, `strlen` - These are core memory routines\n which 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 `memcpy`, `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 common 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/compiler_builtins).\n Note that the library does not guarantee that it will always make these assumptions, so Rust\n user code directly calling the C functions 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 panic function; it is only required to never\n return. You should mark your implementation using `#[panic_handler]`.\n\n* `rust_eh_personality` - is used by the failure mechanisms of the\n compiler. This is often mapped to GCC'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 :preselect 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 :preselect 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 :preselect 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 :preselect 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 :preselect 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 :preselect 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 :preselect 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 :preselect 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 :preselect 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 :preselect 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 :preselect 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 :preselect 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 :preselect 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 :preselect 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 :preselect 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 :preselect 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 :preselect 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 reference conversion.\n\nThis trait is similar to [`AsRef`] but used for converting between mutable\nreferences. If you need to do a costly conversion it is better to\nimplement [`From`] with type `&mut T` or write a custom function.\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` has type `&mut Foo` or `&mut &mut Foo`).\n\nNote that due to historic reasons, the above currently does not hold generally for all\n[mutably dereferenceable types], e.g. `foo.as_mut()` will *not* work the same as\n`Box::new(foo).as_mut()`. Instead, many smart pointers provide an `as_mut` implementation 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 dereferencing; instead ['`Deref` coercion'] can be used:\n\n[mutably dereferenceable types]: core::ops::DerefMut\n[pointed-to value]: core::ops::Deref::Target\n['`Deref` coercion']: core::ops::DerefMut#mutable-deref-coercion\n\n```rust\nlet mut x = Box::new(5i32);\n// Avoid this:\n// let y: &mut i32 = x.as_mut();\n// Better just write:\nlet y: &mut i32 = &mut x;\n```\n\nTypes which implement [`DerefMut`] should consider to add an implementation of `AsMut` as\nfollows:\n\n[`DerefMut`]: core::ops::DerefMut\n\n```rust\nimpl AsMut for SomeType\nwhere\n ::Target: AsMut,\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 reflexive, i.e. there would be an `impl AsMut for T`\nwith [`as_mut`] simply returning its argument unchanged.\nSuch a blanket implementation is currently *not* provided due to technical restrictions of\nRust's type system (it would be overlapping with another existing blanket implementation 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\nA 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 trait bound for a generic function, we can accept all mutable references that\ncan be converted to type `&mut T`. Unlike [dereference], which has a single [target type],\nthere can be multiple implementations of `AsMut` for a type. In particular, `Vec` implements\nboth `AsMut>` and `AsMut<[T]>`.\n\nIn the following, the example functions `caesar` and `null_terminate` provide a generic\ninterface which work with any type that can be converted by cheap mutable-to-mutable conversion\ninto a byte slice (`[u8]`) or byte 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 Document\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 = byte.wrapping_add(key);\n }\n}\n\nfn null_terminate>>(data: &mut T) {\n // Using a non-generic inner function, which contains most of the\n // functionality, helps to minimize monomorphization overhead.\n fn doit(data: &mut Vec) {\n let len = data.len();\n if len == 0 || data[len-1] != 0 {\n data.push(0);\n }\n }\n doit(data.as_mut());\n}\n\nfn main() {\n let mut v: Vec = 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 = Document {\n info: String::from(\"Example\"),\n content: vec![17, 19, 8],\n };\n caesar(&mut doc, 1);\n assert_eq!(doc.content, [18, 20, 9]);\n null_terminate(&mut doc);\n assert_eq!(doc.content, [18, 20, 9, 0]);\n}\n```\n\nNote, however, that APIs don'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 type 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 conversion.\n\nThis trait is similar to [`AsMut`] which is used for converting 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`], but [`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 reference or a value. (See also note on `AsRef`'s reflexibility below.)\n- [`Borrow`] also requires that [`Hash`], [`Eq`] and [`Ord`] for a borrowed value are\n equivalent to those of the owned value. For this reason, if you want 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 conversion can fail, use a\ndedicated method which returns an [`Option`] or a [`Result`].\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 for all\n[dereferenceable types], e.g. `foo.as_ref()` will *not* work the same as\n`Box::new(foo).as_ref()`. Instead, many smart pointers provide an `as_ref` implementation which\nsimply returns a reference to the [pointed-to value] (but do not perform a cheap\nreference-to-reference conversion for that value). However, [`AsRef::as_ref`] should not be\nused for the sole purpose of dereferencing; instead ['`Deref` coercion'] can be used:\n\n[dereferenceable types]: core::ops::Deref\n[pointed-to value]: core::ops::Deref::Target\n['`Deref` coercion']: core::ops::Deref#deref-coercion\n\n```rust\nlet x = Box::new(5i32);\n// Avoid this:\n// let y: &i32 = x.as_ref();\n// Better just write:\nlet y: &i32 = &x;\n```\n\nTypes which implement [`Deref`] should consider implementing `AsRef` as follows:\n\n[`Deref`]: core::ops::Deref\n\n```rust\nimpl AsRef for SomeType\nwhere\n T: ?Sized,\n ::Target: AsRef,\n{\n fn as_ref(&self) -> &T {\n self.deref().as_ref()\n }\n}\n```\n\n# Reflexivity\n\nIdeally, `AsRef` would be reflexive, i.e. there would be an `impl AsRef for T`\nwith [`as_ref`] simply returning its argument unchanged.\nSuch a blanket implementation is currently *not* provided due to technical restrictions of\nRust's type system (it would be overlapping with another existing blanket implementation for\n`&T where T: AsRef` which allows `AsRef` to auto-dereference, see \"Generic Implementations\"\nabove).\n\n[`as_ref`]: 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, and 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 long as they can be\nconverted to the specified type `T`.\n\nFor example: By creating a generic function that takes an `AsRef` we express that we\nwant to accept all references that can be converted to [`&str`] as an argument.\nSince both [`String`] and [`&str`] implement `AsRef` we can accept both as input argument.\n\n[`&str`]: primitive@str\n[`Borrow`]: crate::borrow::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 = \"hello\";\nis_hello(s);\n\nlet s = \"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}>" :documentation (:kind "markdown" :value "A pointer type that uniquely owns a heap allocation of type `T`.\n\nSee the [module-level documentation](../../std/boxed/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 explicitly duplicate an object.\n\nDiffers from [`Copy`] in that [`Copy`] is implicit and an inexpensive bit-wise copy, while\n`Clone` is always explicit and may or may not be expensive. In order to enforce\nthese characteristics, Rust does not allow you to reimplement [`Copy`], but you\nmay reimplement `Clone` 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## Derivable\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]` implements `Clone` conditionally by adding bound `Clone` on\ngeneric parameters.\n\n```rust\n// `derive` implements Clone for Reading when T is Clone.\n#[derive(Clone)]\nstruct Reading {\n frequency: T,\n}\n```\n\n## How can I implement `Clone`?\n\nTypes that are [`Copy`] should have a trivial implementation of `Clone`. More formally:\nif `T: Copy`, `x: T`, and `y: &T`, then `let x = y.clone();` is equivalent to `let x = *y;`.\nManual implementations should be careful to uphold this invariant; however, unsafe code\nmust not rely on it to ensure memory safety.\n\nAn example is a generic struct holding a function pointer. In this case, the\nimplementation of `Clone` cannot be `derive`d, but can be implemented as:\n\n```rust\nstruct Generate(fn() -> T);\n\nimpl Copy for Generate {}\n\nimpl Clone for Generate {\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 unnecessary because clearly the function itself should be\ncopy- and cloneable even if its return type is not:\n\n```rust\n#[derive(Copy, Clone)]\nstruct Generate(fn() -> T);\n\nstruct NotCloneable;\n\nfn generate_not_cloneable() -> NotCloneable {\n NotCloneable\n}\n\nGenerate(generate_not_cloneable).clone(); // error: trait bounds were not satisfied\n// Note: With the manual implementations the above line will compile.\n```\n\n## Additional implementors\n\nIn addition to the [implementors listed below][impls],\nthe following types also implement `Clone`:\n\n* Function item types (i.e., the distinct 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 never 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.' In other\nwords:\n\n```rust\n#[derive(Debug)]\nstruct Foo;\n\nlet x = Foo;\n\nlet y = 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 type 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 supertrait of `Copy`.\n#[derive(Debug, Copy, Clone)]\nstruct Foo;\n\nlet x = Foo;\n\nlet y = 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 only difference is whether you\nare allowed to access `x` after the assignment. 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 implement `Copy`?\n\nThere are two ways to implement `Copy` on your type. The simplest is to use `derive`:\n\n```rust\n#[derive(Copy, Clone)]\nstruct MyStruct;\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\nThere is a small difference between the two: the `derive` strategy will also place a `Copy`\nbound on type parameters, which isn't always desired.\n\n## What's the difference between `Copy` and `Clone`?\n\nCopies happen implicitly, for example as part of an assignment `y = 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 example,\nthe implementation of [`Clone`] for [`String`] needs to copy the pointed-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. For this reason, [`String`] is [`Clone`]\nbut not `Copy`.\n\n[`Clone`] is a supertrait of `Copy`, so everything which is `Copy` must also implement\n[`Clone`]. 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 contrast, 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 references of types `T` that are *not* `Copy`. Consider the following struct,\nwhich 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 safely. For example, copying `&mut T` would create an aliased\nmutable reference. Copying [`String`] would duplicate responsibility for managing the\n[`String`]'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 implement `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 `Copy`, 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 future, 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 `Copy`:\n\n* Function item types (i.e., the distinct 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 `Copy` themselves.\n Note that variables captured by shared reference always implement `Copy`\n (even if the referent doesn't),\n while variables captured by mutable reference never implement `Copy`.\n\n[`Vec`]: ../../std/vec/struct.Vec.html\n[`String`]: ../../std/string/struct.String.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, and\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: i32,\n bar: f32,\n}\n```\n\nHow can we define some default values? You can use `Default`:\n\n```rust\n#[derive(Default)]\nstruct SomeOptions {\n foo: i32,\n bar: f32,\n}\n\nfn main() {\n let options: SomeOptions = 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 override a particular option, but still retain the other defaults:\n\n```rust\nfn main() {\n let options = SomeOptions { foo: 42, ..Default::default() };\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 use 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 variant.\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-unit or non-exhaustive variants.\n\nThe `#[default]` attribute was stabilized in Rust 1.62.0.\n\n## How can I implement `Default`?\n\nProvide an implementation for the `default()` method that returns the value of\nyour type that 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 both ends.\n\nSomething that implements `DoubleEndedIterator` has one extra capability\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 note that both back and forth work on the same range,\nand do not cross: iteration 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`] again. [`next()`] and\n[`next_back()`] are interchangeable for this purpose.\n\n[`next_back()`]: DoubleEndedIterator::next_back\n[`next()`]: Iterator::next\n\n# Examples\n\nBasic usage:\n\n```rust\nlet numbers = vec![1, 2, 3, 4, 5, 6];\n\nlet mut iter = numbers.iter();\n\nassert_eq!(Some(&1), iter.next());\nassert_eq!(Some(&6), iter.next_back());\nassert_eq!(Some(&5), iter.next_back());\nassert_eq!(Some(&2), iter.next());\nassert_eq!(Some(&3), iter.next());\nassert_eq!(Some(&4), iter.next());\nassert_eq!(None, iter.next());\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 of\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 other cases,\nplease see [the reference] section on destructors.\n\n[the reference]: https://doc.rust-lang.org/reference/destructors.html\n\nThis destructor consists of two components:\n- A call to `Drop::drop` for that value, if this special `Drop` trait is implemented for its type.\n- The automatically generated \"drop glue\" which recursively calls the destructors\n of all the fields of this value.\n\nAs Rust automatically calls the destructors of all contained fields,\nyou don't have to implement `Drop` in most cases. But there are some cases where\nit is useful, for example for types which directly manage a resource.\nThat resource may be memory, it may be a file 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 the memory or closing the file or socket. This is\nthe job of a destructor, and 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 HasDrop;\n\nimpl Drop for HasDrop {\n fn drop(&mut self) {\n println!(\"Dropping HasDrop!\");\n }\n}\n\nstruct HasTwoDrops {\n one: HasDrop,\n two: HasDrop,\n}\n\nimpl Drop for HasTwoDrops {\n fn drop(&mut self) {\n println!(\"Dropping HasTwoDrops!\");\n }\n}\n\nfn main() {\n let _x = HasTwoDrops { one: HasDrop, two: HasDrop };\n println!(\"Running!\");\n}\n```\n\nRust will first call `Drop::drop` for `_x` and then for both `_x.one` and `_x.two`,\nmeaning that running this will print\n\n```text\nRunning!\nDropping HasTwoDrops!\nDropping HasDrop!\nDropping HasDrop!\n```\n\nEven if we remove the implementation of `Drop` for `HasTwoDrop`, the destructors of its fields are still called.\nThis would result in\n\n```test\nRunning!\nDropping HasDrop!\nDropping HasDrop!\n```\n\n## You cannot call `Drop::drop` yourself\n\nBecause `Drop::drop` is used to clean up a value, it may be dangerous to use this value after\nthe method has been called. As `Drop::drop` does not take ownership of its input,\nRust prevents 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 destructor 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 structs, it's the same\norder that they're declared: first `one`, then `two`. If you'd like to try\nthis yourself, you can modify `HasDrop` above to contain 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 structs, 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 = Foo;\n let _bar = Bar;\n}\n```\n\nThis will print\n\n```text\nDropping Bar!\nDropping Foo!\n```\n\nPlease see [the reference] for the full rules.\n\n[the reference]: https://doc.rust-lang.org/reference/destructors.html\n\n## `Copy` and `Drop` are exclusive\n\nYou cannot implement both [`Copy`] and `Drop` on the same type. Types that\nare `Copy` get implicitly duplicated by the compiler, making it very\nhard to predict when, and how often destructors will be executed. As such,\nthese types cannot have destructors.\n\n## Drop check\n\nDropping interacts with the borrow checker in subtle ways: when a type `T` is being implicitly\ndropped as some variable 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 needs 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) = self.0.get() {\n // Print the contents of the `Box` in `r`.\n println!(\"{}\", r.1);\n }\n }\n}\n\nfn main() {\n // Set up two `S` that point to each other.\n let s1 = S(Cell::new(None), Box::new(42));\n let s2 = S(Cell::new(Some(&s1)), Box::new(42));\n s1.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 for [drop check in more detail][drop check].\n\nTo reject such code, the \"drop 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 [`ManuallyDrop`] 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 field of `T`,\n recursively add the types and lifetimes that need to be live when `U` gets dropped. The set of\n owned types is determined by recursively traversing `T`:\n - Recursively descend through `PhantomData`, `Box`, tuples, and arrays (including arrays of\n length 0).\n - Stop at reference 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 parameters 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 with `impl Drop`, stop there; this type is owned.\n - When hitting an ADT without `impl Drop`, recursively descend to its fields. (For an `enum`,\n consider all fields of all variants.)\n- Furthermore, if `T` implements `Drop`, 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 when `S<'a>` is dropped,\nand hence the example is rejected. If we remove the `impl Drop`, the liveness requirement\ndisappears and the example is accepted.\n\nThere exists an unstable way for a type to opt-out of the last clause; this is called \"drop\ncheck eyepatch\" or `may_dangle`. For more details on this nightly-only feature, see the\n[discussion in the Nomicon][nomicon].\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-standard-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 ==, !=)" :kind 8 :documentation (:kind "markdown" :value "Trait for comparisons corresponding to [equivalence relations](\nhttps://en.wikipedia.org/wiki/Equivalence_relation).\n\nThis means, that in addition to `a == b` and `a != b` being strict inverses,\nthe relation must be (for all `a`, `b` and `c`):\n\n- reflexive: `a == a`;\n- symmetric: `a == b` implies `b == a` (required by `PartialEq` as well); and\n- transitive: `a == b` and `b == c` implies `a == c` (required by `PartialEq` as well).\n\nThis property cannot be checked by the compiler, and therefore `Eq` implies\n[`PartialEq`], and has no extra methods.\n\nViolating this property 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 `unsafe` code **must not** rely on the correctness of these\nmethods.\n\nImplement `Eq` in addition to `PartialEq` if it's guaranteed that\n`PartialEq::eq(a, a)` always returns `true` (reflexivity), in addition to\nthe symmetric and transitive properties already required by `PartialEq`.\n\n## Derivable\n\nThis trait can be used with `#[derive]`. When `derive`d, because `Eq` has\nno extra methods, it is only informing the compiler that this is an\nequivalence relation rather than a partial equivalence relation. Note that\nthe `derive` strategy requires all fields are `Eq`, which isn't\nalways desired.\n\n## How can I implement `Eq`?\n\nIf you cannot 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 == 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 do.\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\nbackwards, a good start is to know where the end is.\n\nWhen implementing an `ExactSizeIterator`, you must also implement\n[`Iterator`]. When doing so, the implementation of [`Iterator::size_hint`]\n*must* return the exact size of 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 that `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 to implement `ExactSizeIterator`. The inner exact-sized\niterator might already be `usize::MAX`-long, and thus the length of the\nlonger adapted iterator would no longer be exactly representable in `usize`.\n\nThis is why [`Chain`](crate::iter::Chain) isn't `ExactSizeIterator`,\neven when `A` and `B` are both `ExactSizeIterator`.\n\n# Examples\n\nBasic usage:\n\n```rust\n// a finite range knows exactly how many times it will iterate\nlet five = 0..5;\n\nassert_eq!(5, five.len());\n```\n\nIn the [module-level docs], we implemented an [`Iterator`], `Counter`.\nLet's implement `ExactSizeIterator` for it as well:\n\n[module-level docs]: crate::iter\n\n```rust\nimpl ExactSizeIterator for Counter {\n // We can easily calculate the remaining 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 = Counter::new();\n\nassert_eq!(5, counter.len());\nlet _ = counter.next();\nassert_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 also 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 iterator. When\nextending a collection with an already existing key, that entry 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 = String::from(\"The first three letters are: \");\n\nmessage.extend(&['a', 'b', 'c']);\n\nassert_eq!(\"abc\", &message[29..32]);\n```\n\nImplementing `Extend`:\n\n```rust\n// A sample collection, that's just a wrapper 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(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 can 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 straightforward: loop through the\n // iterator, and add() each element to ourselves.\n for elem in iter {\n self.add(elem);\n }\n }\n}\n\nlet mut c = MyCollection::new();\n\nc.add(5);\nc.add(6);\nc.add(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 without mutating state.\n\n*This trait (`Fn`) is not to be confused with [function pointers]\n(`fn`).*\n\n`Fn` is implemented automatically by closures which only take immutable\nreferences to captured variables or don't capture anything 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`] and [`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 concurrently). If you do not need such strict requirements, use\n[`FnMut`] or [`FnOnce`] as bounds.\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 syntax for `Fn` traits (e.g.\n`Fn(usize, bool) -> usize`). Those interested in the technical details of\nthis can refer to [the relevant section in the *Rustonomicon*][nomicon].\n\n[book]: ../../book/ch13-01-closures.html\n[function pointers]: fn\n[nomicon]: ../../nomicon/hrtb.html\n\n# Examples\n\n## Calling a closure\n\n```rust\nlet square = |x| x * x;\nassert_eq!(square(5), 25);\n```\n\n## Using a `Fn` parameter\n\n```rust\nfn call_with_one(func: F) -> usize\n where F: Fn(usize) -> usize {\n func(1)\n}\n\nlet double = |x| x * 2;\nassert_eq!(call_with_one(double), 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 may mutate state.\n\n`FnMut` is implemented automatically by closures which take mutable\nreferences to captured variables, as well as all types that implement\n[`Fn`], e.g., (safe) [function pointers] (since `FnMut` is a supertrait 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 expected, and since [`Fn`] is a subtrait of\n`FnMut`, any instance of [`Fn`] can be used where `FnMut` is expected.\n\nUse `FnMut` as a bound when you want to 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 mutate 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 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 relevant section in the *Rustonomicon*][nomicon].\n\n[book]: ../../book/ch13-01-closures.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 = 5;\n{\n let mut square_x = || x *= x;\n square_x();\n}\nassert_eq!(x, 25);\n```\n\n## Using a `FnMut` parameter\n\n```rust\nfn do_twice(mut func: F)\n where F: FnMut()\n{\n func();\n func();\n}\n\nlet mut x: usize = 1;\n{\n let add_two_to_x = || x += 2;\n do_twice(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 about a type is that it\nimplements `FnOnce`, it can only be called once.\n\n`FnOnce` 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 only 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 syntax for `Fn` traits (e.g.\n`Fn(usize, bool) -> usize`). Those interested in the technical details of\nthis can refer to [the relevant section in the *Rustonomicon*][nomicon].\n\n[book]: ../../book/ch13-01-closures.html\n[function 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 variables, so it cannot be run more\n // than once.\n println!(\"Consumed: {}\", 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 = String::from(\"x\");\nlet consume_and_return_x = move || x;\nconsume_with_relish(consume_and_return_x);\n\n// `consume_and_return_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 should always prefer implementing `From` over [`Into`]\nbecause implementing `From` automatically provides one with an implementation of [`Into`]\nthanks to the blanket implementation in the standard library.\n\nOnly implement [`Into`] 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 conversions in earlier versions because of Rust's\norphaning rules.\nSee [`Into`] for more details.\n\nPrefer using [`Into`] over using `From` when specifying trait bounds on a generic function.\nThis way, types that directly implement [`Into`] can be used as arguments as well.\n\nThe `From` trait is also 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 the \"Examples\" section and [the book][book] for more\ndetails.\n\n**Note: This trait must not fail**. The `From` trait is intended for perfect conversions.\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 which conversions can be done using\na `From` implementation, the general expectation is that the conversions\nshould typically be restricted as follows:\n\n* The conversion is *infallible*: if the conversion can fail, use [`TryFrom`]\n instead; don't provide a `From` impl that panics.\n\n* The conversion is *lossless*: semantically, it should not lose or discard\n information. For example, `i32: From` exists, where the original\n value can be 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 information 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 conversion is *value-preserving*: the conceptual kind and meaning of\n the resulting value is the same, even though the Rust type and technical\n representation might be different. For example `-1_i8 as u8` is *lossless*,\n since `as` casting back can recover the original value, but that conversion\n is *not* available via `From` because `-1` and `255` are different conceptual\n values (despite being identical bit patterns technically). But\n `f32: From` *is* available because `1_i16` and `1.0_f32` are conceptually\n the same real number (despite having very different bit patterns technically).\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 covered\n by the [`Display`](crate::fmt::Display) trait.)\n\n* The conversion is *obvious*: it's the only reasonable conversion between\n the two types. 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 like [`u32::from_ne_bytes`], [`u32::from_le_bytes`], and\n [`u32::from_be_bytes`], none of which are `From` implementations. Whereas\n there's only one reasonable way to wrap an [`Ipv6Addr`](crate::net::Ipv6Addr)\n into an [`IpAddr`](crate::net::IpAddr), thus `IpAddr: From` exists.\n\n# Examples\n\n[`String`] implements `From<&str>`:\n\nAn explicit conversion from a `&str` to a String is done as follows:\n\n```rust\nlet string = \"hello\".to_string();\nlet other_string = String::from(\"hello\");\n\nassert_eq!(string, other_string);\n```\n\nWhile performing error handling it is often useful to implement `From` for your own error type.\nBy converting underlying error types to our own custom error type that encapsulates the\nunderlying error type, we can return a single error type without losing information on the\nunderlying cause. The '?' operator automatically converts the underlying error type to our\ncustom error type with `From::from`.\n\n```rust\nuse std::fs;\nuse std::io;\nuse std::num;\n\nenum CliError {\n IoError(io::Error),\n ParseError(num::ParseIntError),\n}\n\nimpl From for CliError {\n fn from(error: io::Error) -> Self {\n CliError::IoError(error)\n }\n}\n\nimpl From for CliError {\n fn from(error: num::ParseIntError) -> Self {\n CliError::ParseError(error)\n }\n}\n\nfn open_and_parse_file(file_name: &str) -> Result {\n let mut contents = fs::read_to_string(&file_name)?;\n let num: i32 = contents.trim().parse()?;\n Ok(num)\n}\n```\n\n[`String`]: ../../std/string/struct.String.html\n[`from`]: From::from\n[book]: ../../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 implementing `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 iterator, the\n[`Iterator::collect()`] method is preferred. However, when you need to\nspecify the container type, [`FromIterator::from_iter()`] can be more\nreadable than using a turbofish (e.g. `::>()`). See the\n[`Iterator::collect()`] documentation for more examples of its use.\n\nSee also: [`IntoIterator`].\n\n# Examples\n\nBasic usage:\n\n```rust\nlet five_fives = std::iter::repeat(5).take(5);\n\nlet v = Vec::from_iter(five_fives);\n\nassert_eq!(v, vec![5, 5, 5, 5, 5]);\n```\n\nUsing [`Iterator::collect()`] to implicitly use `FromIterator`:\n\n```rust\nlet five_fives = std::iter::repeat(5).take(5);\n\nlet v: Vec = five_fives.collect();\n\nassert_eq!(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 std::collections::VecDeque;\nlet first = (0..10).collect::>();\nlet second = 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 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(elem);\n }\n}\n\n// and we'll implement FromIterator\nimpl FromIterator for MyCollection {\n fn from_iter>(iter: I) -> Self {\n let mut c = MyCollection::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 = (0..5).into_iter();\n\n// ... and make a MyCollection out of it\nlet c = MyCollection::from_iter(iter);\n\nassert_eq!(c.0, vec![0, 1, 2, 3, 4]);\n\n// collect works too!\n\nlet iter = (0..5).into_iter();\nlet c: MyCollection = 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 the input value. The\nopposite of [`From`].\n\nOne should avoid implementing [`Into`] and implement [`From`] instead.\nImplementing [`From`] automatically provides one with an implementation of [`Into`]\nthanks to the blanket implementation in the standard library.\n\nPrefer using [`Into`] over [`From`] when specifying trait bounds on a generic function\nto ensure that types that only implement [`Into`] can be used as well.\n\n**Note: This trait must not fail**. If the conversion can fail, use [`TryInto`].\n\n# Generic Implementations\n\n- [`From`]` for U` implies `Into for T`\n- [`Into`] is reflexive, which means that `Into for T` is implemented\n\n# Implementing [`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 crate\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 Rust's orphaning rules\nused to be a little bit more strict. To bypass this, you 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 back to [`Into`] if [`From`] can't be implemented.\n\n# Examples\n\n[`String`] implements [`Into`]`<`[`Vec`]`<`[`u8`]`>>`:\n\nIn order to express that we 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 example: 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 = b\"hello\".to_vec();\n assert_eq!(bytes, s.into());\n}\n\nlet s = \"hello\".to_string();\nis_hello(s);\n```\n\n[`String`]: ../../std/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 implementing `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-intoiterator).\n\nSee also: [`FromIterator`].\n\n# Examples\n\nBasic usage:\n\n```rust\nlet v = [1, 2, 3];\nlet mut iter = 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 `IntoIterator` for your type:\n\n```rust\n// A sample collection, that's just a wrapper 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(elem);\n }\n}\n\n// and we'll implement IntoIterator\nimpl IntoIterator for MyCollection {\n type Item = i32;\n type IntoIter = std::vec::IntoIter;\n\n fn into_iter(self) -> Self::IntoIter {\n self.0.into_iter()\n }\n}\n\n// Now we can make a new collection...\nlet mut c = 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. Additional bounds can be specified by restricting on\n`Item`:\n\n```rust\nfn collect_as_strings(collection: T) -> Vec\nwhere\n T: IntoIterator,\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\ngenerally, please see the [module-level documentation]. In particular, you\nmay want to know how to [implement `Iterator`][impl].\n\n[module-level documentation]: 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 documentation](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 <, >, <=, >=)" :kind 8 :documentation (:kind "markdown" :value "Trait for types that form a [total order](https://en.wikipedia.org/wiki/Total_order).\n\nImplementations must be consistent with the [`PartialOrd`] implementation, and ensure\n`max`, `min`, and `clamp` are consistent with `cmp`:\n\n- `partial_cmp(a, b) == Some(cmp(a, b))`.\n- `max(a, b) == max_by(a, b, cmp)` (ensured by the default implementation).\n- `min(a, b) == min_by(a, b, cmp)` (ensured by the default implementation).\n- For `a.clamp(min, max)`, see the [method docs](#method.clamp)\n (ensured by the default implementation).\n\nIt's easy to accidentally make `cmp` and `partial_cmp` disagree by\nderiving some of the traits 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 in\nundefined behavior. This means that `unsafe` code **must not** rely on the correctness of these\nmethods.\n\n## Corollaries\n\nFrom the above and the requirements of `PartialOrd`, it follows that for\nall `a`, `b` and `c`:\n\n- exactly one of `a < b`, `a == b` or `a > b` is true; and\n- `<` is transitive: `a < b` and `b < c` implies `a < c`. The same must hold for both `==` and `>`.\n\nMathematically speaking, the `<` operator defines a strict [weak order]. In\ncases where `==` conforms to mathematical equality, it also defines a\nstrict [total order].\n\n[weak order]: https://en.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-bottom 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 example:\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, manually setting the discriminants can override this default\nbehavior:\n\n```rust\n#[derive(PartialEq, Eq, PartialOrd, Ord)]\nenum E {\n Top = 2,\n Bottom = 1,\n}\n\nassert!(E::Bottom < E::Top);\n```\n\n## Lexicographical comparison\n\nLexicographical comparison is an operation with the following 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 sequences have equivalent elements and are of the same length, then the sequences are lexicographically equal.\n - An empty sequence is lexicographically less than any non-empty sequence.\n - Two empty sequences are lexicographically equal.\n\n## How can I implement `Ord`?\n\n`Ord` requires that the type also be [`PartialOrd`] and [`Eq`] (which requires [`PartialEq`]).\n\nThen you must define an implementation for [`cmp`]. You may find it useful to use\n[`cmp`] on your type's fields.\n\nHere's an example where you want to sort people by height only, disregarding `id`\nand `name`:\n\n```rust\nuse std::cmp::Ordering;\n\n#[derive(Eq)]\nstruct Person {\n id: u32,\n name: 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 PartialEq for Person {\n fn eq(&self, other: &Self) -> bool {\n self.height == 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 ==, !=)" :kind 8 :documentation (:kind "markdown" :value "Trait for comparisons using the equality operator.\n\nImplementing this trait for types provides the `==` and `!=` operators for\nthose types.\n\n`x.eq(y)` can also be written `x == y`, and `x.ne(y)` can be written `x != y`.\nWe use the easier-to-read infix notation in the remainder of this documentation.\n\nThis trait allows for comparisons using the equality operator, for types\nthat do not have a full equivalence relation. For example, in floating point\nnumbers `NaN != NaN`, so floating point types implement `PartialEq` but not\n[`trait@Eq`]. Formally speaking, when `Rhs == Self`, this trait corresponds\nto a [partial equivalence relation].\n\n[partial equivalence relation]: https://en.wikipedia.org/wiki/Partial_equivalence_relation\n\nImplementations must ensure that `eq` and `ne` are consistent with each other:\n\n- `a != b` if and only if `!(a == b)`.\n\nThe default implementation of `ne` provides this consistency and is almost\nalways sufficient. It should not be overridden without very good reason.\n\nIf [`PartialOrd`] or [`Ord`] are also implemented for `Self` and `Rhs`, their methods must also\nbe consistent with `PartialEq` (see the documentation of those traits for the exact\nrequirements). It's easy to accidentally make them disagree by deriving some of the traits and\nmanually implementing others.\n\nThe equality relation `==` 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 == b`\n implies `b == a`**; and\n\n- **Transitivity**: if `A: PartialEq` and `B: PartialEq` and `A:\n PartialEq`, then **`a == b` and `b == c` implies `a == c`**.\n This must also work for longer chains, such as when `A: PartialEq`, `B: PartialEq`,\n `C: PartialEq`, and `A: PartialEq` all exist.\n\nNote that the `B: PartialEq` (symmetric) and `A: PartialEq`\n(transitive) impls are not forced to exist, but these requirements apply\nwhenever they do exist.\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 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 `PartialEq`\nfor a type of another crate (i.e., to allow comparing one of its own types with a type from the\nstandard library). The recommendation is to never implement this trait for a foreign 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-cross crate boundaries: for all local\ntypes `T`, you may assume that no other crate will add `impl`s that allow comparing `T == U`. In\nother words, if 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\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 ways that violate\ntransitivity.\n\nNot having such foreign `impl`s also avoids forward compatibility issues where one crate adding\nmore `PartialEq` implementations can cause build failures in downstream crates.\n\n## Derivable\n\nThis trait can be used with `#[derive]`. When `derive`d on structs, two\ninstances are equal if all fields are equal, and not equal if any fields\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 are considered\nthe same book if their ISBN matches, even if the formats differ:\n\n```rust\nenum BookFormat {\n Paperback,\n Hardback,\n Ebook,\n}\n\nstruct Book {\n isbn: i32,\n format: BookFormat,\n}\n\nimpl PartialEq for Book {\n fn eq(&self, other: &Self) -> bool {\n self.isbn == other.isbn\n }\n}\n\nlet b1 = Book { isbn: 3, format: BookFormat::Paperback };\nlet b2 = Book { isbn: 3, format: BookFormat::Ebook };\nlet b3 = Book { isbn: 10, format: BookFormat::Paperback };\n\nassert!(b1 == b2);\nassert!(b1 != b3);\n```\n\n## How can I compare two different 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 == comparisons\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 == comparisons\nimpl PartialEq for Book {\n fn eq(&self, other: &BookFormat) -> bool {\n self.format == *other\n }\n}\n\n// Implement == comparisons\nimpl PartialEq for BookFormat {\n fn eq(&self, other: &Book) -> bool {\n *self == other.format\n }\n}\n\nlet b1 = Book { isbn: 3, format: BookFormat::Paperback };\n\nassert!(b1 == BookFormat::Paperback);\nassert!(BookFormat::Ebook != 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 like 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 implementation of `PartialEq` for `BookFormat` and added an\nimplementation of `PartialEq` for `Book` (either via a `#[derive]` or\nvia the manual implementation from the first example) then the result would\nviolate transitivity:\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 Book {\n fn eq(&self, other: &BookFormat) -> bool {\n self.format == *other\n }\n}\n\nimpl PartialEq for BookFormat {\n fn eq(&self, other: &Book) -> bool {\n *self == other.format\n }\n}\n\nfn main() {\n let b1 = Book { isbn: 1, format: BookFormat::Paperback };\n let b2 = Book { isbn: 2, format: BookFormat::Paperback };\n\n assert!(b1 == BookFormat::Paperback);\n assert!(BookFormat::Paperback == b2);\n\n // The following should hold by transitivity but doesn't.\n assert!(b1 == b2); // <-- PANICS\n}\n```\n\n# Examples\n\n```rust\nlet x: u32 = 0;\nlet y: u32 = 1;\n\nassert_eq!(x == y, false);\nassert_eq!(x.eq(&y), false);\n```\n\n[`eq`]: PartialEq::eq\n[`ne`]: PartialEq::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 >, <, <=, >=)" :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 `<`, `<=`, `>`, and `>=` operators, respectively.\n\nThe methods of this trait must be consistent with each other and with those of [`PartialEq`].\nThe following conditions must hold:\n\n1. `a == b` if and only if `partial_cmp(a, b) == Some(Equal)`.\n2. `a < b` if and only if `partial_cmp(a, b) == Some(Less)`\n3. `a > b` if and only if `partial_cmp(a, b) == Some(Greater)`\n4. `a <= b` if and only if `a < b || a == b`\n5. `a >= b` if and only if `a > b || a == b`\n6. `a != b` if and only if `!(a == b)`.\n\nConditions 2–5 above are ensured by the default implementation.\nCondition 6 is already ensured by [`PartialEq`].\n\nIf [`Ord`] is also implemented 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\neasy to accidentally make them disagree by deriving some of the traits and manually\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 PartialOrd`, then `a < b` and `b < c` implies `a < c`. The same must hold for both `==` and `>`.\n This must also work for longer chains, such as 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: PartialOrd` (dual) and `A: PartialOrd`\n(transitive) impls are not forced to exist, but these requirements apply\nwhenever they do exist.\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 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\nstandard library). The recommendation is to never implement this trait for a foreign type. In\nother words, such a crate should do `impl PartialOrd for LocalType`, but it should\n*not* do `impl PartialOrd for ForeignType`.\n\nThis avoids the problem of transitive chains that criss-cross crate boundaries: for all local\ntypes `T`, you may assume that no other crate will add `impl`s that allow comparing `T < U`. In\nother words, if 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\ntransitivity.\n\nNot having such foreign `impl`s also avoids forward compatibility issues where one crate adding\nmore `PartialOrd` implementations can cause build failures in downstream crates.\n\n## Corollaries\n\nThe following corollaries follow from the above requirements:\n\n- irreflexivity of `<` and `>`: `!(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) == partial_cmp(b, a).map(Ordering::reverse)`\n\n## Strict and non-strict partial orders\n\nThe `<` and `>` operators behave according to a *strict* partial order.\nHowever, `<=` and `>=` do **not** behave according to a *non-strict*\npartial order.\nThat is because mathematically, a non-strict partial order would require\nreflexivity, i.e. `a <= 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 = f64::sqrt(-1.0);\nassert_eq!(a <= 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-bottom declaration order of the struct's members.\n\nWhen `derive`d on enums, variants are primarily ordered 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 example:\n\n```rust\n#[derive(PartialEq, PartialOrd)]\nenum E {\n Top,\n Bottom,\n}\n\nassert!(E::Top < E::Bottom);\n```\n\nHowever, manually setting the discriminants can override this default\nbehavior:\n\n```rust\n#[derive(PartialEq, PartialOrd)]\nenum E {\n Top = 2,\n Bottom = 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 remains possible to implement the others separately for types which do not have a\ntotal order. For example, for floating point numbers, `NaN < 0 == false` and `NaN >= 0 ==\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 name: String,\n height: u32,\n}\n\nimpl PartialOrd for Person {\n fn partial_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 PartialEq for Person {\n fn eq(&self, other: &Self) -> bool {\n self.height == 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 `Person` 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 Person {\n id: u32,\n name: String,\n height: f64,\n}\n\nimpl PartialOrd for Person {\n fn partial_cmp(&self, other: &Self) -> Option {\n self.height.partial_cmp(&other.height)\n }\n}\n\nimpl PartialEq for Person {\n fn eq(&self, other: &Self) -> bool {\n self.height == other.height\n }\n}\n```\n\n# Examples\n\n```rust\nlet x: u32 = 0;\nlet y: u32 = 1;\n\nassert_eq!(x < y, true);\nassert_eq!(x.lt(&y), true);\n```\n\n[`partial_cmp`]: PartialOrd::partial_cmp\n[`cmp`]: Ord::cmp") :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}>" :documentation (:kind "markdown" :value "`Result` is a type that represents either success ([`Ok`]) or failure ([`Err`]).\n\nSee the [module documentation](self) 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 determines it's\nappropriate.\n\nAn example of a non-`Send` type is the reference-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 update 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 `Send`.\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-undefined.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 special 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 FooUse(Foo<[i32]>); // error: Sized is not implemented for [i32]\nstruct BarUse(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 incompatible with [trait object]s\nwhere, by definition, the trait needs to work 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: &dyn Foo = &Impl; // OK\n// let y: &dyn Bar = &Impl; // error: the trait `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–encoded, growable string.\n\n`String` is the most common string type. It has ownership over the contents\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 literal string][`&str`] with [`String::from`]:\n\n[`String::from`]: From::from\n\n```rust\nlet hello = String::from(\"Hello, world!\");\n```\n\nYou can append a [`char`] to a `String` with the [`push`] method, and\nappend a [`&str`] with the [`push_str`] method:\n\n```rust\nlet mut hello = String::from(\"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 vector 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 = vec![240, 159, 146, 150];\n\n// We know these bytes are valid, so we'll use `unwrap()`.\nlet sparkle_heart = String::from_utf8(sparkle_heart).unwrap();\n\nassert_eq!(\"💖\", sparkle_heart);\n```\n\n[`from_utf8`]: String::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 UTF-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 = \"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 = ['h', 'e', 'l', 'l', 'o'];\nlet size: usize = 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 same\nlet s = \"💖💖💖💖💖\";\nassert_eq!(s.len(), 20);\n\nlet s = ['💖', '💖', '💖', '💖', '💖'];\nlet size: usize = s.into_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 should `i` be here? Several options include byte indices and\n`char` indices but, because of UTF-8 encoding, only byte indices\nwould provide constant time indexing. Getting the `i`th `char`, for\nexample, is available using [`chars`]:\n\n```rust\nlet s = \"hello\";\nlet third_character = s.chars().nth(2);\nassert_eq!(third_character, Some('l'));\n\nlet s = \"💖💖💖💖💖\";\nlet third_character = s.chars().nth(2);\nassert_eq!(third_character, Some('💖'));\n```\n\nNext, what should `s[i]` return? Because indexing returns a reference\nto underlying data it could be `&u8`, `&[u8]`, or something else similar.\nSince we're only providing one index, `&u8` makes the most sense but that\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 = \"hello\";\nassert_eq!(s.as_bytes()[0], 104);\n// or\nassert_eq!(s.as_bytes()[0], b'h');\n\n// The first byte is 240 which isn't obviously useful\nlet s = \"💖💖💖💖💖\";\nassert_eq!(s.as_bytes()[0], 240);\n```\n\nDue to these ambiguities/restrictions, indexing with a `usize` is simply\nforbidden:\n\n```rust\nlet s = \"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 accept 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 the byte indices provided are not character\nboundaries - see [`is_char_boundary`] for more details. See the implementations\nfor [`SliceIndex`] for more details on string slicing. For a non-panicking\nversion of string slicing, 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_boundary\n\nThe [`bytes`] and [`chars`] methods return iterators over the bytes 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`String` implements [Deref], and so inherits all of [`str`]'s\nmethods. In addition, this means that you can pass a `String` to a\nfunction which takes a [`&str`] by using an ampersand (`&`):\n\n```rust\nfn takes_str(s: &str) { }\n\nlet s = String::from(\"Hello\");\n\ntakes_str(&s);\n```\n\nThis will create a [`&str`] from the `String` and pass 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 specific\nreason.\n\nIn certain cases Rust doesn't have enough information to make this\nconversion, known as [`Deref`] coercion. In the following example 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 for &'a str {}\n\nfn example_func(example_arg: A) {}\n\nlet example_string = 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 explicitly 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 the [`str`] back to\n[`&str`]. The second way is more idiomatic, however both work to do the\nconversion explicitly rather than relying on the implicit conversion.\n\n# Representation\n\nA `String` is made up of three components: 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 is 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 than 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`]\nmethods:\n\n```rust\nuse std::mem;\n\nlet story = String::from(\"Once upon a time...\");\n\n// Prevent automatically dropping the String's data\nlet mut story = mem::ManuallyDrop::new(story);\n\nlet ptr = story.as_mut_ptr();\nlet len = story.len();\nlet capacity = story.capacity();\n\n// story 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 responsible for making sure the components are\n// valid:\nlet s = unsafe { String::from_raw_parts(ptr, len, capacity) } ;\n\nassert_eq!(String::from(\"Once 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 program:\n\n```rust\nlet mut s = String::new();\n\nprintln!(\"{}\", s.capacity());\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 = 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::with_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 loop.\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::ops::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 references between threads.\n\nThis trait is automatically implemented when the compiler 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 is no possibility of\n[undefined behavior][ub] (including data races) when passing\n`&T` references between threads.\n\nAs one would expect, primitive types like [`u8`] and [`f64`]\nare all [`Sync`], and so are simple aggregate 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 the 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`)\nbecomes read-only, as if it were a `& &T`. Hence there is no risk\nof a data race.\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 only if `T` is [`Sync`]\n\nTypes that are not `Sync` are those that have \"interior\nmutability\" in a non-thread-safe form, such as [`Cell`][cell]\nand [`RefCell`][refcell]. These types allow for mutation of\ntheir contents even through an immutable, shared reference. For\nexample the `set` method on [`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 reference-counting\npointer [`Rc`][rc]. Given any reference [`&Rc`][rc], you can clone\na new [`Rc`][rc], modifying the reference counts in a non-atomic 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 types with interior mutability must also use the\n[`cell::UnsafeCell`][unsafecell] wrapper around the value(s) which\ncan be mutated through a shared reference. 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/struct.Rc.html\n[arc]: ../../std/sync/struct.Arc.html\n[atomic data types]: crate::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 data.\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\nfrom 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 directly:\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 fail 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 may\ntrivially succeed but may also need special handling.\nFor example, there 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 go 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 reflexive, which means that `TryFrom for T`\nis implemented and cannot fail -- the associated `Error` type for\ncalling `T::try_from()` on a value of type `T` is [`Infallible`].\nWhen the [`!`] type is stabilized [`Infallible`] and [`!`] will be\nequivalent.\n\n`TryFrom` can be implemented as follows:\n\n```rust\nstruct GreaterThanZero(i32);\n\nimpl TryFrom for GreaterThanZero {\n type Error = &'static str;\n\n fn try_from(value: i32) -> Result {\n if value <= 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 = 1_000_000_000_000i64;\n// Silently truncates `big_number`, requires detecting\n// and handling the truncation after the fact.\nlet smaller_number = 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 = i32::try_from(big_number);\nassert!(try_smaller_number.is_err());\n\n// Returns `Ok(3)`.\nlet try_successful_smaller_number = i32::try_from(3);\nassert!(try_successful_smaller_number.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 not directly implement this trait,\nbut should prefer implementing the [`TryFrom`] trait, which offers\ngreater flexibility and provides an equivalent `TryInto`\nimplementation for free, thanks to a blanket implementation in the\nstandard library. For more information on this, see the\ndocumentation for [`Into`].\n\n# Implementing `TryInto`\n\nThis suffers the same restrictions 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 guarantees.\n\nFor information on what \"pinning\" is, see the [`pin` module] documentation.\n\nImplementing the `Unpin` trait for `T` expresses the fact that `T` is pinning-agnostic:\nit shall not expose nor rely on any pinning guarantees. This, in turn, means that a\n`Pin`-wrapped pointer to such a type 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 otherwise 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 restrict 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 ergonomics of APIs that require the use\nof [`Pin`] for soundness for some types, 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 many\n[`Future`] types that don't care about pinning. These futures can implement `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 consequences of [`Unpin`] within the wider scope of the pinning\nsystem, see the [section about `Unpin`] in the [`pin` module].\n\n`Unpin` has no consequence at 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\ninside 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\nSo 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 = \"this\".to_string();\nlet mut pinned_string = Pin::new(&mut string);\n\n// We need a mutable reference to call `mem::replace`.\n// We can obtain such a reference by (implicitly) invoking `Pin::deref_mut`,\n// but that is only possible because `String` implements `Unpin`.\nmem::replace(&mut *pinned_string, \"other\".to_string());\n```\n\nThis trait is automatically implemented for almost every type. The compiler is free\nto take the conservative stance of marking types as [`Unpin`] so long as all of the types that\ncompose its fields are also [`Unpin`]. This is because if a type implements [`Unpin`], then 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 pinning for soundness to ensure that type is *not* marked as [`Unpin`]\nby adding [`PhantomPinned`] field. For more details, see the [`pin` module] docs.\n\n[`mem::replace`]: crate::mem::replace \"mem replace\"\n[`Future`]: crate::future::Future \"Future\"\n[`Future::poll`]: crate::future::Future::poll \"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}>" :documentation (:kind "markdown" :value "A contiguous growable array type, written as `Vec`, short for 'vector'.\n\n# Examples\n\n```rust\nlet mut vec = Vec::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] = 7;\nassert_eq!(vec[0], 7);\n\nvec.extend([1, 2, 3]);\n\nfor 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 = vec![1, 2, 3];\nvec1.push(4);\nlet vec2 = Vec::from([1, 2, 3, 4]);\nassert_eq!(vec1, vec2);\n```\n\nIt can also initialize each element of a `Vec` with a given value.\nThis may be more efficient than performing allocation and initialization\nin separate steps, especially when initializing a vector of zeros:\n\n```rust\nlet vec = vec![0; 5];\nassert_eq!(vec, [0, 0, 0, 0, 0]);\n\n// The following is equivalent, but potentially slower:\nlet mut vec = Vec::with_capacity(5);\nvec.resize(5, 0);\nassert_eq!(vec, [0, 0, 0, 0, 0]);\n```\n\nFor more information, see\n[Capacity and Reallocation](#capacity-and-reallocation).\n\nUse a `Vec` as an efficient stack:\n\n```rust\nlet mut stack = Vec::new();\n\nstack.push(1);\nstack.push(2);\nstack.push(3);\n\nwhile let Some(top) = 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 = vec![0, 2, 4, 6];\nprintln!(\"{}\", v[1]); // it will display '2'\n```\n\nHowever 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 = 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-only objects.\nTo get a [slice][prim@slice], use [`&`]. Example:\n\n```rust\nfn read_slice(slice: &[usize]) {\n // ...\n}\n\nlet v = vec![0, 1];\nread_slice(&v);\n\n// ... and that's all!\n// you can also do it like this:\nlet u: &[usize] = &v;\n// or like this:\nlet u: &[_] = &v;\n```\n\nIn Rust, it's more common to pass slices as arguments rather than vectors\nwhen 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, which 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 with capacity 10 and length 0 would be an empty vector\nwith space for 10 more elements. Pushing 10 or fewer elements onto the\nvector will not change its capacity or cause reallocation to occur. However,\nif the vector's length 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 possible to specify how big the vector is expected to get.\n\n# Guarantees\n\nDue to its incredibly fundamental nature, `Vec` makes a lot of guarantees\nabout 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 unsafe code. Note that these guarantees refer to an unqualified `Vec`.\nIf additional type parameters are added (e.g., to support custom allocators),\noverriding their defaults may change the behavior.\n\nMost fundamentally, `Vec` is and always will be a (pointer, capacity, length)\ntriplet. No more, no less. The order of these fields is completely\nunspecified, and you should 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_capacity(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 this case\nthe `Vec` might not report a [`capacity`] of 0*. `Vec` will allocate if and only\nif [mem::size_of::\\]\\() * [capacity]\\() > 0. In general, `Vec`'s allocation\ndetails are very subtle --- if you intend to allocate memory using a `Vec`\nand use it for something else (either 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 configured to use by default), and its\npointer points to [`len`] initialized, contiguous elements in order (what\nyou would see if you coerced it to a slice), followed by [capacity] - [len]\nlogically uninitialized, 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` struct, it contains a\npointer to the head of the allocation in the heap, length and capacity.\nThe bottom part is the allocation on the heap, a contiguous 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 not stable and `Vec` makes no guarantees about its memory\n layout (including 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* It 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, incurring an additional branch\n on every access.\n\n`Vec` will never automatically shrink itself, even if completely empty. This\nensures no unnecessary allocations or deallocations occur. Emptying a `Vec`\nand then filling it back up to the same [`len`] should incur no calls to\nthe allocator. If you wish 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] == [capacity]. That is, the reported capacity is completely\naccurate, and can be relied on. It can even be used to manually free the memory\nallocated by a `Vec` if desired. Bulk insertion methods *may* reallocate, even\nwhen not necessary.\n\n`Vec` does not guarantee any particular growth strategy when reallocating\nwhen full, nor when [`reserve`] is called. The current strategy is basic\nand it may prove desirable to use a non-constant 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::with_capacity(n)`][`Vec::with_capacity`], will all produce a `Vec`\nwith at least the requested capacity. If [len] == [capacity],\n(as is the case for the [`vec!`] macro), then a `Vec` can be converted to\nand from a [`Box<[T]>`][owned slice] without reallocating or moving the elements.\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 optimizer does not consider\nthis a side-effect that must be preserved. There is one case which we will\nnot break, however: using `unsafe` code to write to the excess capacity,\nand then increasing the length to match, is always valid.\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::String\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::len\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 :preselect 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 that the elements\nimplement the [`Eq`] and [`Hash`] traits. This can frequently be achieved by\nusing `#[derive(PartialEq, Eq, Hash)]`. If you implement these yourself,\nit is important that the following property holds:\n\n```text\nk1 == k2 -> hash(k1) == 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 its 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 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 lets us omit an explicit type signature (which\n// would be `HashSet` in this example).\nlet mut books = HashSet::new();\n\n// Add some books.\nbooks.insert(\"A Dance With Dragons\".to_string());\nbooks.insert(\"To Kill a Mockingbird\".to_string());\nbooks.insert(\"The Odyssey\".to_string());\nbooks.insert(\"The Great Gatsby\".to_string());\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```\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 [`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 = 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_string(), 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::collections::HashSet;\n\nlet viking_names = 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[`RefCell`]: crate::cell::RefCell\n[`Cell`]: crate::cell::Cell") :deprecated :json-false :sortText "fffffff0" :filterText "HashSet" :textEdit (: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 "HashSet")] :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%3A1726418014" :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 "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 that the elements\nimplement the [`Eq`] and [`Hash`] traits. This can frequently be achieved by\nusing `#[derive(PartialEq, Eq, Hash)]`. If you implement these yourself,\nit is important that the following property holds:\n\n```text\nk1 == k2 -> hash(k1) == 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 its 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 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 lets us omit an explicit type signature (which\n// would be `HashSet` in this example).\nlet mut books = HashSet::new();\n\n// Add some books.\nbooks.insert(\"A Dance With Dragons\".to_string());\nbooks.insert(\"To Kill a Mockingbird\".to_string());\nbooks.insert(\"The Odyssey\".to_string());\nbooks.insert(\"The Great Gatsby\".to_string());\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```\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 [`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 = 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_string(), 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::collections::HashSet;\n\nlet viking_names = 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[`RefCell`]: crate::cell::RefCell\n[`Cell`]: crate::cell::Cell") :deprecated :json-false :sortText "fffffff0" :filterText "HashSet" :textEdit (: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)