####### LanguageClient 0.1.161 ####### 16:30:46 DEBUG unnamed src/language_client.rs:108 state: null ==> {"capabilities":{},"code_lens":{},"diagnostics":{},"highlight_match_ids":[],"highlight_source":null,"highlights":{},"highlights_placed":{},"initialization_options":null,"inlay_hints":{},"last_cursor_line":0,"last_line_diagnostic":" ","logger":{"level":"DEBUG","path":"/tmp/shiz"},"namespace_ids":{},"registrations":[],"roots":{},"semantic_highlights":{},"semantic_scope_to_hl_group_table":{},"semantic_scopes":{},"stashed_code_action_actions":[],"text_documents":{},"text_documents_metadata":{},"user_handlers":{},"viewports":{}} 16:30:46 INFO unnamed src/language_server_protocol.rs:3580 settings synced 16:30:46 INFO unnamed src/language_server_protocol.rs:3607 Project root: /home/dick/LanguageClient-neovim 16:30:46 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:EchomsgEllipsis","params":["Project root: /home/dick/LanguageClient-neovim"]} 16:30:46 DEBUG unnamed src/language_client.rs:108 state.roots.rust: null ==> "/home/dick/LanguageClient-neovim" 16:30:46 INFO unnamed src/language_server_protocol.rs:840 initialize; params=Object({"bufnr": Number(1), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(0), "line": Number(0)}), "viewport": Object({"end": Number(20), "start": Number(0)})}) 16:30:46 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:command","params":["sign define LanguageClientWarning text= texthl=LanguageClientWarningSign","sign define LanguageClientError text= texthl=LanguageClientErrorSign","sign define LanguageClientInformation text= texthl=LanguageClientInfoSign","sign define LanguageClientHint text= texthl=LanguageClientInfoSign"]} 16:30:46 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"eval","params":["s:hasSnippetSupport()"],"id":3} 16:30:46 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 3, "jsonrpc": "2.0", "result": 0} 16:30:46 DEBUG writer-Some("rust") src/rpcclient.rs:254 => Some("rust") {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":false},"completion":{"completionItem":{"insertReplaceSupport":false,"snippetSupport":false}},"declaration":{"linkSupport":true},"definition":{"linkSupport":true},"hover":{},"implementation":{"linkSupport":true},"publishDiagnostics":{"relatedInformation":true},"semanticHighlightingCapabilities":{"semanticHighlighting":true},"signatureHelp":{"signatureInformation":{"parameterInformation":{"labelOffsetSupport":true}}},"typeDefinition":{"linkSupport":true}},"workspace":{"applyEdit":true,"didChangeWatchedFiles":{"dynamicRegistration":true}}},"clientInfo":{"name":"LanguageClient-neovim","version":"0.1.161"},"processId":243451,"rootPath":"/home/dick/LanguageClient-neovim","rootUri":"file:///home/dick/LanguageClient-neovim","trace":"off"},"id":0} 16:30:46 DEBUG reader-Some("rust") src/rpcclient.rs:207 <= Some("rust") {"jsonrpc":"2.0","id":0,"result":{"capabilities":{"textDocumentSync":{"openClose":true,"change":2,"save":{}},"selectionRangeProvider":true,"hoverProvider":true,"completionProvider":{"triggerCharacters":[":",".","'","("],"completionItem":{"labelDetailsSupport":false}},"signatureHelpProvider":{"triggerCharacters":["(",",","<"]},"definitionProvider":true,"typeDefinitionProvider":true,"implementationProvider":true,"referencesProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"workspaceSymbolProvider":true,"codeActionProvider":{"codeActionKinds":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite"],"resolveProvider":true},"codeLensProvider":{"resolveProvider":true},"documentFormattingProvider":true,"documentRangeFormattingProvider":false,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"=","moreTriggerCharacter":[".",">","{"]},"renameProvider":{"prepareProvider":true},"foldingRangeProvider":true,"declarationProvider":true,"workspace":{"fileOperations":{"willRename":{"filters":[{"scheme":"file","pattern":{"glob":"**/*.rs","matches":"file"}},{"scheme":"file","pattern":{"glob":"**","matches":"folder"}}]}}},"callHierarchyProvider":true,"semanticTokensProvider":{"legend":{"tokenTypes":["comment","decorator","enumMember","enum","function","interface","keyword","macro","method","namespace","number","operator","parameter","property","string","struct","typeParameter","variable","angle","arithmetic","attribute","attributeBracket","bitwise","boolean","brace","bracket","builtinAttribute","builtinType","character","colon","comma","comparison","constParameter","derive","deriveHelper","dot","escapeSequence","formatSpecifier","generic","label","lifetime","logical","macroBang","parenthesis","punctuation","selfKeyword","selfTypeKeyword","semicolon","typeAlias","toolModule","union","unresolvedReference"],"tokenModifiers":["documentation","declaration","static","defaultLibrary","async","attribute","callable","constant","consuming","controlFlow","crateRoot","injected","intraDocLink","library","mutable","public","reference","trait","unsafe"]},"range":true,"full":{"delta":true}},"inlayHintProvider":{"resolveProvider":true},"experimental":{"externalDocs":true,"hoverRange":true,"joinLines":true,"matchingBrace":true,"moveItem":true,"onEnter":true,"openCargoToml":true,"parentModule":true,"runnables":{"kinds":["cargo"]},"ssr":true,"workspaceSymbolScopeKindFiltering":true}},"serverInfo":{"name":"rust-analyzer","version":"0.0.0 (8ddb8b7e8 2022-09-03)"}}} 16:30:46 DEBUG unnamed src/language_client.rs:108 state.capabilities.rust: null ==> {"capabilities":{"callHierarchyProvider":true,"codeActionProvider":{"codeActionKinds":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite"],"resolveProvider":true},"codeLensProvider":{"resolveProvider":true},"completionProvider":{"triggerCharacters":[":",".","'","("]},"declarationProvider":true,"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"=","moreTriggerCharacter":[".",">","{"]},"documentRangeFormattingProvider":false,"documentSymbolProvider":true,"experimental":{"externalDocs":true,"hoverRange":true,"joinLines":true,"matchingBrace":true,"moveItem":true,"onEnter":true,"openCargoToml":true,"parentModule":true,"runnables":{"kinds":["cargo"]},"ssr":true,"workspaceSymbolScopeKindFiltering":true},"foldingRangeProvider":true,"hoverProvider":true,"implementationProvider":true,"referencesProvider":true,"renameProvider":{"prepareProvider":true},"selectionRangeProvider":true,"semanticTokensProvider":{"full":{"delta":true},"legend":{"tokenModifiers":["documentation","declaration","static","defaultLibrary","async","attribute","callable","constant","consuming","controlFlow","crateRoot","injected","intraDocLink","library","mutable","public","reference","trait","unsafe"],"tokenTypes":["comment","decorator","enumMember","enum","function","interface","keyword","macro","method","namespace","number","operator","parameter","property","string","struct","typeParameter","variable","angle","arithmetic","attribute","attributeBracket","bitwise","boolean","brace","bracket","builtinAttribute","builtinType","character","colon","comma","comparison","constParameter","derive","deriveHelper","dot","escapeSequence","formatSpecifier","generic","label","lifetime","logical","macroBang","parenthesis","punctuation","selfKeyword","selfTypeKeyword","semicolon","typeAlias","toolModule","union","unresolvedReference"]},"range":true},"signatureHelpProvider":{"triggerCharacters":["(",",","<"]},"textDocumentSync":{"change":2,"openClose":true,"save":{}},"typeDefinitionProvider":true,"workspace":{},"workspaceSymbolProvider":true},"serverInfo":{"name":"rust-analyzer","version":"0.0.0 (8ddb8b7e8 2022-09-03)"}} 16:30:46 INFO unnamed src/language_server_protocol.rs:567 register_cm_source; language_id="rust" result=Object({"capabilities": Object({"callHierarchyProvider": Bool(true), "codeActionProvider": Object({"codeActionKinds": Array([String(""), String("quickfix"), String("refactor"), String("refactor.extract"), String("refactor.inline"), String("refactor.rewrite")]), "resolveProvider": Bool(true)}), "codeLensProvider": Object({"resolveProvider": Bool(true)}), "completionProvider": Object({"completionItem": Object({"labelDetailsSupport": Bool(false)}), "triggerCharacters": Array([String(":"), String("."), String("'"), String("(")])}), "declarationProvider": Bool(true), "definitionProvider": Bool(true), "documentFormattingProvider": Bool(true), "documentHighlightProvider": Bool(true), "documentOnTypeFormattingProvider": Object({"firstTriggerCharacter": String("="), "moreTriggerCharacter": Array([String("."), String(">"), String("{")])}), "documentRangeFormattingProvider": Bool(false), "documentSymbolProvider": Bool(true), "experimental": Object({"externalDocs": Bool(true), "hoverRange": Bool(true), "joinLines": Bool(true), "matchingBrace": Bool(true), "moveItem": Bool(true), "onEnter": Bool(true), "openCargoToml": Bool(true), "parentModule": Bool(true), "runnables": Object({"kinds": Array([String("cargo")])}), "ssr": Bool(true), "workspaceSymbolScopeKindFiltering": Bool(true)}), "foldingRangeProvider": Bool(true), "hoverProvider": Bool(true), "implementationProvider": Bool(true), "inlayHintProvider": Object({"resolveProvider": Bool(true)}), "referencesProvider": Bool(true), "renameProvider": Object({"prepareProvider": Bool(true)}), "selectionRangeProvider": Bool(true), "semanticTokensProvider": Object({"full": Object({"delta": Bool(true)}), "legend": Object({"tokenModifiers": Array([String("documentation"), String("declaration"), String("static"), String("defaultLibrary"), String("async"), String("attribute"), String("callable"), String("constant"), String("consuming"), String("controlFlow"), String("crateRoot"), String("injected"), String("intraDocLink"), String("library"), String("mutable"), String("public"), String("reference"), String("trait"), String("unsafe")]), "tokenTypes": Array([String("comment"), String("decorator"), String("enumMember"), String("enum"), String("function"), String("interface"), String("keyword"), String("macro"), String("method"), String("namespace"), String("number"), String("operator"), String("parameter"), String("property"), String("string"), String("struct"), String("typeParameter"), String("variable"), String("angle"), String("arithmetic"), String("attribute"), String("attributeBracket"), String("bitwise"), String("boolean"), String("brace"), String("bracket"), String("builtinAttribute"), String("builtinType"), String("character"), String("colon"), String("comma"), String("comparison"), String("constParameter"), String("derive"), String("deriveHelper"), String("dot"), String("escapeSequence"), String("formatSpecifier"), String("generic"), String("label"), String("lifetime"), String("logical"), String("macroBang"), String("parenthesis"), String("punctuation"), String("selfKeyword"), String("selfTypeKeyword"), String("semicolon"), String("typeAlias"), String("toolModule"), String("union"), String("unresolvedReference")])}), "range": Bool(true)}), "signatureHelpProvider": Object({"triggerCharacters": Array([String("("), String(","), String("<")])}), "textDocumentSync": Object({"change": Number(2), "openClose": Bool(true), "save": Object({})}), "typeDefinitionProvider": Bool(true), "workspace": Object({"fileOperations": Object({"willRename": Object({"filters": Array([Object({"pattern": Object({"glob": String("**/*.rs"), "matches": String("file")}), "scheme": String("file")}), Object({"pattern": Object({"glob": String("**"), "matches": String("folder")}), "scheme": String("file")})])})})}), "workspaceSymbolProvider": Bool(true)}), "serverInfo": Object({"name": String("rust-analyzer"), "version": String("0.0.0 (8ddb8b7e8 2022-09-03)")})}) 16:30:46 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"eval","params":["exists('g:cm_matcher')"],"id":4} 16:30:46 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 4, "jsonrpc": "2.0", "result": 0} 16:30:46 INFO unnamed src/language_server_protocol.rs:607 register_ncm2_source; language_id="rust" result=Object({"capabilities": Object({"callHierarchyProvider": Bool(true), "codeActionProvider": Object({"codeActionKinds": Array([String(""), String("quickfix"), String("refactor"), String("refactor.extract"), String("refactor.inline"), String("refactor.rewrite")]), "resolveProvider": Bool(true)}), "codeLensProvider": Object({"resolveProvider": Bool(true)}), "completionProvider": Object({"completionItem": Object({"labelDetailsSupport": Bool(false)}), "triggerCharacters": Array([String(":"), String("."), String("'"), String("(")])}), "declarationProvider": Bool(true), "definitionProvider": Bool(true), "documentFormattingProvider": Bool(true), "documentHighlightProvider": Bool(true), "documentOnTypeFormattingProvider": Object({"firstTriggerCharacter": String("="), "moreTriggerCharacter": Array([String("."), String(">"), String("{")])}), "documentRangeFormattingProvider": Bool(false), "documentSymbolProvider": Bool(true), "experimental": Object({"externalDocs": Bool(true), "hoverRange": Bool(true), "joinLines": Bool(true), "matchingBrace": Bool(true), "moveItem": Bool(true), "onEnter": Bool(true), "openCargoToml": Bool(true), "parentModule": Bool(true), "runnables": Object({"kinds": Array([String("cargo")])}), "ssr": Bool(true), "workspaceSymbolScopeKindFiltering": Bool(true)}), "foldingRangeProvider": Bool(true), "hoverProvider": Bool(true), "implementationProvider": Bool(true), "inlayHintProvider": Object({"resolveProvider": Bool(true)}), "referencesProvider": Bool(true), "renameProvider": Object({"prepareProvider": Bool(true)}), "selectionRangeProvider": Bool(true), "semanticTokensProvider": Object({"full": Object({"delta": Bool(true)}), "legend": Object({"tokenModifiers": Array([String("documentation"), String("declaration"), String("static"), String("defaultLibrary"), String("async"), String("attribute"), String("callable"), String("constant"), String("consuming"), String("controlFlow"), String("crateRoot"), String("injected"), String("intraDocLink"), String("library"), String("mutable"), String("public"), String("reference"), String("trait"), String("unsafe")]), "tokenTypes": Array([String("comment"), String("decorator"), String("enumMember"), String("enum"), String("function"), String("interface"), String("keyword"), String("macro"), String("method"), String("namespace"), String("number"), String("operator"), String("parameter"), String("property"), String("string"), String("struct"), String("typeParameter"), String("variable"), String("angle"), String("arithmetic"), String("attribute"), String("attributeBracket"), String("bitwise"), String("boolean"), String("brace"), String("bracket"), String("builtinAttribute"), String("builtinType"), String("character"), String("colon"), String("comma"), String("comparison"), String("constParameter"), String("derive"), String("deriveHelper"), String("dot"), String("escapeSequence"), String("formatSpecifier"), String("generic"), String("label"), String("lifetime"), String("logical"), String("macroBang"), String("parenthesis"), String("punctuation"), String("selfKeyword"), String("selfTypeKeyword"), String("semicolon"), String("typeAlias"), String("toolModule"), String("union"), String("unresolvedReference")])}), "range": Bool(true)}), "signatureHelpProvider": Object({"triggerCharacters": Array([String("("), String(","), String("<")])}), "textDocumentSync": Object({"change": Number(2), "openClose": Bool(true), "save": Object({})}), "typeDefinitionProvider": Bool(true), "workspace": Object({"fileOperations": Object({"willRename": Object({"filters": Array([Object({"pattern": Object({"glob": String("**/*.rs"), "matches": String("file")}), "scheme": String("file")}), Object({"pattern": Object({"glob": String("**"), "matches": String("folder")}), "scheme": String("file")})])})})}), "workspaceSymbolProvider": Bool(true)}), "serverInfo": Object({"name": String("rust-analyzer"), "version": String("0.0.0 (8ddb8b7e8 2022-09-03)")})}) 16:30:46 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"eval","params":["exists('g:ncm2_loaded')"],"id":5} 16:30:46 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 5, "jsonrpc": "2.0", "result": 0} 16:30:46 INFO unnamed src/language_server_protocol.rs:647 parse_semantic_scopes; language_id="rust" result=Object({"capabilities": Object({"callHierarchyProvider": Bool(true), "codeActionProvider": Object({"codeActionKinds": Array([String(""), String("quickfix"), String("refactor"), String("refactor.extract"), String("refactor.inline"), String("refactor.rewrite")]), "resolveProvider": Bool(true)}), "codeLensProvider": Object({"resolveProvider": Bool(true)}), "completionProvider": Object({"completionItem": Object({"labelDetailsSupport": Bool(false)}), "triggerCharacters": Array([String(":"), String("."), String("'"), String("(")])}), "declarationProvider": Bool(true), "definitionProvider": Bool(true), "documentFormattingProvider": Bool(true), "documentHighlightProvider": Bool(true), "documentOnTypeFormattingProvider": Object({"firstTriggerCharacter": String("="), "moreTriggerCharacter": Array([String("."), String(">"), String("{")])}), "documentRangeFormattingProvider": Bool(false), "documentSymbolProvider": Bool(true), "experimental": Object({"externalDocs": Bool(true), "hoverRange": Bool(true), "joinLines": Bool(true), "matchingBrace": Bool(true), "moveItem": Bool(true), "onEnter": Bool(true), "openCargoToml": Bool(true), "parentModule": Bool(true), "runnables": Object({"kinds": Array([String("cargo")])}), "ssr": Bool(true), "workspaceSymbolScopeKindFiltering": Bool(true)}), "foldingRangeProvider": Bool(true), "hoverProvider": Bool(true), "implementationProvider": Bool(true), "inlayHintProvider": Object({"resolveProvider": Bool(true)}), "referencesProvider": Bool(true), "renameProvider": Object({"prepareProvider": Bool(true)}), "selectionRangeProvider": Bool(true), "semanticTokensProvider": Object({"full": Object({"delta": Bool(true)}), "legend": Object({"tokenModifiers": Array([String("documentation"), String("declaration"), String("static"), String("defaultLibrary"), String("async"), String("attribute"), String("callable"), String("constant"), String("consuming"), String("controlFlow"), String("crateRoot"), String("injected"), String("intraDocLink"), String("library"), String("mutable"), String("public"), String("reference"), String("trait"), String("unsafe")]), "tokenTypes": Array([String("comment"), String("decorator"), String("enumMember"), String("enum"), String("function"), String("interface"), String("keyword"), String("macro"), String("method"), String("namespace"), String("number"), String("operator"), String("parameter"), String("property"), String("string"), String("struct"), String("typeParameter"), String("variable"), String("angle"), String("arithmetic"), String("attribute"), String("attributeBracket"), String("bitwise"), String("boolean"), String("brace"), String("bracket"), String("builtinAttribute"), String("builtinType"), String("character"), String("colon"), String("comma"), String("comparison"), String("constParameter"), String("derive"), String("deriveHelper"), String("dot"), String("escapeSequence"), String("formatSpecifier"), String("generic"), String("label"), String("lifetime"), String("logical"), String("macroBang"), String("parenthesis"), String("punctuation"), String("selfKeyword"), String("selfTypeKeyword"), String("semicolon"), String("typeAlias"), String("toolModule"), String("union"), String("unresolvedReference")])}), "range": Bool(true)}), "signatureHelpProvider": Object({"triggerCharacters": Array([String("("), String(","), String("<")])}), "textDocumentSync": Object({"change": Number(2), "openClose": Bool(true), "save": Object({})}), "typeDefinitionProvider": Bool(true), "workspace": Object({"fileOperations": Object({"willRename": Object({"filters": Array([Object({"pattern": Object({"glob": String("**/*.rs"), "matches": String("file")}), "scheme": String("file")}), Object({"pattern": Object({"glob": String("**"), "matches": String("folder")}), "scheme": String("file")})])})})}), "workspaceSymbolProvider": Bool(true)}), "serverInfo": Object({"name": String("rust-analyzer"), "version": String("0.0.0 (8ddb8b7e8 2022-09-03)")})}) 16:30:46 INFO unnamed src/language_server_protocol.rs:1019 initialized; params=Object({"bufnr": Number(1), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(0), "line": Number(0)}), "viewport": Object({"end": Number(20), "start": Number(0)})}) 16:30:46 INFO unnamed src/language_server_protocol.rs:666 update_semantic_highlight_tables; language_id="rust" 16:30:46 DEBUG writer-Some("rust") src/rpcclient.rs:254 => Some("rust") {"jsonrpc":"2.0","method":"initialized","params":{}} 16:30:46 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"eval","params":["LSP#filename()"],"id":6} 16:30:46 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 6, "jsonrpc": "2.0", "result": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"} 16:30:46 INFO unnamed src/language_server_protocol.rs:1946 text_document_did_open; params=Object({"bufnr": Number(1), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(0), "line": Number(0)}), "viewport": Object({"end": Number(20), "start": Number(0)})}) 16:30:46 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"setbufvar","params":["/home/dick/LanguageClient-neovim/src/rpcclient.rs","LanguageClient_isServerRunning",1]} 16:30:46 DEBUG writer-Some("rust") src/rpcclient.rs:254 => Some("rust") {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"rust":{"all_targets":false,"build_on_save":true,"clippy_preference":"on","wait_to_build":0}}}} 16:30:46 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:ExecuteAutocmd","params":["LanguageClientStarted"]} 16:30:46 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"LSP#text","params":["/home/dick/LanguageClient-neovim/src/rpcclient.rs"],"id":7} 16:30:46 DEBUG reader-Some("rust") src/rpcclient.rs:207 <= Some("rust") {"jsonrpc":"2.0","id":0,"method":"workspace/configuration","params":{"items":[{"section":"rust-analyzer"}]}} 16:30:46 ERROR unnamed src/rpchandler.rs:27 Error handling message: Message not handled: MethodCall { jsonrpc: Some(V2), method: "workspace/configuration", params: Map({"items": Array([Object({"section": String("rust-analyzer")})])}), id: Num(0) } Message: {"jsonrpc":"2.0","method":"workspace/configuration","params":{"items":[{"section":"rust-analyzer"}]},"id":0} Error: Message not handled: MethodCall { jsonrpc: Some(V2), method: "workspace/configuration", params: Map({"items": Array([Object({"section": String("rust-analyzer")})])}), id: Num(0) } 16:30:46 DEBUG writer-Some("rust") src/rpcclient.rs:254 => Some("rust") {"jsonrpc":"2.0","error":{"code":-32603,"message":"Message not handled: MethodCall { jsonrpc: Some(V2), method: \"workspace/configuration\", params: Map({\"items\": Array([Object({\"section\": String(\"rust-analyzer\")})])}), id: Num(0) }"},"id":0} 16:30:46 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 7, "jsonrpc": "2.0", "result": ["use crate::types::{Call, Id, LSError, LanguageId, RawMessage, ToInt, ToParams, ToRpcError};", "use anyhow::{anyhow, Result};", "use crossbeam::channel::{bounded, unbounded, Receiver, Sender};", "use log::*;", "use regex::Regex;", "use serde::{de::DeserializeOwned, Serialize};", "use std::io::Write;", "use std::str::FromStr;", "use std::{", " collections::HashMap,", " io::BufRead,", " sync::atomic::{AtomicU64, Ordering},", " thread,", " time::Duration,", "};", "", "const CONTENT_MODIFIED_ERROR_CODE: i64 = -32801;", "", "lazy_static! {", " // this regex is used to remove some additional fields that we get from some servers, namely:", " // meta, sent by javascript-typescript-langserver and requestMethod, sent by Sorbet.", " static ref RE_REMOVE_EXTRA_FIELDS: Regex =", " Regex::new(r#\",\\s?\"(?:meta|requestMethod)\":(?:\"\\w+(/\\w+)?\"|\\{\\})\"#).unwrap();", "}", "", "#[derive(Serialize)]", "pub struct RpcClient {", " language_id: LanguageId,", " #[serde(skip_serializing)]", " id: AtomicU64,", " #[serde(skip_serializing)]", " writer_tx: Sender,", " #[serde(skip_serializing)]", " reader_tx: Sender<(Id, Sender)>,", " pub process_id: Option,", "}", "", "impl RpcClient {", " #[allow(clippy::new_ret_no_self)]", " pub fn new(", " language_id: LanguageId,", " reader: impl BufRead + Send + 'static,", " writer: impl Write + Send + 'static,", " process_id: Option,", " sink: Sender,", " on_crash: impl Fn(&LanguageId) + Clone + Send + 'static,", " ) -> Result {", " let (reader_tx, reader_rx): (Sender<(Id, Sender)>, _) = unbounded();", "", " let language_id_clone = language_id.clone();", " let reader_thread_name = format!(\"reader-{:?}\", language_id);", " let on_crash_clone = on_crash.clone();", " thread::Builder::new()", " .name(reader_thread_name.clone())", " .spawn(move || {", " if let Err(err) = loop_read(reader, reader_rx, &sink, &language_id_clone) {", " match err.downcast_ref::() {", " Some(err) if err.kind() == std::io::ErrorKind::UnexpectedEof => {", " on_crash_clone(&language_id_clone)", " }", " _ => {}", " }", "", " error!(\"Thread {} exited with error: {:?}\", reader_thread_name, err);", " }", " })?;", "", " let (writer_tx, writer_rx) = unbounded();", " let writer_thread_name = format!(\"writer-{:?}\", language_id);", " let language_id_clone = language_id.clone();", " thread::Builder::new()", " .name(writer_thread_name.clone())", " .spawn(move || {", " if let Err(err) = loop_write(writer, &writer_rx, &language_id_clone) {", " match err.downcast_ref::() {", " Some(err) if err.kind() == std::io::ErrorKind::BrokenPipe => {", " on_crash(&language_id_clone)", " }", " _ => {}", " }", "", " error!(\"Thread {} exited with error: {:?}\", writer_thread_name, err);", " }", " })?;", "", " Ok(Self {", " language_id,", " id: AtomicU64::default(),", " process_id,", " reader_tx,", " writer_tx,", " })", " }", "", " pub fn call(", " &self,", " method: impl AsRef,", " params: impl Serialize,", " ) -> Result {", " let method = method.as_ref();", " let id = self.id.fetch_add(1, Ordering::SeqCst);", " let msg = jsonrpc_core::MethodCall {", " jsonrpc: Some(jsonrpc_core::Version::V2),", " id: jsonrpc_core::Id::Num(id),", " method: method.to_owned(),", " params: params.to_params()?,", " };", " let (tx, rx) = bounded(1);", " self.reader_tx.send((id, tx))?;", " self.writer_tx.send(RawMessage::MethodCall(msg))?;", " // TODO: duration from config.", " match rx.recv_timeout(Duration::from_secs(60))? {", " jsonrpc_core::Output::Success(ok) => Ok(serde_json::from_value(ok.result)?),", " // NOTE: Errors with code -32801 correspond to the protocol's ContentModified error,", " // which we don't want to show to the user and should ignore, as the result of the", " // request that triggered this error has been invalidated by changes to the state", " // of the server, so we must handle this error specifically.", " jsonrpc_core::Output::Failure(err)", " if err.error.code.code() == CONTENT_MODIFIED_ERROR_CODE =>", " {", " Err(anyhow::Error::from(LSError::ContentModified))", " }", " jsonrpc_core::Output::Failure(err) => Err(anyhow!(\"Error: {:?}\", err)),", " }", " }", "", " pub fn notify(&self, method: impl AsRef, params: impl Serialize) -> Result<()> {", " let method = method.as_ref();", "", " let msg = jsonrpc_core::Notification {", " jsonrpc: Some(jsonrpc_core::Version::V2),", " method: method.to_owned(),", " params: params.to_params()?,", " };", " self.writer_tx.send(RawMessage::Notification(msg))?;", " Ok(())", " }", "", " pub fn output(&self, id: Id, result: Result) -> Result<()> {", " let output = match result {", " Ok(ok) => jsonrpc_core::Output::Success(jsonrpc_core::Success {", " jsonrpc: Some(jsonrpc_core::Version::V2),", " id: jsonrpc_core::Id::Num(id),", " result: serde_json::to_value(ok)?,", " }),", " Err(err) => jsonrpc_core::Output::Failure(jsonrpc_core::Failure {", " jsonrpc: Some(jsonrpc_core::Version::V2),", " id: jsonrpc_core::Id::Num(id),", " error: err.to_rpc_error(),", " }),", " };", "", " self.writer_tx.send(RawMessage::Output(output))?;", " Ok(())", " }", "}", "", "fn loop_read(", " reader: impl BufRead,", " reader_rx: Receiver<(Id, Sender)>,", " sink: &Sender,", " language_id: &LanguageId,", ") -> Result<()> {", " let mut pending_outputs = HashMap::new();", "", " // Count how many consequent empty lines.", " let mut count_empty_lines = 0;", "", " let mut reader = reader;", " let mut content_length = 0;", " loop {", " let mut message = String::new();", " let mut line = String::new();", " if language_id.is_some() {", " reader.read_line(&mut line)?;", " let line = line.trim();", " if line.is_empty() {", " count_empty_lines += 1;", " if count_empty_lines > 5 {", " return Err(anyhow!(\"Unable to read from language server\"));", " }", "", " let mut buf = vec![0; content_length];", " reader.read_exact(buf.as_mut_slice())?;", " message = String::from_utf8(buf)?;", " } else {", " count_empty_lines = 0;", " if !line.starts_with(\"Content-Length\") {", " continue;", " }", "", " let tokens: Vec<&str> = line.splitn(2, ':').collect();", " let len = tokens", " .get(1)", " .ok_or_else(|| anyhow!(\"Failed to get length! tokens: {:?}\", tokens))?", " .trim();", " content_length = usize::from_str(len)?;", " }", " } else if reader.read_line(&mut message)? == 0 {", " break;", " }", "", " let message = message.trim();", " if message.is_empty() {", " continue;", " }", " debug!(\"<= {:?} {}\", language_id, message);", " // FIXME: Remove extra `meta` property from javascript-typescript-langserver and", " // `requestMethod` sent by Sorbet.", " let s = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");", " let message = serde_json::from_str(&s);", " if let Err(ref err) = message {", " error!(", " \"Failed to deserialize output: {}\\n\\n Message: {}\\n\\nError: {:?}\",", " err, s, err", " );", " continue;", " }", " // TODO: cleanup.", " let message = message.unwrap();", " match message {", " RawMessage::MethodCall(method_call) => {", " sink.send(Call::MethodCall(language_id.clone(), method_call))?;", " }", " RawMessage::Notification(notification) => {", " sink.send(Call::Notification(language_id.clone(), notification))?;", " }", " RawMessage::Output(output) => {", " while let Ok((id, tx)) = reader_rx.try_recv() {", " pending_outputs.insert(id, tx);", " }", "", " if let Some(tx) = pending_outputs.remove(&output.id().to_int()?) {", " tx.send(output)", " .map_err(|output| anyhow!(\"Failed to send output: {:?}\", output))?;", " }", " }", " };", " }", "", " info!(\"reader-{:?} terminated\", language_id);", " Ok(())", "}", "", "fn loop_write(", " writer: impl Write,", " rx: &Receiver,", " language_id: &LanguageId,", ") -> Result<()> {", " let mut writer = writer;", "", " for msg in rx.iter() {", " let s = serde_json::to_string(&msg)?;", " debug!(\"=> {:?} {}\", language_id, s);", " if language_id.is_none() {", " // Use different convention for two reasons,", " // 1. If using '\\r\\ncontent', nvim will receive output as `\\r` + `content`, while vim", " // receives `content`.", " // 2. Without last line ending, vim output handler won't be triggered.", " write!(writer, \"Content-Length: {}\\n\\n{}\\n\", s.len(), s)?;", " } else {", " write!(writer, \"Content-Length: {}\\r\\n\\r\\n{}\", s.len(), s)?;", " };", " writer.flush()?;", " }", " Ok(())", "}", "", "#[cfg(test)]", "mod test {", " use super::RE_REMOVE_EXTRA_FIELDS;", " use crate::types::RawMessage;", "", " #[test]", " // The library we're using for json-rpc doesn't accept extra fields in the structs used to", " // deserialize the message. Sorbet (and possibly other servers) sends an extra field in it, so", " // the client fails to deserialize that response.", " // Our previous solution was to pin the dependency to jsonrpc-core to version 12, but is", " // suboptimal, so we now try to remove the extra fields we know of from the response.", " //", " // See related issue: https://github.com/autozimu/LanguageClient-neovim/issues/892", " fn it_should_remove_extra_fields() {", " // it removes the requestMethod field from Sorbet", " let message = r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"requestMethod\":\"initialize\",\"result\":0}\"#;", " let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");", " let result: Result = serde_json::from_str(&message);", " assert!(result.is_ok());", "", " let message =", " r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"requestMethod\":\"textDocument/definition\",\"result\":0}\"#;", " let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");", " let result: Result = serde_json::from_str(&message);", " assert!(result.is_ok());", "", " // it removes the meta field from javascript-typescript-langserver", " let message = r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"meta\":{},\"result\":0}\"#;", " let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");", " let result: Result = serde_json::from_str(&message);", " assert!(result.is_ok());", " }", "}", ""]} 16:30:46 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"eval","params":["s:GetVar('LanguageClient_setOmnifunc', v:true)"],"id":8} 16:30:46 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 8, "jsonrpc": "2.0", "result": true} 16:30:46 DEBUG unnamed src/language_client.rs:108 state.text_documents./home/dick/LanguageClient-neovim/src/rpcclient.rs: null ==> {"languageId":"rust","text":"use crate::types::{Call, Id, LSError, LanguageId, RawMessage, ToInt, ToParams, ToRpcError};\nuse anyhow::{anyhow, Result};\nuse crossbeam::channel::{bounded, unbounded, Receiver, Sender};\nuse log::*;\nuse regex::Regex;\nuse serde::{de::DeserializeOwned, Serialize};\nuse std::io::Write;\nuse std::str::FromStr;\nuse std::{\n collections::HashMap,\n io::BufRead,\n sync::atomic::{AtomicU64, Ordering},\n thread,\n time::Duration,\n};\n\nconst CONTENT_MODIFIED_ERROR_CODE: i64 = -32801;\n\nlazy_static! {\n // this regex is used to remove some additional fields that we get from some servers, namely:\n // meta, sent by javascript-typescript-langserver and requestMethod, sent by Sorbet.\n static ref RE_REMOVE_EXTRA_FIELDS: Regex =\n Regex::new(r#\",\\s?\"(?:meta|requestMethod)\":(?:\"\\w+(/\\w+)?\"|\\{\\})\"#).unwrap();\n}\n\n#[derive(Serialize)]\npub struct RpcClient {\n language_id: LanguageId,\n #[serde(skip_serializing)]\n id: AtomicU64,\n #[serde(skip_serializing)]\n writer_tx: Sender,\n #[serde(skip_serializing)]\n reader_tx: Sender<(Id, Sender)>,\n pub process_id: Option,\n}\n\nimpl RpcClient {\n #[allow(clippy::new_ret_no_self)]\n pub fn new(\n language_id: LanguageId,\n reader: impl BufRead + Send + 'static,\n writer: impl Write + Send + 'static,\n process_id: Option,\n sink: Sender,\n on_crash: impl Fn(&LanguageId) + Clone + Send + 'static,\n ) -> Result {\n let (reader_tx, reader_rx): (Sender<(Id, Sender)>, _) = unbounded();\n\n let language_id_clone = language_id.clone();\n let reader_thread_name = format!(\"reader-{:?}\", language_id);\n let on_crash_clone = on_crash.clone();\n thread::Builder::new()\n .name(reader_thread_name.clone())\n .spawn(move || {\n if let Err(err) = loop_read(reader, reader_rx, &sink, &language_id_clone) {\n match err.downcast_ref::() {\n Some(err) if err.kind() == std::io::ErrorKind::UnexpectedEof => {\n on_crash_clone(&language_id_clone)\n }\n _ => {}\n }\n\n error!(\"Thread {} exited with error: {:?}\", reader_thread_name, err);\n }\n })?;\n\n let (writer_tx, writer_rx) = unbounded();\n let writer_thread_name = format!(\"writer-{:?}\", language_id);\n let language_id_clone = language_id.clone();\n thread::Builder::new()\n .name(writer_thread_name.clone())\n .spawn(move || {\n if let Err(err) = loop_write(writer, &writer_rx, &language_id_clone) {\n match err.downcast_ref::() {\n Some(err) if err.kind() == std::io::ErrorKind::BrokenPipe => {\n on_crash(&language_id_clone)\n }\n _ => {}\n }\n\n error!(\"Thread {} exited with error: {:?}\", writer_thread_name, err);\n }\n })?;\n\n Ok(Self {\n language_id,\n id: AtomicU64::default(),\n process_id,\n reader_tx,\n writer_tx,\n })\n }\n\n pub fn call(\n &self,\n method: impl AsRef,\n params: impl Serialize,\n ) -> Result {\n let method = method.as_ref();\n let id = self.id.fetch_add(1, Ordering::SeqCst);\n let msg = jsonrpc_core::MethodCall {\n jsonrpc: Some(jsonrpc_core::Version::V2),\n id: jsonrpc_core::Id::Num(id),\n method: method.to_owned(),\n params: params.to_params()?,\n };\n let (tx, rx) = bounded(1);\n self.reader_tx.send((id, tx))?;\n self.writer_tx.send(RawMessage::MethodCall(msg))?;\n // TODO: duration from config.\n match rx.recv_timeout(Duration::from_secs(60))? {\n jsonrpc_core::Output::Success(ok) => Ok(serde_json::from_value(ok.result)?),\n // NOTE: Errors with code -32801 correspond to the protocol's ContentModified error,\n // which we don't want to show to the user and should ignore, as the result of the\n // request that triggered this error has been invalidated by changes to the state\n // of the server, so we must handle this error specifically.\n jsonrpc_core::Output::Failure(err)\n if err.error.code.code() == CONTENT_MODIFIED_ERROR_CODE =>\n {\n Err(anyhow::Error::from(LSError::ContentModified))\n }\n jsonrpc_core::Output::Failure(err) => Err(anyhow!(\"Error: {:?}\", err)),\n }\n }\n\n pub fn notify(&self, method: impl AsRef, params: impl Serialize) -> Result<()> {\n let method = method.as_ref();\n\n let msg = jsonrpc_core::Notification {\n jsonrpc: Some(jsonrpc_core::Version::V2),\n method: method.to_owned(),\n params: params.to_params()?,\n };\n self.writer_tx.send(RawMessage::Notification(msg))?;\n Ok(())\n }\n\n pub fn output(&self, id: Id, result: Result) -> Result<()> {\n let output = match result {\n Ok(ok) => jsonrpc_core::Output::Success(jsonrpc_core::Success {\n jsonrpc: Some(jsonrpc_core::Version::V2),\n id: jsonrpc_core::Id::Num(id),\n result: serde_json::to_value(ok)?,\n }),\n Err(err) => jsonrpc_core::Output::Failure(jsonrpc_core::Failure {\n jsonrpc: Some(jsonrpc_core::Version::V2),\n id: jsonrpc_core::Id::Num(id),\n error: err.to_rpc_error(),\n }),\n };\n\n self.writer_tx.send(RawMessage::Output(output))?;\n Ok(())\n }\n}\n\nfn loop_read(\n reader: impl BufRead,\n reader_rx: Receiver<(Id, Sender)>,\n sink: &Sender,\n language_id: &LanguageId,\n) -> Result<()> {\n let mut pending_outputs = HashMap::new();\n\n // Count how many consequent empty lines.\n let mut count_empty_lines = 0;\n\n let mut reader = reader;\n let mut content_length = 0;\n loop {\n let mut message = String::new();\n let mut line = String::new();\n if language_id.is_some() {\n reader.read_line(&mut line)?;\n let line = line.trim();\n if line.is_empty() {\n count_empty_lines += 1;\n if count_empty_lines > 5 {\n return Err(anyhow!(\"Unable to read from language server\"));\n }\n\n let mut buf = vec![0; content_length];\n reader.read_exact(buf.as_mut_slice())?;\n message = String::from_utf8(buf)?;\n } else {\n count_empty_lines = 0;\n if !line.starts_with(\"Content-Length\") {\n continue;\n }\n\n let tokens: Vec<&str> = line.splitn(2, ':').collect();\n let len = tokens\n .get(1)\n .ok_or_else(|| anyhow!(\"Failed to get length! tokens: {:?}\", tokens))?\n .trim();\n content_length = usize::from_str(len)?;\n }\n } else if reader.read_line(&mut message)? == 0 {\n break;\n }\n\n let message = message.trim();\n if message.is_empty() {\n continue;\n }\n debug!(\"<= {:?} {}\", language_id, message);\n // FIXME: Remove extra `meta` property from javascript-typescript-langserver and\n // `requestMethod` sent by Sorbet.\n let s = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");\n let message = serde_json::from_str(&s);\n if let Err(ref err) = message {\n error!(\n \"Failed to deserialize output: {}\\n\\n Message: {}\\n\\nError: {:?}\",\n err, s, err\n );\n continue;\n }\n // TODO: cleanup.\n let message = message.unwrap();\n match message {\n RawMessage::MethodCall(method_call) => {\n sink.send(Call::MethodCall(language_id.clone(), method_call))?;\n }\n RawMessage::Notification(notification) => {\n sink.send(Call::Notification(language_id.clone(), notification))?;\n }\n RawMessage::Output(output) => {\n while let Ok((id, tx)) = reader_rx.try_recv() {\n pending_outputs.insert(id, tx);\n }\n\n if let Some(tx) = pending_outputs.remove(&output.id().to_int()?) {\n tx.send(output)\n .map_err(|output| anyhow!(\"Failed to send output: {:?}\", output))?;\n }\n }\n };\n }\n\n info!(\"reader-{:?} terminated\", language_id);\n Ok(())\n}\n\nfn loop_write(\n writer: impl Write,\n rx: &Receiver,\n language_id: &LanguageId,\n) -> Result<()> {\n let mut writer = writer;\n\n for msg in rx.iter() {\n let s = serde_json::to_string(&msg)?;\n debug!(\"=> {:?} {}\", language_id, s);\n if language_id.is_none() {\n // Use different convention for two reasons,\n // 1. If using '\\r\\ncontent', nvim will receive output as `\\r` + `content`, while vim\n // receives `content`.\n // 2. Without last line ending, vim output handler won't be triggered.\n write!(writer, \"Content-Length: {}\\n\\n{}\\n\", s.len(), s)?;\n } else {\n write!(writer, \"Content-Length: {}\\r\\n\\r\\n{}\", s.len(), s)?;\n };\n writer.flush()?;\n }\n Ok(())\n}\n\n#[cfg(test)]\nmod test {\n use super::RE_REMOVE_EXTRA_FIELDS;\n use crate::types::RawMessage;\n\n #[test]\n // The library we're using for json-rpc doesn't accept extra fields in the structs used to\n // deserialize the message. Sorbet (and possibly other servers) sends an extra field in it, so\n // the client fails to deserialize that response.\n // Our previous solution was to pin the dependency to jsonrpc-core to version 12, but is\n // suboptimal, so we now try to remove the extra fields we know of from the response.\n //\n // See related issue: https://github.com/autozimu/LanguageClient-neovim/issues/892\n fn it_should_remove_extra_fields() {\n // it removes the requestMethod field from Sorbet\n let message = r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"requestMethod\":\"initialize\",\"result\":0}\"#;\n let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");\n let result: Result = serde_json::from_str(&message);\n assert!(result.is_ok());\n\n let message =\n r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"requestMethod\":\"textDocument/definition\",\"result\":0}\"#;\n let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");\n let result: Result = serde_json::from_str(&message);\n assert!(result.is_ok());\n\n // it removes the meta field from javascript-typescript-langserver\n let message = r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"meta\":{},\"result\":0}\"#;\n let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");\n let result: Result = serde_json::from_str(&message);\n assert!(result.is_ok());\n }\n}\n","uri":"file:///home/dick/LanguageClient-neovim/src/rpcclient.rs","version":0} 16:30:46 INFO unnamed src/language_server_protocol.rs:1888 text_document_code_lens; params=Object({"bufnr": Number(1), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(0), "line": Number(0)}), "viewport": Object({"end": Number(20), "start": Number(0)})}) 16:30:46 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:command","params":["setlocal omnifunc=LanguageClient#complete"]} 16:30:46 DEBUG writer-Some("rust") src/rpcclient.rs:254 => Some("rust") {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"rust","text":"use crate::types::{Call, Id, LSError, LanguageId, RawMessage, ToInt, ToParams, ToRpcError};\nuse anyhow::{anyhow, Result};\nuse crossbeam::channel::{bounded, unbounded, Receiver, Sender};\nuse log::*;\nuse regex::Regex;\nuse serde::{de::DeserializeOwned, Serialize};\nuse std::io::Write;\nuse std::str::FromStr;\nuse std::{\n collections::HashMap,\n io::BufRead,\n sync::atomic::{AtomicU64, Ordering},\n thread,\n time::Duration,\n};\n\nconst CONTENT_MODIFIED_ERROR_CODE: i64 = -32801;\n\nlazy_static! {\n // this regex is used to remove some additional fields that we get from some servers, namely:\n // meta, sent by javascript-typescript-langserver and requestMethod, sent by Sorbet.\n static ref RE_REMOVE_EXTRA_FIELDS: Regex =\n Regex::new(r#\",\\s?\"(?:meta|requestMethod)\":(?:\"\\w+(/\\w+)?\"|\\{\\})\"#).unwrap();\n}\n\n#[derive(Serialize)]\npub struct RpcClient {\n language_id: LanguageId,\n #[serde(skip_serializing)]\n id: AtomicU64,\n #[serde(skip_serializing)]\n writer_tx: Sender,\n #[serde(skip_serializing)]\n reader_tx: Sender<(Id, Sender)>,\n pub process_id: Option,\n}\n\nimpl RpcClient {\n #[allow(clippy::new_ret_no_self)]\n pub fn new(\n language_id: LanguageId,\n reader: impl BufRead + Send + 'static,\n writer: impl Write + Send + 'static,\n process_id: Option,\n sink: Sender,\n on_crash: impl Fn(&LanguageId) + Clone + Send + 'static,\n ) -> Result {\n let (reader_tx, reader_rx): (Sender<(Id, Sender)>, _) = unbounded();\n\n let language_id_clone = language_id.clone();\n let reader_thread_name = format!(\"reader-{:?}\", language_id);\n let on_crash_clone = on_crash.clone();\n thread::Builder::new()\n .name(reader_thread_name.clone())\n .spawn(move || {\n if let Err(err) = loop_read(reader, reader_rx, &sink, &language_id_clone) {\n match err.downcast_ref::() {\n Some(err) if err.kind() == std::io::ErrorKind::UnexpectedEof => {\n on_crash_clone(&language_id_clone)\n }\n _ => {}\n }\n\n error!(\"Thread {} exited with error: {:?}\", reader_thread_name, err);\n }\n })?;\n\n let (writer_tx, writer_rx) = unbounded();\n let writer_thread_name = format!(\"writer-{:?}\", language_id);\n let language_id_clone = language_id.clone();\n thread::Builder::new()\n .name(writer_thread_name.clone())\n .spawn(move || {\n if let Err(err) = loop_write(writer, &writer_rx, &language_id_clone) {\n match err.downcast_ref::() {\n Some(err) if err.kind() == std::io::ErrorKind::BrokenPipe => {\n on_crash(&language_id_clone)\n }\n _ => {}\n }\n\n error!(\"Thread {} exited with error: {:?}\", writer_thread_name, err);\n }\n })?;\n\n Ok(Self {\n language_id,\n id: AtomicU64::default(),\n process_id,\n reader_tx,\n writer_tx,\n })\n }\n\n pub fn call(\n &self,\n method: impl AsRef,\n params: impl Serialize,\n ) -> Result {\n let method = method.as_ref();\n let id = self.id.fetch_add(1, Ordering::SeqCst);\n let msg = jsonrpc_core::MethodCall {\n jsonrpc: Some(jsonrpc_core::Version::V2),\n id: jsonrpc_core::Id::Num(id),\n method: method.to_owned(),\n params: params.to_params()?,\n };\n let (tx, rx) = bounded(1);\n self.reader_tx.send((id, tx))?;\n self.writer_tx.send(RawMessage::MethodCall(msg))?;\n // TODO: duration from config.\n match rx.recv_timeout(Duration::from_secs(60))? {\n jsonrpc_core::Output::Success(ok) => Ok(serde_json::from_value(ok.result)?),\n // NOTE: Errors with code -32801 correspond to the protocol's ContentModified error,\n // which we don't want to show to the user and should ignore, as the result of the\n // request that triggered this error has been invalidated by changes to the state\n // of the server, so we must handle this error specifically.\n jsonrpc_core::Output::Failure(err)\n if err.error.code.code() == CONTENT_MODIFIED_ERROR_CODE =>\n {\n Err(anyhow::Error::from(LSError::ContentModified))\n }\n jsonrpc_core::Output::Failure(err) => Err(anyhow!(\"Error: {:?}\", err)),\n }\n }\n\n pub fn notify(&self, method: impl AsRef, params: impl Serialize) -> Result<()> {\n let method = method.as_ref();\n\n let msg = jsonrpc_core::Notification {\n jsonrpc: Some(jsonrpc_core::Version::V2),\n method: method.to_owned(),\n params: params.to_params()?,\n };\n self.writer_tx.send(RawMessage::Notification(msg))?;\n Ok(())\n }\n\n pub fn output(&self, id: Id, result: Result) -> Result<()> {\n let output = match result {\n Ok(ok) => jsonrpc_core::Output::Success(jsonrpc_core::Success {\n jsonrpc: Some(jsonrpc_core::Version::V2),\n id: jsonrpc_core::Id::Num(id),\n result: serde_json::to_value(ok)?,\n }),\n Err(err) => jsonrpc_core::Output::Failure(jsonrpc_core::Failure {\n jsonrpc: Some(jsonrpc_core::Version::V2),\n id: jsonrpc_core::Id::Num(id),\n error: err.to_rpc_error(),\n }),\n };\n\n self.writer_tx.send(RawMessage::Output(output))?;\n Ok(())\n }\n}\n\nfn loop_read(\n reader: impl BufRead,\n reader_rx: Receiver<(Id, Sender)>,\n sink: &Sender,\n language_id: &LanguageId,\n) -> Result<()> {\n let mut pending_outputs = HashMap::new();\n\n // Count how many consequent empty lines.\n let mut count_empty_lines = 0;\n\n let mut reader = reader;\n let mut content_length = 0;\n loop {\n let mut message = String::new();\n let mut line = String::new();\n if language_id.is_some() {\n reader.read_line(&mut line)?;\n let line = line.trim();\n if line.is_empty() {\n count_empty_lines += 1;\n if count_empty_lines > 5 {\n return Err(anyhow!(\"Unable to read from language server\"));\n }\n\n let mut buf = vec![0; content_length];\n reader.read_exact(buf.as_mut_slice())?;\n message = String::from_utf8(buf)?;\n } else {\n count_empty_lines = 0;\n if !line.starts_with(\"Content-Length\") {\n continue;\n }\n\n let tokens: Vec<&str> = line.splitn(2, ':').collect();\n let len = tokens\n .get(1)\n .ok_or_else(|| anyhow!(\"Failed to get length! tokens: {:?}\", tokens))?\n .trim();\n content_length = usize::from_str(len)?;\n }\n } else if reader.read_line(&mut message)? == 0 {\n break;\n }\n\n let message = message.trim();\n if message.is_empty() {\n continue;\n }\n debug!(\"<= {:?} {}\", language_id, message);\n // FIXME: Remove extra `meta` property from javascript-typescript-langserver and\n // `requestMethod` sent by Sorbet.\n let s = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");\n let message = serde_json::from_str(&s);\n if let Err(ref err) = message {\n error!(\n \"Failed to deserialize output: {}\\n\\n Message: {}\\n\\nError: {:?}\",\n err, s, err\n );\n continue;\n }\n // TODO: cleanup.\n let message = message.unwrap();\n match message {\n RawMessage::MethodCall(method_call) => {\n sink.send(Call::MethodCall(language_id.clone(), method_call))?;\n }\n RawMessage::Notification(notification) => {\n sink.send(Call::Notification(language_id.clone(), notification))?;\n }\n RawMessage::Output(output) => {\n while let Ok((id, tx)) = reader_rx.try_recv() {\n pending_outputs.insert(id, tx);\n }\n\n if let Some(tx) = pending_outputs.remove(&output.id().to_int()?) {\n tx.send(output)\n .map_err(|output| anyhow!(\"Failed to send output: {:?}\", output))?;\n }\n }\n };\n }\n\n info!(\"reader-{:?} terminated\", language_id);\n Ok(())\n}\n\nfn loop_write(\n writer: impl Write,\n rx: &Receiver,\n language_id: &LanguageId,\n) -> Result<()> {\n let mut writer = writer;\n\n for msg in rx.iter() {\n let s = serde_json::to_string(&msg)?;\n debug!(\"=> {:?} {}\", language_id, s);\n if language_id.is_none() {\n // Use different convention for two reasons,\n // 1. If using '\\r\\ncontent', nvim will receive output as `\\r` + `content`, while vim\n // receives `content`.\n // 2. Without last line ending, vim output handler won't be triggered.\n write!(writer, \"Content-Length: {}\\n\\n{}\\n\", s.len(), s)?;\n } else {\n write!(writer, \"Content-Length: {}\\r\\n\\r\\n{}\", s.len(), s)?;\n };\n writer.flush()?;\n }\n Ok(())\n}\n\n#[cfg(test)]\nmod test {\n use super::RE_REMOVE_EXTRA_FIELDS;\n use crate::types::RawMessage;\n\n #[test]\n // The library we're using for json-rpc doesn't accept extra fields in the structs used to\n // deserialize the message. Sorbet (and possibly other servers) sends an extra field in it, so\n // the client fails to deserialize that response.\n // Our previous solution was to pin the dependency to jsonrpc-core to version 12, but is\n // suboptimal, so we now try to remove the extra fields we know of from the response.\n //\n // See related issue: https://github.com/autozimu/LanguageClient-neovim/issues/892\n fn it_should_remove_extra_fields() {\n // it removes the requestMethod field from Sorbet\n let message = r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"requestMethod\":\"initialize\",\"result\":0}\"#;\n let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");\n let result: Result = serde_json::from_str(&message);\n assert!(result.is_ok());\n\n let message =\n r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"requestMethod\":\"textDocument/definition\",\"result\":0}\"#;\n let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");\n let result: Result = serde_json::from_str(&message);\n assert!(result.is_ok());\n\n // it removes the meta field from javascript-typescript-langserver\n let message = r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"meta\":{},\"result\":0}\"#;\n let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");\n let result: Result = serde_json::from_str(&message);\n assert!(result.is_ok());\n }\n}\n","uri":"file:///home/dick/LanguageClient-neovim/src/rpcclient.rs","version":0}}} 16:30:46 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"setbufvar","params":["/home/dick/LanguageClient-neovim/src/rpcclient.rs","LanguageClient_projectRoot","/home/dick/LanguageClient-neovim"]} 16:30:46 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:ExecuteAutocmd","params":["LanguageClientTextDocumentDidOpenPost"]} 16:30:46 DEBUG writer-Some("rust") src/rpcclient.rs:254 => Some("rust") {"jsonrpc":"2.0","method":"textDocument/codeLens","params":{"textDocument":{"uri":"file:///home/dick/LanguageClient-neovim/src/rpcclient.rs"}},"id":1} 16:30:46 DEBUG reader-Some("rust") src/rpcclient.rs:207 <= Some("rust") {"jsonrpc":"2.0","id":1,"error":{"code":-32801,"message":"waiting for cargo metadata or cargo check"}} 16:30:47 DEBUG reader-Some("rust") src/rpcclient.rs:207 <= Some("rust") {"jsonrpc":"2.0","id":1,"method":"client/registerCapability","params":{"registrations":[{"id":"workspace/didChangeWatchedFiles","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"/home/dick/LanguageClient-neovim/**/*.rs"},{"globPattern":"/home/dick/LanguageClient-neovim/**/Cargo.toml"},{"globPattern":"/home/dick/LanguageClient-neovim/**/Cargo.lock"}]}}]}} 16:30:47 INFO unnamed src/language_server_protocol.rs:2489 client_register_capability; language_id="rust" params=Object({"registrations": Array([Object({"id": String("workspace/didChangeWatchedFiles"), "method": String("workspace/didChangeWatchedFiles"), "registerOptions": Object({"watchers": Array([Object({"globPattern": String("/home/dick/LanguageClient-neovim/**/*.rs")}), Object({"globPattern": String("/home/dick/LanguageClient-neovim/**/Cargo.toml")}), Object({"globPattern": String("/home/dick/LanguageClient-neovim/**/Cargo.lock")})])})})])}) 16:30:47 INFO unnamed src/language_server_protocol.rs:2512 Watching glob pattern: /home/dick/LanguageClient-neovim/**/*.rs 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/config/mod.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/config/server_command.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/extensions/clangd.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/extensions/gopls.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/extensions/java.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/extensions/mod.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/extensions/rust_analyzer.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/language_client.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/language_server_protocol.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/logger.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/main.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/rpcclient.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/rpchandler.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/sign.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/types.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/utils.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/viewport.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/vim.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/vimext.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/watcher.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/target/debug/build/anyhow-be1327a37b4de4c6/out/probe.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/target/debug/build/anyhow-fa158a1d365cbdd8/out/probe.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/target/release/build/anyhow-4457d73fa8da0d46/out/probe.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/target/release/build/anyhow-7418c11d7db55b23/out/probe.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/target/rls/debug/build/anyhow-be1327a37b4de4c6/out/probe.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/tests/data/sample-rs/src/libs.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/tests/data/sample-rs/src/main.rs" 16:30:47 INFO unnamed src/language_server_protocol.rs:2512 Watching glob pattern: /home/dick/LanguageClient-neovim/**/Cargo.toml 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/Cargo.toml" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/tests/data/sample-rs/Cargo.toml" 16:30:47 INFO unnamed src/language_server_protocol.rs:2512 Watching glob pattern: /home/dick/LanguageClient-neovim/**/Cargo.lock 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/Cargo.lock" 16:30:47 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/tests/data/sample-rs/Cargo.lock" 16:30:47 DEBUG unnamed src/language_client.rs:108 state.registrations: [] ==> [{"id":"workspace/didChangeWatchedFiles","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"/home/dick/LanguageClient-neovim/**/*.rs"},{"globPattern":"/home/dick/LanguageClient-neovim/**/Cargo.toml"},{"globPattern":"/home/dick/LanguageClient-neovim/**/Cargo.lock"}]}}] 16:30:47 DEBUG writer-Some("rust") src/rpcclient.rs:254 => Some("rust") {"jsonrpc":"2.0","result":null,"id":1} 16:30:48 DEBUG reader-Some("rust") src/rpcclient.rs:207 <= Some("rust") {"jsonrpc":"2.0","id":2,"method":"client/registerCapability","params":{"registrations":[{"id":"workspace/didChangeWatchedFiles","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"/home/dick/LanguageClient-neovim/**/*.rs"},{"globPattern":"/home/dick/LanguageClient-neovim/**/Cargo.toml"},{"globPattern":"/home/dick/LanguageClient-neovim/**/Cargo.lock"}]}}]}} 16:30:48 INFO unnamed src/language_server_protocol.rs:2489 client_register_capability; language_id="rust" params=Object({"registrations": Array([Object({"id": String("workspace/didChangeWatchedFiles"), "method": String("workspace/didChangeWatchedFiles"), "registerOptions": Object({"watchers": Array([Object({"globPattern": String("/home/dick/LanguageClient-neovim/**/*.rs")}), Object({"globPattern": String("/home/dick/LanguageClient-neovim/**/Cargo.toml")}), Object({"globPattern": String("/home/dick/LanguageClient-neovim/**/Cargo.lock")})])})})])}) 16:30:48 INFO unnamed src/language_server_protocol.rs:2512 Watching glob pattern: /home/dick/LanguageClient-neovim/**/*.rs 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/config/mod.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/config/server_command.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/extensions/clangd.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/extensions/gopls.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/extensions/java.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/extensions/mod.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/extensions/rust_analyzer.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/language_client.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/language_server_protocol.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/logger.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/main.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/rpcclient.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/rpchandler.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/sign.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/types.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/utils.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/viewport.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/vim.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/vimext.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/src/watcher.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/target/debug/build/anyhow-be1327a37b4de4c6/out/probe.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/target/debug/build/anyhow-fa158a1d365cbdd8/out/probe.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/target/release/build/anyhow-4457d73fa8da0d46/out/probe.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/target/release/build/anyhow-7418c11d7db55b23/out/probe.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/target/rls/debug/build/anyhow-be1327a37b4de4c6/out/probe.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/tests/data/sample-rs/src/libs.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/tests/data/sample-rs/src/main.rs" 16:30:48 INFO unnamed src/language_server_protocol.rs:2512 Watching glob pattern: /home/dick/LanguageClient-neovim/**/Cargo.toml 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/Cargo.toml" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/tests/data/sample-rs/Cargo.toml" 16:30:48 INFO unnamed src/language_server_protocol.rs:2512 Watching glob pattern: /home/dick/LanguageClient-neovim/**/Cargo.lock 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/Cargo.lock" 16:30:48 INFO unnamed src/language_server_protocol.rs:2524 Start watching path "/home/dick/LanguageClient-neovim/tests/data/sample-rs/Cargo.lock" 16:30:48 DEBUG unnamed src/language_client.rs:108 state.registrations: [{"id":"workspace/didChangeWatchedFiles","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"/home/dick/LanguageClient-neovim/**/*.rs"},{"globPattern":"/home/dick/LanguageClient-neovim/**/Cargo.toml"},{"globPattern":"/home/dick/LanguageClient-neovim/**/Cargo.lock"}]}}] ==> [{"id":"workspace/didChangeWatchedFiles","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"/home/dick/LanguageClient-neovim/**/*.rs"},{"globPattern":"/home/dick/LanguageClient-neovim/**/Cargo.toml"},{"globPattern":"/home/dick/LanguageClient-neovim/**/Cargo.lock"}]}},{"id":"workspace/didChangeWatchedFiles","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"/home/dick/LanguageClient-neovim/**/*.rs"},{"globPattern":"/home/dick/LanguageClient-neovim/**/Cargo.toml"},{"globPattern":"/home/dick/LanguageClient-neovim/**/Cargo.lock"}]}}] 16:30:48 DEBUG writer-Some("rust") src/rpcclient.rs:254 => Some("rust") {"jsonrpc":"2.0","result":null,"id":2} 16:31:04 DEBUG reader-Some("rust") src/rpcclient.rs:207 <= Some("rust") {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/dick/LanguageClient-neovim/src/rpcclient.rs","diagnostics":[],"version":0}} 16:31:04 INFO unnamed src/language_server_protocol.rs:2095 text_document_publish_diagnostics; params=Object({"diagnostics": Array([]), "uri": String("file:///home/dick/LanguageClient-neovim/src/rpcclient.rs"), "version": Number(0)}) 16:31:04 DEBUG unnamed src/language_client.rs:108 state.diagnostics./home/dick/LanguageClient-neovim/src/rpcclient.rs: null ==> [] 16:31:04 INFO unnamed src/vim.rs:225 Begin setqflist 16:31:04 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"setqflist","params":[[],"r"]} 16:31:04 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"setqflist","params":[[],"a",{"title":"[LC]: diagnostics"}]} 16:31:04 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"eval","params":["bufnr('/home/dick/LanguageClient-neovim/src/rpcclient.rs')"],"id":9} 16:31:04 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 9, "jsonrpc": "2.0", "result": 1} 16:31:04 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"setbufvar","params":["/home/dick/LanguageClient-neovim/src/rpcclient.rs","LanguageClient_statusLineDiagnosticsCounts",{"E":0,"H":0,"I":0,"W":0}]} 16:31:04 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"eval","params":["LSP#filename()"],"id":10} 16:31:04 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 10, "jsonrpc": "2.0", "result": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"} 16:31:04 DEBUG unnamed src/language_client.rs:108 state.highlights./home/dick/LanguageClient-neovim/src/rpcclient.rs: null ==> [] 16:31:04 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Null force_redraw=true 16:31:04 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"eval","params":["LSP#filename()"],"id":11} 16:31:04 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 11, "jsonrpc": "2.0", "result": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"} 16:31:04 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"getbufvar","params":["/home/dick/LanguageClient-neovim/src/rpcclient.rs","&filetype"],"id":12} 16:31:04 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 12, "jsonrpc": "2.0", "result": "rust"} 16:31:04 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"eval","params":["LSP#position()"],"id":13} 16:31:04 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 13, "jsonrpc": "2.0", "result": {"character": 0, "line": 0}} 16:31:04 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"eval","params":["LSP#viewport()"],"id":14} 16:31:04 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 14, "jsonrpc": "2.0", "result": {"end": 20, "start": 0}} 16:31:04 INFO unnamed src/language_server_protocol.rs:2847 get_signs_to_display; filename="/home/dick/LanguageClient-neovim/src/rpcclient.rs" viewport=Viewport { start: 0, end: 20 } 16:31:04 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/LanguageClient-neovim/src/rpcclient.rs: null ==> {"end":20,"start":0} 16:31:04 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_signs","params":["/home/dick/LanguageClient-neovim/src/rpcclient.rs",[]],"id":15} 16:31:04 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 15, "jsonrpc": "2.0", "result": 0} 16:31:04 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:ClearHighlights","params":["__LCN_DIAGNOSTIC_HIGHLIGHT__"]} 16:31:04 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"eval","params":["LSP#filename()"],"id":16} 16:31:04 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 16, "jsonrpc": "2.0", "result": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"} 16:31:04 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"eval","params":["LSP#viewport()"],"id":17} 16:31:04 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 17, "jsonrpc": "2.0", "result": {"end": 20, "start": 0}} 16:31:04 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"eval","params":["bufnr('/home/dick/LanguageClient-neovim/src/rpcclient.rs')"],"id":18} 16:31:04 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 18, "jsonrpc": "2.0", "result": 1} 16:31:04 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"nvim_create_namespace","params":["LanguageClient_VirtualText"],"id":19} 16:31:04 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 19, "jsonrpc": "2.0", "result": 3} 16:31:04 DEBUG unnamed src/language_client.rs:108 state.namespace_ids.LanguageClient_VirtualText: null ==> 3 16:31:04 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"mode","params":[],"id":20} 16:31:04 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 20, "jsonrpc": "2.0", "result": "c"} 16:31:04 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_virtual_texts","params":[1,3,0,20,[]],"id":21} 16:31:04 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 21, "jsonrpc": "2.0", "result": 0} 16:31:04 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:ExecuteAutocmd","params":["LanguageClientDiagnosticsChanged"]} 17:00:02 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 20, "start": 0}, "languageId": "rust", "buftype": "", "position": {"character": 0, "line": 1}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 17:00:02 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(0), "line": Number(1)}), "viewport": Object({"end": Number(20), "start": Number(0)})}) force_redraw=false 17:00:02 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:EchoEllipsis","params":[""]} 17:00:02 DEBUG unnamed src/language_client.rs:108 state.last_line_diagnostic: " " ==> "" 17:00:02 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 0 ==> 1 17:00:03 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 24, "line": 49}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 17:00:03 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(24), "line": Number(49)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 17:00:03 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 1 ==> 49 17:00:03 INFO unnamed src/language_server_protocol.rs:2847 get_signs_to_display; filename="/home/dick/LanguageClient-neovim/src/rpcclient.rs" viewport=Viewport { start: 40, end: 59 } 17:00:03 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/LanguageClient-neovim/src/rpcclient.rs.start: 0 ==> 40 17:00:03 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/LanguageClient-neovim/src/rpcclient.rs.end: 20 ==> 59 17:00:03 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_signs","params":["/home/dick/LanguageClient-neovim/src/rpcclient.rs",[]],"id":22} 17:00:03 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 22, "jsonrpc": "2.0", "result": 0} 17:00:03 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:ClearHighlights","params":["__LCN_DIAGNOSTIC_HIGHLIGHT__"]} 17:00:03 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"mode","params":[],"id":23} 17:00:03 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 23, "jsonrpc": "2.0", "result": "n"} 17:00:03 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_virtual_texts","params":[1,3,40,59,[]],"id":24} 17:00:03 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 24, "jsonrpc": "2.0", "result": 0} 17:00:16 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 1, "jsonrpc": "2.0", "method": "textDocument/definition", "params": {"bufnr": 1, "character": 45, "handle": true, "languageId": "rust", "gotoCmd": null, "line": 49, "text": ["use crate::types::{Call, Id, LSError, LanguageId, RawMessage, ToInt, ToParams, ToRpcError};", "use anyhow::{anyhow, Result};", "use crossbeam::channel::{bounded, unbounded, Receiver, Sender};", "use log::*;", "use regex::Regex;", "use serde::{de::DeserializeOwned, Serialize};", "use std::io::Write;", "use std::str::FromStr;", "use std::{", " collections::HashMap,", " io::BufRead,", " sync::atomic::{AtomicU64, Ordering},", " thread,", " time::Duration,", "};", "", "const CONTENT_MODIFIED_ERROR_CODE: i64 = -32801;", "", "lazy_static! {", " // this regex is used to remove some additional fields that we get from some servers, namely:", " // meta, sent by javascript-typescript-langserver and requestMethod, sent by Sorbet.", " static ref RE_REMOVE_EXTRA_FIELDS: Regex =", " Regex::new(r#\",\\s?\"(?:meta|requestMethod)\":(?:\"\\w+(/\\w+)?\"|\\{\\})\"#).unwrap();", "}", "", "#[derive(Serialize)]", "pub struct RpcClient {", " language_id: LanguageId,", " #[serde(skip_serializing)]", " id: AtomicU64,", " #[serde(skip_serializing)]", " writer_tx: Sender,", " #[serde(skip_serializing)]", " reader_tx: Sender<(Id, Sender)>,", " pub process_id: Option,", "}", "", "impl RpcClient {", " #[allow(clippy::new_ret_no_self)]", " pub fn new(", " language_id: LanguageId,", " reader: impl BufRead + Send + 'static,", " writer: impl Write + Send + 'static,", " process_id: Option,", " sink: Sender,", " on_crash: impl Fn(&LanguageId) + Clone + Send + 'static,", " ) -> Result {", " let (reader_tx, reader_rx): (Sender<(Id, Sender)>, _) = unbounded();", "", " let language_id_clone = language_id.clone();", " let reader_thread_name = format!(\"reader-{:?}\", language_id);", " let on_crash_clone = on_crash.clone();", " thread::Builder::new()", " .name(reader_thread_name.clone())", " .spawn(move || {", " if let Err(err) = loop_read(reader, reader_rx, &sink, &language_id_clone) {", " match err.downcast_ref::() {", " Some(err) if err.kind() == std::io::ErrorKind::UnexpectedEof => {", " on_crash_clone(&language_id_clone)", " }", " _ => {}", " }", "", " error!(\"Thread {} exited with error: {:?}\", reader_thread_name, err);", " }", " })?;", "", " let (writer_tx, writer_rx) = unbounded();", " let writer_thread_name = format!(\"writer-{:?}\", language_id);", " let language_id_clone = language_id.clone();", " thread::Builder::new()", " .name(writer_thread_name.clone())", " .spawn(move || {", " if let Err(err) = loop_write(writer, &writer_rx, &language_id_clone) {", " match err.downcast_ref::() {", " Some(err) if err.kind() == std::io::ErrorKind::BrokenPipe => {", " on_crash(&language_id_clone)", " }", " _ => {}", " }", "", " error!(\"Thread {} exited with error: {:?}\", writer_thread_name, err);", " }", " })?;", "", " Ok(Self {", " language_id,", " id: AtomicU64::default(),", " process_id,", " reader_tx,", " writer_tx,", " })", " }", "", " pub fn call(", " &self,", " method: impl AsRef,", " params: impl Serialize,", " ) -> Result {", " let method = method.as_ref();", " let id = self.id.fetch_add(1, Ordering::SeqCst);", " let msg = jsonrpc_core::MethodCall {", " jsonrpc: Some(jsonrpc_core::Version::V2),", " id: jsonrpc_core::Id::Num(id),", " method: method.to_owned(),", " params: params.to_params()?,", " };", " let (tx, rx) = bounded(1);", " self.reader_tx.send((id, tx))?;", " self.writer_tx.send(RawMessage::MethodCall(msg))?;", " // TODO: duration from config.", " match rx.recv_timeout(Duration::from_secs(60))? {", " jsonrpc_core::Output::Success(ok) => Ok(serde_json::from_value(ok.result)?),", " // NOTE: Errors with code -32801 correspond to the protocol's ContentModified error,", " // which we don't want to show to the user and should ignore, as the result of the", " // request that triggered this error has been invalidated by changes to the state", " // of the server, so we must handle this error specifically.", " jsonrpc_core::Output::Failure(err)", " if err.error.code.code() == CONTENT_MODIFIED_ERROR_CODE =>", " {", " Err(anyhow::Error::from(LSError::ContentModified))", " }", " jsonrpc_core::Output::Failure(err) => Err(anyhow!(\"Error: {:?}\", err)),", " }", " }", "", " pub fn notify(&self, method: impl AsRef, params: impl Serialize) -> Result<()> {", " let method = method.as_ref();", "", " let msg = jsonrpc_core::Notification {", " jsonrpc: Some(jsonrpc_core::Version::V2),", " method: method.to_owned(),", " params: params.to_params()?,", " };", " self.writer_tx.send(RawMessage::Notification(msg))?;", " Ok(())", " }", "", " pub fn output(&self, id: Id, result: Result) -> Result<()> {", " let output = match result {", " Ok(ok) => jsonrpc_core::Output::Success(jsonrpc_core::Success {", " jsonrpc: Some(jsonrpc_core::Version::V2),", " id: jsonrpc_core::Id::Num(id),", " result: serde_json::to_value(ok)?,", " }),", " Err(err) => jsonrpc_core::Output::Failure(jsonrpc_core::Failure {", " jsonrpc: Some(jsonrpc_core::Version::V2),", " id: jsonrpc_core::Id::Num(id),", " error: err.to_rpc_error(),", " }),", " };", "", " self.writer_tx.send(RawMessage::Output(output))?;", " Ok(())", " }", "}", "", "fn loop_read(", " reader: impl BufRead,", " reader_rx: Receiver<(Id, Sender)>,", " sink: &Sender,", " language_id: &LanguageId,", ") -> Result<()> {", " let mut pending_outputs = HashMap::new();", "", " // Count how many consequent empty lines.", " let mut count_empty_lines = 0;", "", " let mut reader = reader;", " let mut content_length = 0;", " loop {", " let mut message = String::new();", " let mut line = String::new();", " if language_id.is_some() {", " reader.read_line(&mut line)?;", " let line = line.trim();", " if line.is_empty() {", " count_empty_lines += 1;", " if count_empty_lines > 5 {", " return Err(anyhow!(\"Unable to read from language server\"));", " }", "", " let mut buf = vec![0; content_length];", " reader.read_exact(buf.as_mut_slice())?;", " message = String::from_utf8(buf)?;", " } else {", " count_empty_lines = 0;", " if !line.starts_with(\"Content-Length\") {", " continue;", " }", "", " let tokens: Vec<&str> = line.splitn(2, ':').collect();", " let len = tokens", " .get(1)", " .ok_or_else(|| anyhow!(\"Failed to get length! tokens: {:?}\", tokens))?", " .trim();", " content_length = usize::from_str(len)?;", " }", " } else if reader.read_line(&mut message)? == 0 {", " break;", " }", "", " let message = message.trim();", " if message.is_empty() {", " continue;", " }", " debug!(\"<= {:?} {}\", language_id, message);", " // FIXME: Remove extra `meta` property from javascript-typescript-langserver and", " // `requestMethod` sent by Sorbet.", " let s = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");", " let message = serde_json::from_str(&s);", " if let Err(ref err) = message {", " error!(", " \"Failed to deserialize output: {}\\n\\n Message: {}\\n\\nError: {:?}\",", " err, s, err", " );", " continue;", " }", " // TODO: cleanup.", " let message = message.unwrap();", " match message {", " RawMessage::MethodCall(method_call) => {", " sink.send(Call::MethodCall(language_id.clone(), method_call))?;", " }", " RawMessage::Notification(notification) => {", " sink.send(Call::Notification(language_id.clone(), notification))?;", " }", " RawMessage::Output(output) => {", " while let Ok((id, tx)) = reader_rx.try_recv() {", " pending_outputs.insert(id, tx);", " }", "", " if let Some(tx) = pending_outputs.remove(&output.id().to_int()?) {", " tx.send(output)", " .map_err(|output| anyhow!(\"Failed to send output: {:?}\", output))?;", " }", " }", " };", " }", "", " info!(\"reader-{:?} terminated\", language_id);", " Ok(())", "}", "", "fn loop_write(", " writer: impl Write,", " rx: &Receiver,", " language_id: &LanguageId,", ") -> Result<()> {", " let mut writer = writer;", "", " for msg in rx.iter() {", " let s = serde_json::to_string(&msg)?;", " debug!(\"=> {:?} {}\", language_id, s);", " if language_id.is_none() {", " // Use different convention for two reasons,", " // 1. If using '\\r\\ncontent', nvim will receive output as `\\r` + `content`, while vim", " // receives `content`.", " // 2. Without last line ending, vim output handler won't be triggered.", " write!(writer, \"Content-Length: {}\\n\\n{}\\n\", s.len(), s)?;", " } else {", " write!(writer, \"Content-Length: {}\\r\\n\\r\\n{}\", s.len(), s)?;", " };", " writer.flush()?;", " }", " Ok(())", "}", "", "#[cfg(test)]", "mod test {", " use super::RE_REMOVE_EXTRA_FIELDS;", " use crate::types::RawMessage;", "", " #[test]", " // The library we're using for json-rpc doesn't accept extra fields in the structs used to", " // deserialize the message. Sorbet (and possibly other servers) sends an extra field in it, so", " // the client fails to deserialize that response.", " // Our previous solution was to pin the dependency to jsonrpc-core to version 12, but is", " // suboptimal, so we now try to remove the extra fields we know of from the response.", " //", " // See related issue: https://github.com/autozimu/LanguageClient-neovim/issues/892", " fn it_should_remove_extra_fields() {", " // it removes the requestMethod field from Sorbet", " let message = r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"requestMethod\":\"initialize\",\"result\":0}\"#;", " let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");", " let result: Result = serde_json::from_str(&message);", " assert!(result.is_ok());", "", " let message =", " r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"requestMethod\":\"textDocument/definition\",\"result\":0}\"#;", " let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");", " let result: Result = serde_json::from_str(&message);", " assert!(result.is_ok());", "", " // it removes the meta field from javascript-typescript-langserver", " let message = r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"meta\":{},\"result\":0}\"#;", " let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");", " let result: Result = serde_json::from_str(&message);", " assert!(result.is_ok());", " }", "}", ""], "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 17:00:16 INFO unnamed src/language_server_protocol.rs:1473 text_document_definition; params=Object({"bufnr": Number(1), "character": Number(45), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "gotoCmd": Null, "handle": Bool(true), "languageId": String("rust"), "line": Number(49), "text": Array([String("use crate::types::{Call, Id, LSError, LanguageId, RawMessage, ToInt, ToParams, ToRpcError};"), String("use anyhow::{anyhow, Result};"), String("use crossbeam::channel::{bounded, unbounded, Receiver, Sender};"), String("use log::*;"), String("use regex::Regex;"), String("use serde::{de::DeserializeOwned, Serialize};"), String("use std::io::Write;"), String("use std::str::FromStr;"), String("use std::{"), String(" collections::HashMap,"), String(" io::BufRead,"), String(" sync::atomic::{AtomicU64, Ordering},"), String(" thread,"), String(" time::Duration,"), String("};"), String(""), String("const CONTENT_MODIFIED_ERROR_CODE: i64 = -32801;"), String(""), String("lazy_static! {"), String(" // this regex is used to remove some additional fields that we get from some servers, namely:"), String(" // meta, sent by javascript-typescript-langserver and requestMethod, sent by Sorbet."), String(" static ref RE_REMOVE_EXTRA_FIELDS: Regex ="), String(" Regex::new(r#\",\\s?\"(?:meta|requestMethod)\":(?:\"\\w+(/\\w+)?\"|\\{\\})\"#).unwrap();"), String("}"), String(""), String("#[derive(Serialize)]"), String("pub struct RpcClient {"), String(" language_id: LanguageId,"), String(" #[serde(skip_serializing)]"), String(" id: AtomicU64,"), String(" #[serde(skip_serializing)]"), String(" writer_tx: Sender,"), String(" #[serde(skip_serializing)]"), String(" reader_tx: Sender<(Id, Sender)>,"), String(" pub process_id: Option,"), String("}"), String(""), String("impl RpcClient {"), String(" #[allow(clippy::new_ret_no_self)]"), String(" pub fn new("), String(" language_id: LanguageId,"), String(" reader: impl BufRead + Send + 'static,"), String(" writer: impl Write + Send + 'static,"), String(" process_id: Option,"), String(" sink: Sender,"), String(" on_crash: impl Fn(&LanguageId) + Clone + Send + 'static,"), String(" ) -> Result {"), String(" let (reader_tx, reader_rx): (Sender<(Id, Sender)>, _) = unbounded();"), String(""), String(" let language_id_clone = language_id.clone();"), String(" let reader_thread_name = format!(\"reader-{:?}\", language_id);"), String(" let on_crash_clone = on_crash.clone();"), String(" thread::Builder::new()"), String(" .name(reader_thread_name.clone())"), String(" .spawn(move || {"), String(" if let Err(err) = loop_read(reader, reader_rx, &sink, &language_id_clone) {"), String(" match err.downcast_ref::() {"), String(" Some(err) if err.kind() == std::io::ErrorKind::UnexpectedEof => {"), String(" on_crash_clone(&language_id_clone)"), String(" }"), String(" _ => {}"), String(" }"), String(""), String(" error!(\"Thread {} exited with error: {:?}\", reader_thread_name, err);"), String(" }"), String(" })?;"), String(""), String(" let (writer_tx, writer_rx) = unbounded();"), String(" let writer_thread_name = format!(\"writer-{:?}\", language_id);"), String(" let language_id_clone = language_id.clone();"), String(" thread::Builder::new()"), String(" .name(writer_thread_name.clone())"), String(" .spawn(move || {"), String(" if let Err(err) = loop_write(writer, &writer_rx, &language_id_clone) {"), String(" match err.downcast_ref::() {"), String(" Some(err) if err.kind() == std::io::ErrorKind::BrokenPipe => {"), String(" on_crash(&language_id_clone)"), String(" }"), String(" _ => {}"), String(" }"), String(""), String(" error!(\"Thread {} exited with error: {:?}\", writer_thread_name, err);"), String(" }"), String(" })?;"), String(""), String(" Ok(Self {"), String(" language_id,"), String(" id: AtomicU64::default(),"), String(" process_id,"), String(" reader_tx,"), String(" writer_tx,"), String(" })"), String(" }"), String(""), String(" pub fn call("), String(" &self,"), String(" method: impl AsRef,"), String(" params: impl Serialize,"), String(" ) -> Result {"), String(" let method = method.as_ref();"), String(" let id = self.id.fetch_add(1, Ordering::SeqCst);"), String(" let msg = jsonrpc_core::MethodCall {"), String(" jsonrpc: Some(jsonrpc_core::Version::V2),"), String(" id: jsonrpc_core::Id::Num(id),"), String(" method: method.to_owned(),"), String(" params: params.to_params()?,"), String(" };"), String(" let (tx, rx) = bounded(1);"), String(" self.reader_tx.send((id, tx))?;"), String(" self.writer_tx.send(RawMessage::MethodCall(msg))?;"), String(" // TODO: duration from config."), String(" match rx.recv_timeout(Duration::from_secs(60))? {"), String(" jsonrpc_core::Output::Success(ok) => Ok(serde_json::from_value(ok.result)?),"), String(" // NOTE: Errors with code -32801 correspond to the protocol's ContentModified error,"), String(" // which we don't want to show to the user and should ignore, as the result of the"), String(" // request that triggered this error has been invalidated by changes to the state"), String(" // of the server, so we must handle this error specifically."), String(" jsonrpc_core::Output::Failure(err)"), String(" if err.error.code.code() == CONTENT_MODIFIED_ERROR_CODE =>"), String(" {"), String(" Err(anyhow::Error::from(LSError::ContentModified))"), String(" }"), String(" jsonrpc_core::Output::Failure(err) => Err(anyhow!(\"Error: {:?}\", err)),"), String(" }"), String(" }"), String(""), String(" pub fn notify(&self, method: impl AsRef, params: impl Serialize) -> Result<()> {"), String(" let method = method.as_ref();"), String(""), String(" let msg = jsonrpc_core::Notification {"), String(" jsonrpc: Some(jsonrpc_core::Version::V2),"), String(" method: method.to_owned(),"), String(" params: params.to_params()?,"), String(" };"), String(" self.writer_tx.send(RawMessage::Notification(msg))?;"), String(" Ok(())"), String(" }"), String(""), String(" pub fn output(&self, id: Id, result: Result) -> Result<()> {"), String(" let output = match result {"), String(" Ok(ok) => jsonrpc_core::Output::Success(jsonrpc_core::Success {"), String(" jsonrpc: Some(jsonrpc_core::Version::V2),"), String(" id: jsonrpc_core::Id::Num(id),"), String(" result: serde_json::to_value(ok)?,"), String(" }),"), String(" Err(err) => jsonrpc_core::Output::Failure(jsonrpc_core::Failure {"), String(" jsonrpc: Some(jsonrpc_core::Version::V2),"), String(" id: jsonrpc_core::Id::Num(id),"), String(" error: err.to_rpc_error(),"), String(" }),"), String(" };"), String(""), String(" self.writer_tx.send(RawMessage::Output(output))?;"), String(" Ok(())"), String(" }"), String("}"), String(""), String("fn loop_read("), String(" reader: impl BufRead,"), String(" reader_rx: Receiver<(Id, Sender)>,"), String(" sink: &Sender,"), String(" language_id: &LanguageId,"), String(") -> Result<()> {"), String(" let mut pending_outputs = HashMap::new();"), String(""), String(" // Count how many consequent empty lines."), String(" let mut count_empty_lines = 0;"), String(""), String(" let mut reader = reader;"), String(" let mut content_length = 0;"), String(" loop {"), String(" let mut message = String::new();"), String(" let mut line = String::new();"), String(" if language_id.is_some() {"), String(" reader.read_line(&mut line)?;"), String(" let line = line.trim();"), String(" if line.is_empty() {"), String(" count_empty_lines += 1;"), String(" if count_empty_lines > 5 {"), String(" return Err(anyhow!(\"Unable to read from language server\"));"), String(" }"), String(""), String(" let mut buf = vec![0; content_length];"), String(" reader.read_exact(buf.as_mut_slice())?;"), String(" message = String::from_utf8(buf)?;"), String(" } else {"), String(" count_empty_lines = 0;"), String(" if !line.starts_with(\"Content-Length\") {"), String(" continue;"), String(" }"), String(""), String(" let tokens: Vec<&str> = line.splitn(2, ':').collect();"), String(" let len = tokens"), String(" .get(1)"), String(" .ok_or_else(|| anyhow!(\"Failed to get length! tokens: {:?}\", tokens))?"), String(" .trim();"), String(" content_length = usize::from_str(len)?;"), String(" }"), String(" } else if reader.read_line(&mut message)? == 0 {"), String(" break;"), String(" }"), String(""), String(" let message = message.trim();"), String(" if message.is_empty() {"), String(" continue;"), String(" }"), String(" debug!(\"<= {:?} {}\", language_id, message);"), String(" // FIXME: Remove extra `meta` property from javascript-typescript-langserver and"), String(" // `requestMethod` sent by Sorbet."), String(" let s = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");"), String(" let message = serde_json::from_str(&s);"), String(" if let Err(ref err) = message {"), String(" error!("), String(" \"Failed to deserialize output: {}\\n\\n Message: {}\\n\\nError: {:?}\","), String(" err, s, err"), String(" );"), String(" continue;"), String(" }"), String(" // TODO: cleanup."), String(" let message = message.unwrap();"), String(" match message {"), String(" RawMessage::MethodCall(method_call) => {"), String(" sink.send(Call::MethodCall(language_id.clone(), method_call))?;"), String(" }"), String(" RawMessage::Notification(notification) => {"), String(" sink.send(Call::Notification(language_id.clone(), notification))?;"), String(" }"), String(" RawMessage::Output(output) => {"), String(" while let Ok((id, tx)) = reader_rx.try_recv() {"), String(" pending_outputs.insert(id, tx);"), String(" }"), String(""), String(" if let Some(tx) = pending_outputs.remove(&output.id().to_int()?) {"), String(" tx.send(output)"), String(" .map_err(|output| anyhow!(\"Failed to send output: {:?}\", output))?;"), String(" }"), String(" }"), String(" };"), String(" }"), String(""), String(" info!(\"reader-{:?} terminated\", language_id);"), String(" Ok(())"), String("}"), String(""), String("fn loop_write("), String(" writer: impl Write,"), String(" rx: &Receiver,"), String(" language_id: &LanguageId,"), String(") -> Result<()> {"), String(" let mut writer = writer;"), String(""), String(" for msg in rx.iter() {"), String(" let s = serde_json::to_string(&msg)?;"), String(" debug!(\"=> {:?} {}\", language_id, s);"), String(" if language_id.is_none() {"), String(" // Use different convention for two reasons,"), String(" // 1. If using '\\r\\ncontent', nvim will receive output as `\\r` + `content`, while vim"), String(" // receives `content`."), String(" // 2. Without last line ending, vim output handler won't be triggered."), String(" write!(writer, \"Content-Length: {}\\n\\n{}\\n\", s.len(), s)?;"), String(" } else {"), String(" write!(writer, \"Content-Length: {}\\r\\n\\r\\n{}\", s.len(), s)?;"), String(" };"), String(" writer.flush()?;"), String(" }"), String(" Ok(())"), String("}"), String(""), String("#[cfg(test)]"), String("mod test {"), String(" use super::RE_REMOVE_EXTRA_FIELDS;"), String(" use crate::types::RawMessage;"), String(""), String(" #[test]"), String(" // The library we're using for json-rpc doesn't accept extra fields in the structs used to"), String(" // deserialize the message. Sorbet (and possibly other servers) sends an extra field in it, so"), String(" // the client fails to deserialize that response."), String(" // Our previous solution was to pin the dependency to jsonrpc-core to version 12, but is"), String(" // suboptimal, so we now try to remove the extra fields we know of from the response."), String(" //"), String(" // See related issue: https://github.com/autozimu/LanguageClient-neovim/issues/892"), String(" fn it_should_remove_extra_fields() {"), String(" // it removes the requestMethod field from Sorbet"), String(" let message = r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"requestMethod\":\"initialize\",\"result\":0}\"#;"), String(" let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");"), String(" let result: Result = serde_json::from_str(&message);"), String(" assert!(result.is_ok());"), String(""), String(" let message ="), String(" r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"requestMethod\":\"textDocument/definition\",\"result\":0}\"#;"), String(" let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");"), String(" let result: Result = serde_json::from_str(&message);"), String(" assert!(result.is_ok());"), String(""), String(" // it removes the meta field from javascript-typescript-langserver"), String(" let message = r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"meta\":{},\"result\":0}\"#;"), String(" let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");"), String(" let result: Result = serde_json::from_str(&message);"), String(" assert!(result.is_ok());"), String(" }"), String("}"), String("")])}) 17:00:16 INFO unnamed src/language_server_protocol.rs:1077 find_locations; params=Object({"bufnr": Number(1), "character": Number(45), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "gotoCmd": Null, "handle": Bool(true), "languageId": String("rust"), "line": Number(49), "method": String("textDocument/definition"), "text": Array([String("use crate::types::{Call, Id, LSError, LanguageId, RawMessage, ToInt, ToParams, ToRpcError};"), String("use anyhow::{anyhow, Result};"), String("use crossbeam::channel::{bounded, unbounded, Receiver, Sender};"), String("use log::*;"), String("use regex::Regex;"), String("use serde::{de::DeserializeOwned, Serialize};"), String("use std::io::Write;"), String("use std::str::FromStr;"), String("use std::{"), String(" collections::HashMap,"), String(" io::BufRead,"), String(" sync::atomic::{AtomicU64, Ordering},"), String(" thread,"), String(" time::Duration,"), String("};"), String(""), String("const CONTENT_MODIFIED_ERROR_CODE: i64 = -32801;"), String(""), String("lazy_static! {"), String(" // this regex is used to remove some additional fields that we get from some servers, namely:"), String(" // meta, sent by javascript-typescript-langserver and requestMethod, sent by Sorbet."), String(" static ref RE_REMOVE_EXTRA_FIELDS: Regex ="), String(" Regex::new(r#\",\\s?\"(?:meta|requestMethod)\":(?:\"\\w+(/\\w+)?\"|\\{\\})\"#).unwrap();"), String("}"), String(""), String("#[derive(Serialize)]"), String("pub struct RpcClient {"), String(" language_id: LanguageId,"), String(" #[serde(skip_serializing)]"), String(" id: AtomicU64,"), String(" #[serde(skip_serializing)]"), String(" writer_tx: Sender,"), String(" #[serde(skip_serializing)]"), String(" reader_tx: Sender<(Id, Sender)>,"), String(" pub process_id: Option,"), String("}"), String(""), String("impl RpcClient {"), String(" #[allow(clippy::new_ret_no_self)]"), String(" pub fn new("), String(" language_id: LanguageId,"), String(" reader: impl BufRead + Send + 'static,"), String(" writer: impl Write + Send + 'static,"), String(" process_id: Option,"), String(" sink: Sender,"), String(" on_crash: impl Fn(&LanguageId) + Clone + Send + 'static,"), String(" ) -> Result {"), String(" let (reader_tx, reader_rx): (Sender<(Id, Sender)>, _) = unbounded();"), String(""), String(" let language_id_clone = language_id.clone();"), String(" let reader_thread_name = format!(\"reader-{:?}\", language_id);"), String(" let on_crash_clone = on_crash.clone();"), String(" thread::Builder::new()"), String(" .name(reader_thread_name.clone())"), String(" .spawn(move || {"), String(" if let Err(err) = loop_read(reader, reader_rx, &sink, &language_id_clone) {"), String(" match err.downcast_ref::() {"), String(" Some(err) if err.kind() == std::io::ErrorKind::UnexpectedEof => {"), String(" on_crash_clone(&language_id_clone)"), String(" }"), String(" _ => {}"), String(" }"), String(""), String(" error!(\"Thread {} exited with error: {:?}\", reader_thread_name, err);"), String(" }"), String(" })?;"), String(""), String(" let (writer_tx, writer_rx) = unbounded();"), String(" let writer_thread_name = format!(\"writer-{:?}\", language_id);"), String(" let language_id_clone = language_id.clone();"), String(" thread::Builder::new()"), String(" .name(writer_thread_name.clone())"), String(" .spawn(move || {"), String(" if let Err(err) = loop_write(writer, &writer_rx, &language_id_clone) {"), String(" match err.downcast_ref::() {"), String(" Some(err) if err.kind() == std::io::ErrorKind::BrokenPipe => {"), String(" on_crash(&language_id_clone)"), String(" }"), String(" _ => {}"), String(" }"), String(""), String(" error!(\"Thread {} exited with error: {:?}\", writer_thread_name, err);"), String(" }"), String(" })?;"), String(""), String(" Ok(Self {"), String(" language_id,"), String(" id: AtomicU64::default(),"), String(" process_id,"), String(" reader_tx,"), String(" writer_tx,"), String(" })"), String(" }"), String(""), String(" pub fn call("), String(" &self,"), String(" method: impl AsRef,"), String(" params: impl Serialize,"), String(" ) -> Result {"), String(" let method = method.as_ref();"), String(" let id = self.id.fetch_add(1, Ordering::SeqCst);"), String(" let msg = jsonrpc_core::MethodCall {"), String(" jsonrpc: Some(jsonrpc_core::Version::V2),"), String(" id: jsonrpc_core::Id::Num(id),"), String(" method: method.to_owned(),"), String(" params: params.to_params()?,"), String(" };"), String(" let (tx, rx) = bounded(1);"), String(" self.reader_tx.send((id, tx))?;"), String(" self.writer_tx.send(RawMessage::MethodCall(msg))?;"), String(" // TODO: duration from config."), String(" match rx.recv_timeout(Duration::from_secs(60))? {"), String(" jsonrpc_core::Output::Success(ok) => Ok(serde_json::from_value(ok.result)?),"), String(" // NOTE: Errors with code -32801 correspond to the protocol's ContentModified error,"), String(" // which we don't want to show to the user and should ignore, as the result of the"), String(" // request that triggered this error has been invalidated by changes to the state"), String(" // of the server, so we must handle this error specifically."), String(" jsonrpc_core::Output::Failure(err)"), String(" if err.error.code.code() == CONTENT_MODIFIED_ERROR_CODE =>"), String(" {"), String(" Err(anyhow::Error::from(LSError::ContentModified))"), String(" }"), String(" jsonrpc_core::Output::Failure(err) => Err(anyhow!(\"Error: {:?}\", err)),"), String(" }"), String(" }"), String(""), String(" pub fn notify(&self, method: impl AsRef, params: impl Serialize) -> Result<()> {"), String(" let method = method.as_ref();"), String(""), String(" let msg = jsonrpc_core::Notification {"), String(" jsonrpc: Some(jsonrpc_core::Version::V2),"), String(" method: method.to_owned(),"), String(" params: params.to_params()?,"), String(" };"), String(" self.writer_tx.send(RawMessage::Notification(msg))?;"), String(" Ok(())"), String(" }"), String(""), String(" pub fn output(&self, id: Id, result: Result) -> Result<()> {"), String(" let output = match result {"), String(" Ok(ok) => jsonrpc_core::Output::Success(jsonrpc_core::Success {"), String(" jsonrpc: Some(jsonrpc_core::Version::V2),"), String(" id: jsonrpc_core::Id::Num(id),"), String(" result: serde_json::to_value(ok)?,"), String(" }),"), String(" Err(err) => jsonrpc_core::Output::Failure(jsonrpc_core::Failure {"), String(" jsonrpc: Some(jsonrpc_core::Version::V2),"), String(" id: jsonrpc_core::Id::Num(id),"), String(" error: err.to_rpc_error(),"), String(" }),"), String(" };"), String(""), String(" self.writer_tx.send(RawMessage::Output(output))?;"), String(" Ok(())"), String(" }"), String("}"), String(""), String("fn loop_read("), String(" reader: impl BufRead,"), String(" reader_rx: Receiver<(Id, Sender)>,"), String(" sink: &Sender,"), String(" language_id: &LanguageId,"), String(") -> Result<()> {"), String(" let mut pending_outputs = HashMap::new();"), String(""), String(" // Count how many consequent empty lines."), String(" let mut count_empty_lines = 0;"), String(""), String(" let mut reader = reader;"), String(" let mut content_length = 0;"), String(" loop {"), String(" let mut message = String::new();"), String(" let mut line = String::new();"), String(" if language_id.is_some() {"), String(" reader.read_line(&mut line)?;"), String(" let line = line.trim();"), String(" if line.is_empty() {"), String(" count_empty_lines += 1;"), String(" if count_empty_lines > 5 {"), String(" return Err(anyhow!(\"Unable to read from language server\"));"), String(" }"), String(""), String(" let mut buf = vec![0; content_length];"), String(" reader.read_exact(buf.as_mut_slice())?;"), String(" message = String::from_utf8(buf)?;"), String(" } else {"), String(" count_empty_lines = 0;"), String(" if !line.starts_with(\"Content-Length\") {"), String(" continue;"), String(" }"), String(""), String(" let tokens: Vec<&str> = line.splitn(2, ':').collect();"), String(" let len = tokens"), String(" .get(1)"), String(" .ok_or_else(|| anyhow!(\"Failed to get length! tokens: {:?}\", tokens))?"), String(" .trim();"), String(" content_length = usize::from_str(len)?;"), String(" }"), String(" } else if reader.read_line(&mut message)? == 0 {"), String(" break;"), String(" }"), String(""), String(" let message = message.trim();"), String(" if message.is_empty() {"), String(" continue;"), String(" }"), String(" debug!(\"<= {:?} {}\", language_id, message);"), String(" // FIXME: Remove extra `meta` property from javascript-typescript-langserver and"), String(" // `requestMethod` sent by Sorbet."), String(" let s = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");"), String(" let message = serde_json::from_str(&s);"), String(" if let Err(ref err) = message {"), String(" error!("), String(" \"Failed to deserialize output: {}\\n\\n Message: {}\\n\\nError: {:?}\","), String(" err, s, err"), String(" );"), String(" continue;"), String(" }"), String(" // TODO: cleanup."), String(" let message = message.unwrap();"), String(" match message {"), String(" RawMessage::MethodCall(method_call) => {"), String(" sink.send(Call::MethodCall(language_id.clone(), method_call))?;"), String(" }"), String(" RawMessage::Notification(notification) => {"), String(" sink.send(Call::Notification(language_id.clone(), notification))?;"), String(" }"), String(" RawMessage::Output(output) => {"), String(" while let Ok((id, tx)) = reader_rx.try_recv() {"), String(" pending_outputs.insert(id, tx);"), String(" }"), String(""), String(" if let Some(tx) = pending_outputs.remove(&output.id().to_int()?) {"), String(" tx.send(output)"), String(" .map_err(|output| anyhow!(\"Failed to send output: {:?}\", output))?;"), String(" }"), String(" }"), String(" };"), String(" }"), String(""), String(" info!(\"reader-{:?} terminated\", language_id);"), String(" Ok(())"), String("}"), String(""), String("fn loop_write("), String(" writer: impl Write,"), String(" rx: &Receiver,"), String(" language_id: &LanguageId,"), String(") -> Result<()> {"), String(" let mut writer = writer;"), String(""), String(" for msg in rx.iter() {"), String(" let s = serde_json::to_string(&msg)?;"), String(" debug!(\"=> {:?} {}\", language_id, s);"), String(" if language_id.is_none() {"), String(" // Use different convention for two reasons,"), String(" // 1. If using '\\r\\ncontent', nvim will receive output as `\\r` + `content`, while vim"), String(" // receives `content`."), String(" // 2. Without last line ending, vim output handler won't be triggered."), String(" write!(writer, \"Content-Length: {}\\n\\n{}\\n\", s.len(), s)?;"), String(" } else {"), String(" write!(writer, \"Content-Length: {}\\r\\n\\r\\n{}\", s.len(), s)?;"), String(" };"), String(" writer.flush()?;"), String(" }"), String(" Ok(())"), String("}"), String(""), String("#[cfg(test)]"), String("mod test {"), String(" use super::RE_REMOVE_EXTRA_FIELDS;"), String(" use crate::types::RawMessage;"), String(""), String(" #[test]"), String(" // The library we're using for json-rpc doesn't accept extra fields in the structs used to"), String(" // deserialize the message. Sorbet (and possibly other servers) sends an extra field in it, so"), String(" // the client fails to deserialize that response."), String(" // Our previous solution was to pin the dependency to jsonrpc-core to version 12, but is"), String(" // suboptimal, so we now try to remove the extra fields we know of from the response."), String(" //"), String(" // See related issue: https://github.com/autozimu/LanguageClient-neovim/issues/892"), String(" fn it_should_remove_extra_fields() {"), String(" // it removes the requestMethod field from Sorbet"), String(" let message = r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"requestMethod\":\"initialize\",\"result\":0}\"#;"), String(" let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");"), String(" let result: Result = serde_json::from_str(&message);"), String(" assert!(result.is_ok());"), String(""), String(" let message ="), String(" r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"requestMethod\":\"textDocument/definition\",\"result\":0}\"#;"), String(" let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");"), String(" let result: Result = serde_json::from_str(&message);"), String(" assert!(result.is_ok());"), String(""), String(" // it removes the meta field from javascript-typescript-langserver"), String(" let message = r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"meta\":{},\"result\":0}\"#;"), String(" let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");"), String(" let result: Result = serde_json::from_str(&message);"), String(" assert!(result.is_ok());"), String(" }"), String("}"), String("")])}) 17:00:16 INFO unnamed src/language_server_protocol.rs:1993 text_document_did_change; params=Object({"bufnr": Number(1), "character": Number(45), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "gotoCmd": Null, "handle": Bool(true), "languageId": String("rust"), "line": Number(49), "method": String("textDocument/definition"), "text": Array([String("use crate::types::{Call, Id, LSError, LanguageId, RawMessage, ToInt, ToParams, ToRpcError};"), String("use anyhow::{anyhow, Result};"), String("use crossbeam::channel::{bounded, unbounded, Receiver, Sender};"), String("use log::*;"), String("use regex::Regex;"), String("use serde::{de::DeserializeOwned, Serialize};"), String("use std::io::Write;"), String("use std::str::FromStr;"), String("use std::{"), String(" collections::HashMap,"), String(" io::BufRead,"), String(" sync::atomic::{AtomicU64, Ordering},"), String(" thread,"), String(" time::Duration,"), String("};"), String(""), String("const CONTENT_MODIFIED_ERROR_CODE: i64 = -32801;"), String(""), String("lazy_static! {"), String(" // this regex is used to remove some additional fields that we get from some servers, namely:"), String(" // meta, sent by javascript-typescript-langserver and requestMethod, sent by Sorbet."), String(" static ref RE_REMOVE_EXTRA_FIELDS: Regex ="), String(" Regex::new(r#\",\\s?\"(?:meta|requestMethod)\":(?:\"\\w+(/\\w+)?\"|\\{\\})\"#).unwrap();"), String("}"), String(""), String("#[derive(Serialize)]"), String("pub struct RpcClient {"), String(" language_id: LanguageId,"), String(" #[serde(skip_serializing)]"), String(" id: AtomicU64,"), String(" #[serde(skip_serializing)]"), String(" writer_tx: Sender,"), String(" #[serde(skip_serializing)]"), String(" reader_tx: Sender<(Id, Sender)>,"), String(" pub process_id: Option,"), String("}"), String(""), String("impl RpcClient {"), String(" #[allow(clippy::new_ret_no_self)]"), String(" pub fn new("), String(" language_id: LanguageId,"), String(" reader: impl BufRead + Send + 'static,"), String(" writer: impl Write + Send + 'static,"), String(" process_id: Option,"), String(" sink: Sender,"), String(" on_crash: impl Fn(&LanguageId) + Clone + Send + 'static,"), String(" ) -> Result {"), String(" let (reader_tx, reader_rx): (Sender<(Id, Sender)>, _) = unbounded();"), String(""), String(" let language_id_clone = language_id.clone();"), String(" let reader_thread_name = format!(\"reader-{:?}\", language_id);"), String(" let on_crash_clone = on_crash.clone();"), String(" thread::Builder::new()"), String(" .name(reader_thread_name.clone())"), String(" .spawn(move || {"), String(" if let Err(err) = loop_read(reader, reader_rx, &sink, &language_id_clone) {"), String(" match err.downcast_ref::() {"), String(" Some(err) if err.kind() == std::io::ErrorKind::UnexpectedEof => {"), String(" on_crash_clone(&language_id_clone)"), String(" }"), String(" _ => {}"), String(" }"), String(""), String(" error!(\"Thread {} exited with error: {:?}\", reader_thread_name, err);"), String(" }"), String(" })?;"), String(""), String(" let (writer_tx, writer_rx) = unbounded();"), String(" let writer_thread_name = format!(\"writer-{:?}\", language_id);"), String(" let language_id_clone = language_id.clone();"), String(" thread::Builder::new()"), String(" .name(writer_thread_name.clone())"), String(" .spawn(move || {"), String(" if let Err(err) = loop_write(writer, &writer_rx, &language_id_clone) {"), String(" match err.downcast_ref::() {"), String(" Some(err) if err.kind() == std::io::ErrorKind::BrokenPipe => {"), String(" on_crash(&language_id_clone)"), String(" }"), String(" _ => {}"), String(" }"), String(""), String(" error!(\"Thread {} exited with error: {:?}\", writer_thread_name, err);"), String(" }"), String(" })?;"), String(""), String(" Ok(Self {"), String(" language_id,"), String(" id: AtomicU64::default(),"), String(" process_id,"), String(" reader_tx,"), String(" writer_tx,"), String(" })"), String(" }"), String(""), String(" pub fn call("), String(" &self,"), String(" method: impl AsRef,"), String(" params: impl Serialize,"), String(" ) -> Result {"), String(" let method = method.as_ref();"), String(" let id = self.id.fetch_add(1, Ordering::SeqCst);"), String(" let msg = jsonrpc_core::MethodCall {"), String(" jsonrpc: Some(jsonrpc_core::Version::V2),"), String(" id: jsonrpc_core::Id::Num(id),"), String(" method: method.to_owned(),"), String(" params: params.to_params()?,"), String(" };"), String(" let (tx, rx) = bounded(1);"), String(" self.reader_tx.send((id, tx))?;"), String(" self.writer_tx.send(RawMessage::MethodCall(msg))?;"), String(" // TODO: duration from config."), String(" match rx.recv_timeout(Duration::from_secs(60))? {"), String(" jsonrpc_core::Output::Success(ok) => Ok(serde_json::from_value(ok.result)?),"), String(" // NOTE: Errors with code -32801 correspond to the protocol's ContentModified error,"), String(" // which we don't want to show to the user and should ignore, as the result of the"), String(" // request that triggered this error has been invalidated by changes to the state"), String(" // of the server, so we must handle this error specifically."), String(" jsonrpc_core::Output::Failure(err)"), String(" if err.error.code.code() == CONTENT_MODIFIED_ERROR_CODE =>"), String(" {"), String(" Err(anyhow::Error::from(LSError::ContentModified))"), String(" }"), String(" jsonrpc_core::Output::Failure(err) => Err(anyhow!(\"Error: {:?}\", err)),"), String(" }"), String(" }"), String(""), String(" pub fn notify(&self, method: impl AsRef, params: impl Serialize) -> Result<()> {"), String(" let method = method.as_ref();"), String(""), String(" let msg = jsonrpc_core::Notification {"), String(" jsonrpc: Some(jsonrpc_core::Version::V2),"), String(" method: method.to_owned(),"), String(" params: params.to_params()?,"), String(" };"), String(" self.writer_tx.send(RawMessage::Notification(msg))?;"), String(" Ok(())"), String(" }"), String(""), String(" pub fn output(&self, id: Id, result: Result) -> Result<()> {"), String(" let output = match result {"), String(" Ok(ok) => jsonrpc_core::Output::Success(jsonrpc_core::Success {"), String(" jsonrpc: Some(jsonrpc_core::Version::V2),"), String(" id: jsonrpc_core::Id::Num(id),"), String(" result: serde_json::to_value(ok)?,"), String(" }),"), String(" Err(err) => jsonrpc_core::Output::Failure(jsonrpc_core::Failure {"), String(" jsonrpc: Some(jsonrpc_core::Version::V2),"), String(" id: jsonrpc_core::Id::Num(id),"), String(" error: err.to_rpc_error(),"), String(" }),"), String(" };"), String(""), String(" self.writer_tx.send(RawMessage::Output(output))?;"), String(" Ok(())"), String(" }"), String("}"), String(""), String("fn loop_read("), String(" reader: impl BufRead,"), String(" reader_rx: Receiver<(Id, Sender)>,"), String(" sink: &Sender,"), String(" language_id: &LanguageId,"), String(") -> Result<()> {"), String(" let mut pending_outputs = HashMap::new();"), String(""), String(" // Count how many consequent empty lines."), String(" let mut count_empty_lines = 0;"), String(""), String(" let mut reader = reader;"), String(" let mut content_length = 0;"), String(" loop {"), String(" let mut message = String::new();"), String(" let mut line = String::new();"), String(" if language_id.is_some() {"), String(" reader.read_line(&mut line)?;"), String(" let line = line.trim();"), String(" if line.is_empty() {"), String(" count_empty_lines += 1;"), String(" if count_empty_lines > 5 {"), String(" return Err(anyhow!(\"Unable to read from language server\"));"), String(" }"), String(""), String(" let mut buf = vec![0; content_length];"), String(" reader.read_exact(buf.as_mut_slice())?;"), String(" message = String::from_utf8(buf)?;"), String(" } else {"), String(" count_empty_lines = 0;"), String(" if !line.starts_with(\"Content-Length\") {"), String(" continue;"), String(" }"), String(""), String(" let tokens: Vec<&str> = line.splitn(2, ':').collect();"), String(" let len = tokens"), String(" .get(1)"), String(" .ok_or_else(|| anyhow!(\"Failed to get length! tokens: {:?}\", tokens))?"), String(" .trim();"), String(" content_length = usize::from_str(len)?;"), String(" }"), String(" } else if reader.read_line(&mut message)? == 0 {"), String(" break;"), String(" }"), String(""), String(" let message = message.trim();"), String(" if message.is_empty() {"), String(" continue;"), String(" }"), String(" debug!(\"<= {:?} {}\", language_id, message);"), String(" // FIXME: Remove extra `meta` property from javascript-typescript-langserver and"), String(" // `requestMethod` sent by Sorbet."), String(" let s = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");"), String(" let message = serde_json::from_str(&s);"), String(" if let Err(ref err) = message {"), String(" error!("), String(" \"Failed to deserialize output: {}\\n\\n Message: {}\\n\\nError: {:?}\","), String(" err, s, err"), String(" );"), String(" continue;"), String(" }"), String(" // TODO: cleanup."), String(" let message = message.unwrap();"), String(" match message {"), String(" RawMessage::MethodCall(method_call) => {"), String(" sink.send(Call::MethodCall(language_id.clone(), method_call))?;"), String(" }"), String(" RawMessage::Notification(notification) => {"), String(" sink.send(Call::Notification(language_id.clone(), notification))?;"), String(" }"), String(" RawMessage::Output(output) => {"), String(" while let Ok((id, tx)) = reader_rx.try_recv() {"), String(" pending_outputs.insert(id, tx);"), String(" }"), String(""), String(" if let Some(tx) = pending_outputs.remove(&output.id().to_int()?) {"), String(" tx.send(output)"), String(" .map_err(|output| anyhow!(\"Failed to send output: {:?}\", output))?;"), String(" }"), String(" }"), String(" };"), String(" }"), String(""), String(" info!(\"reader-{:?} terminated\", language_id);"), String(" Ok(())"), String("}"), String(""), String("fn loop_write("), String(" writer: impl Write,"), String(" rx: &Receiver,"), String(" language_id: &LanguageId,"), String(") -> Result<()> {"), String(" let mut writer = writer;"), String(""), String(" for msg in rx.iter() {"), String(" let s = serde_json::to_string(&msg)?;"), String(" debug!(\"=> {:?} {}\", language_id, s);"), String(" if language_id.is_none() {"), String(" // Use different convention for two reasons,"), String(" // 1. If using '\\r\\ncontent', nvim will receive output as `\\r` + `content`, while vim"), String(" // receives `content`."), String(" // 2. Without last line ending, vim output handler won't be triggered."), String(" write!(writer, \"Content-Length: {}\\n\\n{}\\n\", s.len(), s)?;"), String(" } else {"), String(" write!(writer, \"Content-Length: {}\\r\\n\\r\\n{}\", s.len(), s)?;"), String(" };"), String(" writer.flush()?;"), String(" }"), String(" Ok(())"), String("}"), String(""), String("#[cfg(test)]"), String("mod test {"), String(" use super::RE_REMOVE_EXTRA_FIELDS;"), String(" use crate::types::RawMessage;"), String(""), String(" #[test]"), String(" // The library we're using for json-rpc doesn't accept extra fields in the structs used to"), String(" // deserialize the message. Sorbet (and possibly other servers) sends an extra field in it, so"), String(" // the client fails to deserialize that response."), String(" // Our previous solution was to pin the dependency to jsonrpc-core to version 12, but is"), String(" // suboptimal, so we now try to remove the extra fields we know of from the response."), String(" //"), String(" // See related issue: https://github.com/autozimu/LanguageClient-neovim/issues/892"), String(" fn it_should_remove_extra_fields() {"), String(" // it removes the requestMethod field from Sorbet"), String(" let message = r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"requestMethod\":\"initialize\",\"result\":0}\"#;"), String(" let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");"), String(" let result: Result = serde_json::from_str(&message);"), String(" assert!(result.is_ok());"), String(""), String(" let message ="), String(" r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"requestMethod\":\"textDocument/definition\",\"result\":0}\"#;"), String(" let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");"), String(" let result: Result = serde_json::from_str(&message);"), String(" assert!(result.is_ok());"), String(""), String(" // it removes the meta field from javascript-typescript-langserver"), String(" let message = r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"meta\":{},\"result\":0}\"#;"), String(" let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");"), String(" let result: Result = serde_json::from_str(&message);"), String(" assert!(result.is_ok());"), String(" }"), String("}"), String("")])}) 17:00:16 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"LSP#text","params":["/home/dick/LanguageClient-neovim/src/rpcclient.rs"],"id":25} 17:00:16 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 25, "jsonrpc": "2.0", "result": ["use crate::types::{Call, Id, LSError, LanguageId, RawMessage, ToInt, ToParams, ToRpcError};", "use anyhow::{anyhow, Result};", "use crossbeam::channel::{bounded, unbounded, Receiver, Sender};", "use log::*;", "use regex::Regex;", "use serde::{de::DeserializeOwned, Serialize};", "use std::io::Write;", "use std::str::FromStr;", "use std::{", " collections::HashMap,", " io::BufRead,", " sync::atomic::{AtomicU64, Ordering},", " thread,", " time::Duration,", "};", "", "const CONTENT_MODIFIED_ERROR_CODE: i64 = -32801;", "", "lazy_static! {", " // this regex is used to remove some additional fields that we get from some servers, namely:", " // meta, sent by javascript-typescript-langserver and requestMethod, sent by Sorbet.", " static ref RE_REMOVE_EXTRA_FIELDS: Regex =", " Regex::new(r#\",\\s?\"(?:meta|requestMethod)\":(?:\"\\w+(/\\w+)?\"|\\{\\})\"#).unwrap();", "}", "", "#[derive(Serialize)]", "pub struct RpcClient {", " language_id: LanguageId,", " #[serde(skip_serializing)]", " id: AtomicU64,", " #[serde(skip_serializing)]", " writer_tx: Sender,", " #[serde(skip_serializing)]", " reader_tx: Sender<(Id, Sender)>,", " pub process_id: Option,", "}", "", "impl RpcClient {", " #[allow(clippy::new_ret_no_self)]", " pub fn new(", " language_id: LanguageId,", " reader: impl BufRead + Send + 'static,", " writer: impl Write + Send + 'static,", " process_id: Option,", " sink: Sender,", " on_crash: impl Fn(&LanguageId) + Clone + Send + 'static,", " ) -> Result {", " let (reader_tx, reader_rx): (Sender<(Id, Sender)>, _) = unbounded();", "", " let language_id_clone = language_id.clone();", " let reader_thread_name = format!(\"reader-{:?}\", language_id);", " let on_crash_clone = on_crash.clone();", " thread::Builder::new()", " .name(reader_thread_name.clone())", " .spawn(move || {", " if let Err(err) = loop_read(reader, reader_rx, &sink, &language_id_clone) {", " match err.downcast_ref::() {", " Some(err) if err.kind() == std::io::ErrorKind::UnexpectedEof => {", " on_crash_clone(&language_id_clone)", " }", " _ => {}", " }", "", " error!(\"Thread {} exited with error: {:?}\", reader_thread_name, err);", " }", " })?;", "", " let (writer_tx, writer_rx) = unbounded();", " let writer_thread_name = format!(\"writer-{:?}\", language_id);", " let language_id_clone = language_id.clone();", " thread::Builder::new()", " .name(writer_thread_name.clone())", " .spawn(move || {", " if let Err(err) = loop_write(writer, &writer_rx, &language_id_clone) {", " match err.downcast_ref::() {", " Some(err) if err.kind() == std::io::ErrorKind::BrokenPipe => {", " on_crash(&language_id_clone)", " }", " _ => {}", " }", "", " error!(\"Thread {} exited with error: {:?}\", writer_thread_name, err);", " }", " })?;", "", " Ok(Self {", " language_id,", " id: AtomicU64::default(),", " process_id,", " reader_tx,", " writer_tx,", " })", " }", "", " pub fn call(", " &self,", " method: impl AsRef,", " params: impl Serialize,", " ) -> Result {", " let method = method.as_ref();", " let id = self.id.fetch_add(1, Ordering::SeqCst);", " let msg = jsonrpc_core::MethodCall {", " jsonrpc: Some(jsonrpc_core::Version::V2),", " id: jsonrpc_core::Id::Num(id),", " method: method.to_owned(),", " params: params.to_params()?,", " };", " let (tx, rx) = bounded(1);", " self.reader_tx.send((id, tx))?;", " self.writer_tx.send(RawMessage::MethodCall(msg))?;", " // TODO: duration from config.", " match rx.recv_timeout(Duration::from_secs(60))? {", " jsonrpc_core::Output::Success(ok) => Ok(serde_json::from_value(ok.result)?),", " // NOTE: Errors with code -32801 correspond to the protocol's ContentModified error,", " // which we don't want to show to the user and should ignore, as the result of the", " // request that triggered this error has been invalidated by changes to the state", " // of the server, so we must handle this error specifically.", " jsonrpc_core::Output::Failure(err)", " if err.error.code.code() == CONTENT_MODIFIED_ERROR_CODE =>", " {", " Err(anyhow::Error::from(LSError::ContentModified))", " }", " jsonrpc_core::Output::Failure(err) => Err(anyhow!(\"Error: {:?}\", err)),", " }", " }", "", " pub fn notify(&self, method: impl AsRef, params: impl Serialize) -> Result<()> {", " let method = method.as_ref();", "", " let msg = jsonrpc_core::Notification {", " jsonrpc: Some(jsonrpc_core::Version::V2),", " method: method.to_owned(),", " params: params.to_params()?,", " };", " self.writer_tx.send(RawMessage::Notification(msg))?;", " Ok(())", " }", "", " pub fn output(&self, id: Id, result: Result) -> Result<()> {", " let output = match result {", " Ok(ok) => jsonrpc_core::Output::Success(jsonrpc_core::Success {", " jsonrpc: Some(jsonrpc_core::Version::V2),", " id: jsonrpc_core::Id::Num(id),", " result: serde_json::to_value(ok)?,", " }),", " Err(err) => jsonrpc_core::Output::Failure(jsonrpc_core::Failure {", " jsonrpc: Some(jsonrpc_core::Version::V2),", " id: jsonrpc_core::Id::Num(id),", " error: err.to_rpc_error(),", " }),", " };", "", " self.writer_tx.send(RawMessage::Output(output))?;", " Ok(())", " }", "}", "", "fn loop_read(", " reader: impl BufRead,", " reader_rx: Receiver<(Id, Sender)>,", " sink: &Sender,", " language_id: &LanguageId,", ") -> Result<()> {", " let mut pending_outputs = HashMap::new();", "", " // Count how many consequent empty lines.", " let mut count_empty_lines = 0;", "", " let mut reader = reader;", " let mut content_length = 0;", " loop {", " let mut message = String::new();", " let mut line = String::new();", " if language_id.is_some() {", " reader.read_line(&mut line)?;", " let line = line.trim();", " if line.is_empty() {", " count_empty_lines += 1;", " if count_empty_lines > 5 {", " return Err(anyhow!(\"Unable to read from language server\"));", " }", "", " let mut buf = vec![0; content_length];", " reader.read_exact(buf.as_mut_slice())?;", " message = String::from_utf8(buf)?;", " } else {", " count_empty_lines = 0;", " if !line.starts_with(\"Content-Length\") {", " continue;", " }", "", " let tokens: Vec<&str> = line.splitn(2, ':').collect();", " let len = tokens", " .get(1)", " .ok_or_else(|| anyhow!(\"Failed to get length! tokens: {:?}\", tokens))?", " .trim();", " content_length = usize::from_str(len)?;", " }", " } else if reader.read_line(&mut message)? == 0 {", " break;", " }", "", " let message = message.trim();", " if message.is_empty() {", " continue;", " }", " debug!(\"<= {:?} {}\", language_id, message);", " // FIXME: Remove extra `meta` property from javascript-typescript-langserver and", " // `requestMethod` sent by Sorbet.", " let s = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");", " let message = serde_json::from_str(&s);", " if let Err(ref err) = message {", " error!(", " \"Failed to deserialize output: {}\\n\\n Message: {}\\n\\nError: {:?}\",", " err, s, err", " );", " continue;", " }", " // TODO: cleanup.", " let message = message.unwrap();", " match message {", " RawMessage::MethodCall(method_call) => {", " sink.send(Call::MethodCall(language_id.clone(), method_call))?;", " }", " RawMessage::Notification(notification) => {", " sink.send(Call::Notification(language_id.clone(), notification))?;", " }", " RawMessage::Output(output) => {", " while let Ok((id, tx)) = reader_rx.try_recv() {", " pending_outputs.insert(id, tx);", " }", "", " if let Some(tx) = pending_outputs.remove(&output.id().to_int()?) {", " tx.send(output)", " .map_err(|output| anyhow!(\"Failed to send output: {:?}\", output))?;", " }", " }", " };", " }", "", " info!(\"reader-{:?} terminated\", language_id);", " Ok(())", "}", "", "fn loop_write(", " writer: impl Write,", " rx: &Receiver,", " language_id: &LanguageId,", ") -> Result<()> {", " let mut writer = writer;", "", " for msg in rx.iter() {", " let s = serde_json::to_string(&msg)?;", " debug!(\"=> {:?} {}\", language_id, s);", " if language_id.is_none() {", " // Use different convention for two reasons,", " // 1. If using '\\r\\ncontent', nvim will receive output as `\\r` + `content`, while vim", " // receives `content`.", " // 2. Without last line ending, vim output handler won't be triggered.", " write!(writer, \"Content-Length: {}\\n\\n{}\\n\", s.len(), s)?;", " } else {", " write!(writer, \"Content-Length: {}\\r\\n\\r\\n{}\", s.len(), s)?;", " };", " writer.flush()?;", " }", " Ok(())", "}", "", "#[cfg(test)]", "mod test {", " use super::RE_REMOVE_EXTRA_FIELDS;", " use crate::types::RawMessage;", "", " #[test]", " // The library we're using for json-rpc doesn't accept extra fields in the structs used to", " // deserialize the message. Sorbet (and possibly other servers) sends an extra field in it, so", " // the client fails to deserialize that response.", " // Our previous solution was to pin the dependency to jsonrpc-core to version 12, but is", " // suboptimal, so we now try to remove the extra fields we know of from the response.", " //", " // See related issue: https://github.com/autozimu/LanguageClient-neovim/issues/892", " fn it_should_remove_extra_fields() {", " // it removes the requestMethod field from Sorbet", " let message = r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"requestMethod\":\"initialize\",\"result\":0}\"#;", " let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");", " let result: Result = serde_json::from_str(&message);", " assert!(result.is_ok());", "", " let message =", " r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"requestMethod\":\"textDocument/definition\",\"result\":0}\"#;", " let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");", " let result: Result = serde_json::from_str(&message);", " assert!(result.is_ok());", "", " // it removes the meta field from javascript-typescript-langserver", " let message = r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"meta\":{},\"result\":0}\"#;", " let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");", " let result: Result = serde_json::from_str(&message);", " assert!(result.is_ok());", " }", "}", ""]} 17:00:16 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"eval","params":["LSP#position()"],"id":26} 17:00:16 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 26, "jsonrpc": "2.0", "result": {"character": 45, "line": 49}} 17:00:16 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"eval","params":["expand('')"],"id":27} 17:00:16 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 27, "jsonrpc": "2.0", "result": "clone"} 17:00:16 DEBUG writer-Some("rust") src/rpcclient.rs:254 => Some("rust") {"jsonrpc":"2.0","method":"textDocument/definition","params":{"bufnr":1,"character":45,"filename":"/home/dick/LanguageClient-neovim/src/rpcclient.rs","gotoCmd":null,"handle":true,"languageId":"rust","line":49,"method":"textDocument/definition","position":{"character":45,"line":49},"text":["use crate::types::{Call, Id, LSError, LanguageId, RawMessage, ToInt, ToParams, ToRpcError};","use anyhow::{anyhow, Result};","use crossbeam::channel::{bounded, unbounded, Receiver, Sender};","use log::*;","use regex::Regex;","use serde::{de::DeserializeOwned, Serialize};","use std::io::Write;","use std::str::FromStr;","use std::{"," collections::HashMap,"," io::BufRead,"," sync::atomic::{AtomicU64, Ordering},"," thread,"," time::Duration,","};","","const CONTENT_MODIFIED_ERROR_CODE: i64 = -32801;","","lazy_static! {"," // this regex is used to remove some additional fields that we get from some servers, namely:"," // meta, sent by javascript-typescript-langserver and requestMethod, sent by Sorbet."," static ref RE_REMOVE_EXTRA_FIELDS: Regex ="," Regex::new(r#\",\\s?\"(?:meta|requestMethod)\":(?:\"\\w+(/\\w+)?\"|\\{\\})\"#).unwrap();","}","","#[derive(Serialize)]","pub struct RpcClient {"," language_id: LanguageId,"," #[serde(skip_serializing)]"," id: AtomicU64,"," #[serde(skip_serializing)]"," writer_tx: Sender,"," #[serde(skip_serializing)]"," reader_tx: Sender<(Id, Sender)>,"," pub process_id: Option,","}","","impl RpcClient {"," #[allow(clippy::new_ret_no_self)]"," pub fn new("," language_id: LanguageId,"," reader: impl BufRead + Send + 'static,"," writer: impl Write + Send + 'static,"," process_id: Option,"," sink: Sender,"," on_crash: impl Fn(&LanguageId) + Clone + Send + 'static,"," ) -> Result {"," let (reader_tx, reader_rx): (Sender<(Id, Sender)>, _) = unbounded();",""," let language_id_clone = language_id.clone();"," let reader_thread_name = format!(\"reader-{:?}\", language_id);"," let on_crash_clone = on_crash.clone();"," thread::Builder::new()"," .name(reader_thread_name.clone())"," .spawn(move || {"," if let Err(err) = loop_read(reader, reader_rx, &sink, &language_id_clone) {"," match err.downcast_ref::() {"," Some(err) if err.kind() == std::io::ErrorKind::UnexpectedEof => {"," on_crash_clone(&language_id_clone)"," }"," _ => {}"," }",""," error!(\"Thread {} exited with error: {:?}\", reader_thread_name, err);"," }"," })?;",""," let (writer_tx, writer_rx) = unbounded();"," let writer_thread_name = format!(\"writer-{:?}\", language_id);"," let language_id_clone = language_id.clone();"," thread::Builder::new()"," .name(writer_thread_name.clone())"," .spawn(move || {"," if let Err(err) = loop_write(writer, &writer_rx, &language_id_clone) {"," match err.downcast_ref::() {"," Some(err) if err.kind() == std::io::ErrorKind::BrokenPipe => {"," on_crash(&language_id_clone)"," }"," _ => {}"," }",""," error!(\"Thread {} exited with error: {:?}\", writer_thread_name, err);"," }"," })?;",""," Ok(Self {"," language_id,"," id: AtomicU64::default(),"," process_id,"," reader_tx,"," writer_tx,"," })"," }",""," pub fn call("," &self,"," method: impl AsRef,"," params: impl Serialize,"," ) -> Result {"," let method = method.as_ref();"," let id = self.id.fetch_add(1, Ordering::SeqCst);"," let msg = jsonrpc_core::MethodCall {"," jsonrpc: Some(jsonrpc_core::Version::V2),"," id: jsonrpc_core::Id::Num(id),"," method: method.to_owned(),"," params: params.to_params()?,"," };"," let (tx, rx) = bounded(1);"," self.reader_tx.send((id, tx))?;"," self.writer_tx.send(RawMessage::MethodCall(msg))?;"," // TODO: duration from config."," match rx.recv_timeout(Duration::from_secs(60))? {"," jsonrpc_core::Output::Success(ok) => Ok(serde_json::from_value(ok.result)?),"," // NOTE: Errors with code -32801 correspond to the protocol's ContentModified error,"," // which we don't want to show to the user and should ignore, as the result of the"," // request that triggered this error has been invalidated by changes to the state"," // of the server, so we must handle this error specifically."," jsonrpc_core::Output::Failure(err)"," if err.error.code.code() == CONTENT_MODIFIED_ERROR_CODE =>"," {"," Err(anyhow::Error::from(LSError::ContentModified))"," }"," jsonrpc_core::Output::Failure(err) => Err(anyhow!(\"Error: {:?}\", err)),"," }"," }",""," pub fn notify(&self, method: impl AsRef, params: impl Serialize) -> Result<()> {"," let method = method.as_ref();",""," let msg = jsonrpc_core::Notification {"," jsonrpc: Some(jsonrpc_core::Version::V2),"," method: method.to_owned(),"," params: params.to_params()?,"," };"," self.writer_tx.send(RawMessage::Notification(msg))?;"," Ok(())"," }",""," pub fn output(&self, id: Id, result: Result) -> Result<()> {"," let output = match result {"," Ok(ok) => jsonrpc_core::Output::Success(jsonrpc_core::Success {"," jsonrpc: Some(jsonrpc_core::Version::V2),"," id: jsonrpc_core::Id::Num(id),"," result: serde_json::to_value(ok)?,"," }),"," Err(err) => jsonrpc_core::Output::Failure(jsonrpc_core::Failure {"," jsonrpc: Some(jsonrpc_core::Version::V2),"," id: jsonrpc_core::Id::Num(id),"," error: err.to_rpc_error(),"," }),"," };",""," self.writer_tx.send(RawMessage::Output(output))?;"," Ok(())"," }","}","","fn loop_read("," reader: impl BufRead,"," reader_rx: Receiver<(Id, Sender)>,"," sink: &Sender,"," language_id: &LanguageId,",") -> Result<()> {"," let mut pending_outputs = HashMap::new();",""," // Count how many consequent empty lines."," let mut count_empty_lines = 0;",""," let mut reader = reader;"," let mut content_length = 0;"," loop {"," let mut message = String::new();"," let mut line = String::new();"," if language_id.is_some() {"," reader.read_line(&mut line)?;"," let line = line.trim();"," if line.is_empty() {"," count_empty_lines += 1;"," if count_empty_lines > 5 {"," return Err(anyhow!(\"Unable to read from language server\"));"," }",""," let mut buf = vec![0; content_length];"," reader.read_exact(buf.as_mut_slice())?;"," message = String::from_utf8(buf)?;"," } else {"," count_empty_lines = 0;"," if !line.starts_with(\"Content-Length\") {"," continue;"," }",""," let tokens: Vec<&str> = line.splitn(2, ':').collect();"," let len = tokens"," .get(1)"," .ok_or_else(|| anyhow!(\"Failed to get length! tokens: {:?}\", tokens))?"," .trim();"," content_length = usize::from_str(len)?;"," }"," } else if reader.read_line(&mut message)? == 0 {"," break;"," }",""," let message = message.trim();"," if message.is_empty() {"," continue;"," }"," debug!(\"<= {:?} {}\", language_id, message);"," // FIXME: Remove extra `meta` property from javascript-typescript-langserver and"," // `requestMethod` sent by Sorbet."," let s = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");"," let message = serde_json::from_str(&s);"," if let Err(ref err) = message {"," error!("," \"Failed to deserialize output: {}\\n\\n Message: {}\\n\\nError: {:?}\","," err, s, err"," );"," continue;"," }"," // TODO: cleanup."," let message = message.unwrap();"," match message {"," RawMessage::MethodCall(method_call) => {"," sink.send(Call::MethodCall(language_id.clone(), method_call))?;"," }"," RawMessage::Notification(notification) => {"," sink.send(Call::Notification(language_id.clone(), notification))?;"," }"," RawMessage::Output(output) => {"," while let Ok((id, tx)) = reader_rx.try_recv() {"," pending_outputs.insert(id, tx);"," }",""," if let Some(tx) = pending_outputs.remove(&output.id().to_int()?) {"," tx.send(output)"," .map_err(|output| anyhow!(\"Failed to send output: {:?}\", output))?;"," }"," }"," };"," }",""," info!(\"reader-{:?} terminated\", language_id);"," Ok(())","}","","fn loop_write("," writer: impl Write,"," rx: &Receiver,"," language_id: &LanguageId,",") -> Result<()> {"," let mut writer = writer;",""," for msg in rx.iter() {"," let s = serde_json::to_string(&msg)?;"," debug!(\"=> {:?} {}\", language_id, s);"," if language_id.is_none() {"," // Use different convention for two reasons,"," // 1. If using '\\r\\ncontent', nvim will receive output as `\\r` + `content`, while vim"," // receives `content`."," // 2. Without last line ending, vim output handler won't be triggered."," write!(writer, \"Content-Length: {}\\n\\n{}\\n\", s.len(), s)?;"," } else {"," write!(writer, \"Content-Length: {}\\r\\n\\r\\n{}\", s.len(), s)?;"," };"," writer.flush()?;"," }"," Ok(())","}","","#[cfg(test)]","mod test {"," use super::RE_REMOVE_EXTRA_FIELDS;"," use crate::types::RawMessage;",""," #[test]"," // The library we're using for json-rpc doesn't accept extra fields in the structs used to"," // deserialize the message. Sorbet (and possibly other servers) sends an extra field in it, so"," // the client fails to deserialize that response."," // Our previous solution was to pin the dependency to jsonrpc-core to version 12, but is"," // suboptimal, so we now try to remove the extra fields we know of from the response."," //"," // See related issue: https://github.com/autozimu/LanguageClient-neovim/issues/892"," fn it_should_remove_extra_fields() {"," // it removes the requestMethod field from Sorbet"," let message = r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"requestMethod\":\"initialize\",\"result\":0}\"#;"," let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");"," let result: Result = serde_json::from_str(&message);"," assert!(result.is_ok());",""," let message ="," r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"requestMethod\":\"textDocument/definition\",\"result\":0}\"#;"," let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");"," let result: Result = serde_json::from_str(&message);"," assert!(result.is_ok());",""," // it removes the meta field from javascript-typescript-langserver"," let message = r#\"{\"jsonrpc\":\"2.0\",\"id\":1,\"meta\":{},\"result\":0}\"#;"," let message = RE_REMOVE_EXTRA_FIELDS.replace(message, \"\");"," let result: Result = serde_json::from_str(&message);"," assert!(result.is_ok());"," }","}",""],"textDocument":{"uri":"file:///home/dick/LanguageClient-neovim/src/rpcclient.rs"}},"id":2} 17:00:16 DEBUG reader-Some("rust") src/rpcclient.rs:207 <= Some("rust") {"jsonrpc":"2.0","id":2,"result":[{"originSelectionRange":{"start":{"line":49,"character":44},"end":{"line":49,"character":49}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1886,"character":4},"end":{"line":1892,"character":5}},"targetSelectionRange":{"start":{"line":1887,"character":7},"end":{"line":1887,"character":12}}}]} 17:00:16 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:Edit","params":["edit","/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"]} 17:00:16 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"cursor","params":[1888,8]} 17:00:16 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"eval","params":["expand('%')"],"id":28} 17:00:16 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleFileType", "jsonrpc": "2.0", "params": {"bufnr": 2, "viewport": {"end": 22, "start": 0}, "languageId": "rust", "position": {"character": 0, "line": 0}, "filename": "/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}} 17:00:16 INFO unnamed src/language_server_protocol.rs:2760 handle_file_type; params=Object({"bufnr": Number(2), "filename": String("/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"), "languageId": String("rust"), "position": Object({"character": Number(0), "line": Number(0)}), "viewport": Object({"end": Number(22), "start": Number(0)})}) 17:00:16 INFO unnamed src/language_server_protocol.rs:1946 text_document_did_open; params=Object({"bufnr": Number(2), "filename": String("/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"), "languageId": String("rust"), "position": Object({"character": Number(0), "line": Number(0)}), "viewport": Object({"end": Number(22), "start": Number(0)})}) 17:00:16 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"LSP#text","params":["/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"],"id":29} 17:00:16 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleBufEnter", "jsonrpc": "2.0", "params": {"bufnr": 2, "languageId": "rust", "filename": "/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}} 17:00:16 INFO unnamed src/language_server_protocol.rs:2739 handle_buf_enter; params=Object({"bufnr": Number(2), "filename": String("/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"), "languageId": String("rust")}) 17:00:16 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"setbufvar","params":["/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","LanguageClient_isServerRunning",1]} 17:00:16 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 28, "jsonrpc": "2.0", "result": "/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"} 17:00:16 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:EchomsgEllipsis","params":["/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs 1888:8"]} 17:00:16 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","result":[{"originSelectionRange":{"end":{"character":49,"line":49},"start":{"character":44,"line":49}},"targetRange":{"end":{"character":5,"line":1892},"start":{"character":4,"line":1886}},"targetSelectionRange":{"end":{"character":12,"line":1887},"start":{"character":7,"line":1887}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}],"id":1} 17:00:16 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 29, "jsonrpc": "2.0", "result": ["//! Optional values.", "//!", "//! Type [`Option`] represents an optional value: every [`Option`]", "//! is either [`Some`] and contains a value, or [`None`], and", "//! does not. [`Option`] types are very common in Rust code, as", "//! they have a number of uses:", "//!", "//! * Initial values", "//! * Return values for functions that are not defined", "//! over their entire input range (partial functions)", "//! * Return value for otherwise reporting simple errors, where [`None`] is", "//! returned on error", "//! * Optional struct fields", "//! * Struct fields that can be loaned or \"taken\"", "//! * Optional function arguments", "//! * Nullable pointers", "//! * Swapping things out of difficult situations", "//!", "//! [`Option`]s are commonly paired with pattern matching to query the presence", "//! of a value and take action, always accounting for the [`None`] case.", "//!", "//! ```", "//! fn divide(numerator: f64, denominator: f64) -> Option {", "//! if denominator == 0.0 {", "//! None", "//! } else {", "//! Some(numerator / denominator)", "//! }", "//! }", "//!", "//! // The return value of the function is an option", "//! let result = divide(2.0, 3.0);", "//!", "//! // Pattern match to retrieve the value", "//! match result {", "//! // The division was valid", "//! Some(x) => println!(\"Result: {x}\"),", "//! // The division was invalid", "//! None => println!(\"Cannot divide by 0\"),", "//! }", "//! ```", "//!", "//", "// FIXME: Show how `Option` is used in practice, with lots of methods", "//", "//! # Options and pointers (\"nullable\" pointers)", "//!", "//! Rust's pointer types must always point to a valid location; there are", "//! no \"null\" references. Instead, Rust has *optional* pointers, like", "//! the optional owned box, [Option]<[Box\\]>.", "//!", "//! [Box\\]: ../../std/boxed/struct.Box.html", "//!", "//! The following example uses [`Option`] to create an optional box of", "//! [`i32`]. Notice that in order to use the inner [`i32`] value, the", "//! `check_optional` function first needs to use pattern matching to", "//! determine whether the box has a value (i.e., it is [`Some(...)`][`Some`]) or", "//! not ([`None`]).", "//!", "//! ```", "//! let optional = None;", "//! check_optional(optional);", "//!", "//! let optional = Some(Box::new(9000));", "//! check_optional(optional);", "//!", "//! fn check_optional(optional: Option>) {", "//! match optional {", "//! Some(p) => println!(\"has value {p}\"),", "//! None => println!(\"has no value\"),", "//! }", "//! }", "//! ```", "//!", "//! # Representation", "//!", "//! Rust guarantees to optimize the following types `T` such that", "//! [`Option`] has the same size as `T`:", "//!", "//! * [`Box`]", "//! * `&U`", "//! * `&mut U`", "//! * `fn`, `extern \"C\" fn`[^extern_fn]", "//! * [`num::NonZero*`]", "//! * [`ptr::NonNull`]", "//! * `#[repr(transparent)]` struct around one of the types in this list.", "//!", "//! [^extern_fn]: this remains true for any other ABI: `extern \"abi\" fn` (_e.g._, `extern \"system\" fn`)", "//!", "//! [`Box`]: ../../std/boxed/struct.Box.html", "//! [`num::NonZero*`]: crate::num", "//! [`ptr::NonNull`]: crate::ptr::NonNull", "//!", "//! This is called the \"null pointer optimization\" or NPO.", "//!", "//! It is further guaranteed that, for the cases above, one can", "//! [`mem::transmute`] from all valid values of `T` to `Option` and", "//! from `Some::(_)` to `T` (but transmuting `None::` to `T`", "//! is undefined behaviour).", "//!", "//! # Method overview", "//!", "//! In addition to working with pattern matching, [`Option`] provides a wide", "//! variety of different methods.", "//!", "//! ## Querying the variant", "//!", "//! The [`is_some`] and [`is_none`] methods return [`true`] if the [`Option`]", "//! is [`Some`] or [`None`], respectively.", "//!", "//! [`is_none`]: Option::is_none", "//! [`is_some`]: Option::is_some", "//!", "//! ## Adapters for working with references", "//!", "//! * [`as_ref`] converts from [&][][Option]\\ to [Option]<[&]T>", "//! * [`as_mut`] converts from [&mut] [Option]\\ to [Option]<[&mut] T>", "//! * [`as_deref`] converts from [&][][Option]\\ to", "//! [Option]<[&]T::[Target]>", "//! * [`as_deref_mut`] converts from [&mut] [Option]\\ to", "//! [Option]<[&mut] T::[Target]>", "//! * [`as_pin_ref`] converts from [Pin]<[&][][Option]\\> to", "//! [Option]<[Pin]<[&]T>>", "//! * [`as_pin_mut`] converts from [Pin]<[&mut] [Option]\\> to", "//! [Option]<[Pin]<[&mut] T>>", "//!", "//! [&]: reference \"shared reference\"", "//! [&mut]: reference \"mutable reference\"", "//! [Target]: Deref::Target \"ops::Deref::Target\"", "//! [`as_deref`]: Option::as_deref", "//! [`as_deref_mut`]: Option::as_deref_mut", "//! [`as_mut`]: Option::as_mut", "//! [`as_pin_mut`]: Option::as_pin_mut", "//! [`as_pin_ref`]: Option::as_pin_ref", "//! [`as_ref`]: Option::as_ref", "//!", "//! ## Extracting the contained value", "//!", "//! These methods extract the contained value in an [`Option`] when it", "//! is the [`Some`] variant. If the [`Option`] is [`None`]:", "//!", "//! * [`expect`] panics with a provided custom message", "//! * [`unwrap`] panics with a generic message", "//! * [`unwrap_or`] returns the provided default value", "//! * [`unwrap_or_default`] returns the default value of the type `T`", "//! (which must implement the [`Default`] trait)", "//! * [`unwrap_or_else`] returns the result of evaluating the provided", "//! function", "//!", "//! [`expect`]: Option::expect", "//! [`unwrap`]: Option::unwrap", "//! [`unwrap_or`]: Option::unwrap_or", "//! [`unwrap_or_default`]: Option::unwrap_or_default", "//! [`unwrap_or_else`]: Option::unwrap_or_else", "//!", "//! ## Transforming contained values", "//!", "//! These methods transform [`Option`] to [`Result`]:", "//!", "//! * [`ok_or`] transforms [`Some(v)`] to [`Ok(v)`], and [`None`] to", "//! [`Err(err)`] using the provided default `err` value", "//! * [`ok_or_else`] transforms [`Some(v)`] to [`Ok(v)`], and [`None`] to", "//! a value of [`Err`] using the provided function", "//! * [`transpose`] transposes an [`Option`] of a [`Result`] into a", "//! [`Result`] of an [`Option`]", "//!", "//! [`Err(err)`]: Err", "//! [`Ok(v)`]: Ok", "//! [`Some(v)`]: Some", "//! [`ok_or`]: Option::ok_or", "//! [`ok_or_else`]: Option::ok_or_else", "//! [`transpose`]: Option::transpose", "//!", "//! These methods transform the [`Some`] variant:", "//!", "//! * [`filter`] calls the provided predicate function on the contained", "//! value `t` if the [`Option`] is [`Some(t)`], and returns [`Some(t)`]", "//! if the function returns `true`; otherwise, returns [`None`]", "//! * [`flatten`] removes one level of nesting from an", "//! [`Option>`]", "//! * [`map`] transforms [`Option`] to [`Option`] by applying the", "//! provided function to the contained value of [`Some`] and leaving", "//! [`None`] values unchanged", "//!", "//! [`Some(t)`]: Some", "//! [`filter`]: Option::filter", "//! [`flatten`]: Option::flatten", "//! [`map`]: Option::map", "//!", "//! These methods transform [`Option`] to a value of a possibly", "//! different type `U`:", "//!", "//! * [`map_or`] applies the provided function to the contained value of", "//! [`Some`], or returns the provided default value if the [`Option`] is", "//! [`None`]", "//! * [`map_or_else`] applies the provided function to the contained value", "//! of [`Some`], or returns the result of evaluating the provided", "//! fallback function if the [`Option`] is [`None`]", "//!", "//! [`map_or`]: Option::map_or", "//! [`map_or_else`]: Option::map_or_else", "//!", "//! These methods combine the [`Some`] variants of two [`Option`] values:", "//!", "//! * [`zip`] returns [`Some((s, o))`] if `self` is [`Some(s)`] and the", "//! provided [`Option`] value is [`Some(o)`]; otherwise, returns [`None`]", "//! * [`zip_with`] calls the provided function `f` and returns", "//! [`Some(f(s, o))`] if `self` is [`Some(s)`] and the provided", "//! [`Option`] value is [`Some(o)`]; otherwise, returns [`None`]", "//!", "//! [`Some(f(s, o))`]: Some", "//! [`Some(o)`]: Some", "//! [`Some(s)`]: Some", "//! [`Some((s, o))`]: Some", "//! [`zip`]: Option::zip", "//! [`zip_with`]: Option::zip_with", "//!", "//! ## Boolean operators", "//!", "//! These methods treat the [`Option`] as a boolean value, where [`Some`]", "//! acts like [`true`] and [`None`] acts like [`false`]. There are two", "//! categories of these methods: ones that take an [`Option`] as input, and", "//! ones that take a function as input (to be lazily evaluated).", "//!", "//! The [`and`], [`or`], and [`xor`] methods take another [`Option`] as", "//! input, and produce an [`Option`] as output. Only the [`and`] method can", "//! produce an [`Option`] value having a different inner type `U` than", "//! [`Option`].", "//!", "//! | method | self | input | output |", "//! |---------|-----------|-----------|-----------|", "//! | [`and`] | `None` | (ignored) | `None` |", "//! | [`and`] | `Some(x)` | `None` | `None` |", "//! | [`and`] | `Some(x)` | `Some(y)` | `Some(y)` |", "//! | [`or`] | `None` | `None` | `None` |", "//! | [`or`] | `None` | `Some(y)` | `Some(y)` |", "//! | [`or`] | `Some(x)` | (ignored) | `Some(x)` |", "//! | [`xor`] | `None` | `None` | `None` |", "//! | [`xor`] | `None` | `Some(y)` | `Some(y)` |", "//! | [`xor`] | `Some(x)` | `None` | `Some(x)` |", "//! | [`xor`] | `Some(x)` | `Some(y)` | `None` |", "//!", "//! [`and`]: Option::and", "//! [`or`]: Option::or", "//! [`xor`]: Option::xor", "//!", "//! The [`and_then`] and [`or_else`] methods take a function as input, and", "//! only evaluate the function when they need to produce a new value. Only", "//! the [`and_then`] method can produce an [`Option`] value having a", "//! different inner type `U` than [`Option`].", "//!", "//! | method | self | function input | function result | output |", "//! |--------------|-----------|----------------|-----------------|-----------|", "//! | [`and_then`] | `None` | (not provided) | (not evaluated) | `None` |", "//! | [`and_then`] | `Some(x)` | `x` | `None` | `None` |", "//! | [`and_then`] | `Some(x)` | `x` | `Some(y)` | `Some(y)` |", "//! | [`or_else`] | `None` | (not provided) | `None` | `None` |", "//! | [`or_else`] | `None` | (not provided) | `Some(y)` | `Some(y)` |", "//! | [`or_else`] | `Some(x)` | (not provided) | (not evaluated) | `Some(x)` |", "//!", "//! [`and_then`]: Option::and_then", "//! [`or_else`]: Option::or_else", "//!", "//! This is an example of using methods like [`and_then`] and [`or`] in a", "//! pipeline of method calls. Early stages of the pipeline pass failure", "//! values ([`None`]) through unchanged, and continue processing on", "//! success values ([`Some`]). Toward the end, [`or`] substitutes an error", "//! message if it receives [`None`].", "//!", "//! ```", "//! # use std::collections::BTreeMap;", "//! let mut bt = BTreeMap::new();", "//! bt.insert(20u8, \"foo\");", "//! bt.insert(42u8, \"bar\");", "//! let res = [0u8, 1, 11, 200, 22]", "//! .into_iter()", "//! .map(|x| {", "//! // `checked_sub()` returns `None` on error", "//! x.checked_sub(1)", "//! // same with `checked_mul()`", "//! .and_then(|x| x.checked_mul(2))", "//! // `BTreeMap::get` returns `None` on error", "//! .and_then(|x| bt.get(&x))", "//! // Substitute an error message if we have `None` so far", "//! .or(Some(&\"error!\"))", "//! .copied()", "//! // Won't panic because we unconditionally used `Some` above", "//! .unwrap()", "//! })", "//! .collect::>();", "//! assert_eq!(res, [\"error!\", \"error!\", \"foo\", \"error!\", \"bar\"]);", "//! ```", "//!", "//! ## Comparison operators", "//!", "//! If `T` implements [`PartialOrd`] then [`Option`] will derive its", "//! [`PartialOrd`] implementation. With this order, [`None`] compares as", "//! less than any [`Some`], and two [`Some`] compare the same way as their", "//! contained values would in `T`. If `T` also implements", "//! [`Ord`], then so does [`Option`].", "//!", "//! ```", "//! assert!(None < Some(0));", "//! assert!(Some(0) < Some(1));", "//! ```", "//!", "//! ## Iterating over `Option`", "//!", "//! An [`Option`] can be iterated over. This can be helpful if you need an", "//! iterator that is conditionally empty. The iterator will either produce", "//! a single value (when the [`Option`] is [`Some`]), or produce no values", "//! (when the [`Option`] is [`None`]). For example, [`into_iter`] acts like", "//! [`once(v)`] if the [`Option`] is [`Some(v)`], and like [`empty()`] if", "//! the [`Option`] is [`None`].", "//!", "//! [`Some(v)`]: Some", "//! [`empty()`]: crate::iter::empty", "//! [`once(v)`]: crate::iter::once", "//!", "//! Iterators over [`Option`] come in three types:", "//!", "//! * [`into_iter`] consumes the [`Option`] and produces the contained", "//! value", "//! * [`iter`] produces an immutable reference of type `&T` to the", "//! contained value", "//! * [`iter_mut`] produces a mutable reference of type `&mut T` to the", "//! contained value", "//!", "//! [`into_iter`]: Option::into_iter", "//! [`iter`]: Option::iter", "//! [`iter_mut`]: Option::iter_mut", "//!", "//! An iterator over [`Option`] can be useful when chaining iterators, for", "//! example, to conditionally insert items. (It's not always necessary to", "//! explicitly call an iterator constructor: many [`Iterator`] methods that", "//! accept other iterators will also accept iterable types that implement", "//! [`IntoIterator`], which includes [`Option`].)", "//!", "//! ```", "//! let yep = Some(42);", "//! let nope = None;", "//! // chain() already calls into_iter(), so we don't have to do so", "//! let nums: Vec = (0..4).chain(yep).chain(4..8).collect();", "//! assert_eq!(nums, [0, 1, 2, 3, 42, 4, 5, 6, 7]);", "//! let nums: Vec = (0..4).chain(nope).chain(4..8).collect();", "//! assert_eq!(nums, [0, 1, 2, 3, 4, 5, 6, 7]);", "//! ```", "//!", "//! One reason to chain iterators in this way is that a function returning", "//! `impl Iterator` must have all possible return values be of the same", "//! concrete type. Chaining an iterated [`Option`] can help with that.", "//!", "//! ```", "//! fn make_iter(do_insert: bool) -> impl Iterator {", "//! // Explicit returns to illustrate return types matching", "//! match do_insert {", "//! true => return (0..4).chain(Some(42)).chain(4..8),", "//! false => return (0..4).chain(None).chain(4..8),", "//! }", "//! }", "//! println!(\"{:?}\", make_iter(true).collect::>());", "//! println!(\"{:?}\", make_iter(false).collect::>());", "//! ```", "//!", "//! If we try to do the same thing, but using [`once()`] and [`empty()`],", "//! we can't return `impl Iterator` anymore because the concrete types of", "//! the return values differ.", "//!", "//! [`empty()`]: crate::iter::empty", "//! [`once()`]: crate::iter::once", "//!", "//! ```compile_fail,E0308", "//! # use std::iter::{empty, once};", "//! // This won't compile because all possible returns from the function", "//! // must have the same concrete type.", "//! fn make_iter(do_insert: bool) -> impl Iterator {", "//! // Explicit returns to illustrate return types not matching", "//! match do_insert {", "//! true => return (0..4).chain(once(42)).chain(4..8),", "//! false => return (0..4).chain(empty()).chain(4..8),", "//! }", "//! }", "//! ```", "//!", "//! ## Collecting into `Option`", "//!", "//! [`Option`] implements the [`FromIterator`][impl-FromIterator] trait,", "//! which allows an iterator over [`Option`] values to be collected into an", "//! [`Option`] of a collection of each contained value of the original", "//! [`Option`] values, or [`None`] if any of the elements was [`None`].", "//!", "//! [impl-FromIterator]: Option#impl-FromIterator%3COption%3CA%3E%3E", "//!", "//! ```", "//! let v = [Some(2), Some(4), None, Some(8)];", "//! let res: Option> = v.into_iter().collect();", "//! assert_eq!(res, None);", "//! let v = [Some(2), Some(4), Some(8)];", "//! let res: Option> = v.into_iter().collect();", "//! assert_eq!(res, Some(vec![2, 4, 8]));", "//! ```", "//!", "//! [`Option`] also implements the [`Product`][impl-Product] and", "//! [`Sum`][impl-Sum] traits, allowing an iterator over [`Option`] values", "//! to provide the [`product`][Iterator::product] and", "//! [`sum`][Iterator::sum] methods.", "//!", "//! [impl-Product]: Option#impl-Product%3COption%3CU%3E%3E", "//! [impl-Sum]: Option#impl-Sum%3COption%3CU%3E%3E", "//!", "//! ```", "//! let v = [None, Some(1), Some(2), Some(3)];", "//! let res: Option = v.into_iter().sum();", "//! assert_eq!(res, None);", "//! let v = [Some(1), Some(2), Some(21)];", "//! let res: Option = v.into_iter().product();", "//! assert_eq!(res, Some(42));", "//! ```", "//!", "//! ## Modifying an [`Option`] in-place", "//!", "//! These methods return a mutable reference to the contained value of an", "//! [`Option`]:", "//!", "//! * [`insert`] inserts a value, dropping any old contents", "//! * [`get_or_insert`] gets the current value, inserting a provided", "//! default value if it is [`None`]", "//! * [`get_or_insert_default`] gets the current value, inserting the", "//! default value of type `T` (which must implement [`Default`]) if it is", "//! [`None`]", "//! * [`get_or_insert_with`] gets the current value, inserting a default", "//! computed by the provided function if it is [`None`]", "//!", "//! [`get_or_insert`]: Option::get_or_insert", "//! [`get_or_insert_default`]: Option::get_or_insert_default", "//! [`get_or_insert_with`]: Option::get_or_insert_with", "//! [`insert`]: Option::insert", "//!", "//! These methods transfer ownership of the contained value of an", "//! [`Option`]:", "//!", "//! * [`take`] takes ownership of the contained value of an [`Option`], if", "//! any, replacing the [`Option`] with [`None`]", "//! * [`replace`] takes ownership of the contained value of an [`Option`],", "//! if any, replacing the [`Option`] with a [`Some`] containing the", "//! provided value", "//!", "//! [`replace`]: Option::replace", "//! [`take`]: Option::take", "//!", "//! # Examples", "//!", "//! Basic pattern matching on [`Option`]:", "//!", "//! ```", "//! let msg = Some(\"howdy\");", "//!", "//! // Take a reference to the contained string", "//! if let Some(m) = &msg {", "//! println!(\"{}\", *m);", "//! }", "//!", "//! // Remove the contained string, destroying the Option", "//! let unwrapped_msg = msg.unwrap_or(\"default message\");", "//! ```", "//!", "//! Initialize a result to [`None`] before a loop:", "//!", "//! ```", "//! enum Kingdom { Plant(u32, &'static str), Animal(u32, &'static str) }", "//!", "//! // A list of data to search through.", "//! let all_the_big_things = [", "//! Kingdom::Plant(250, \"redwood\"),", "//! Kingdom::Plant(230, \"noble fir\"),", "//! Kingdom::Plant(229, \"sugar pine\"),", "//! Kingdom::Animal(25, \"blue whale\"),", "//! Kingdom::Animal(19, \"fin whale\"),", "//! Kingdom::Animal(15, \"north pacific right whale\"),", "//! ];", "//!", "//! // We're going to search for the name of the biggest animal,", "//! // but to start with we've just got `None`.", "//! let mut name_of_biggest_animal = None;", "//! let mut size_of_biggest_animal = 0;", "//! for big_thing in &all_the_big_things {", "//! match *big_thing {", "//! Kingdom::Animal(size, name) if size > size_of_biggest_animal => {", "//! // Now we've found the name of some big animal", "//! size_of_biggest_animal = size;", "//! name_of_biggest_animal = Some(name);", "//! }", "//! Kingdom::Animal(..) | Kingdom::Plant(..) => ()", "//! }", "//! }", "//!", "//! match name_of_biggest_animal {", "//! Some(name) => println!(\"the biggest animal is {name}\"),", "//! None => println!(\"there are no animals :(\"),", "//! }", "//! ```", "", "#![stable(feature = \"rust1\", since = \"1.0.0\")]", "", "use crate::iter::{self, FromIterator, FusedIterator, TrustedLen};", "use crate::marker::Destruct;", "use crate::panicking::{panic, panic_str};", "use crate::pin::Pin;", "use crate::{", " convert, hint, mem,", " ops::{self, ControlFlow, Deref, DerefMut},", "};", "", "/// The `Option` type. See [the module level documentation](self) for more.", "#[derive(Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]", "#[rustc_diagnostic_item = \"Option\"]", "#[stable(feature = \"rust1\", since = \"1.0.0\")]", "pub enum Option {", " /// No value.", " #[lang = \"None\"]", " #[stable(feature = \"rust1\", since = \"1.0.0\")]", " None,", " /// Some value of type `T`.", " #[lang = \"Some\"]", " #[stable(feature = \"rust1\", since = \"1.0.0\")]", " Some(#[stable(feature = \"rust1\", since = \"1.0.0\")] T),", "}", "", "/////////////////////////////////////////////////////////////////////////////", "// Type implementation", "/////////////////////////////////////////////////////////////////////////////", "", "impl Option {", " /////////////////////////////////////////////////////////////////////////", " // Querying the contained values", " /////////////////////////////////////////////////////////////////////////", "", " /// Returns `true` if the option is a [`Some`] value.", " ///", " /// # Examples", " ///", " /// ```", " /// let x: Option = Some(2);", " /// assert_eq!(x.is_some(), true);", " ///", " /// let x: Option = None;", " /// assert_eq!(x.is_some(), false);", " /// ```", " #[must_use = \"if you intended to assert that this has a value, consider `.unwrap()` instead\"]", " #[inline]", " #[stable(feature = \"rust1\", since = \"1.0.0\")]", " #[rustc_const_stable(feature = \"const_option_basics\", since = \"1.48.0\")]", " pub const fn is_some(&self) -> bool {", " matches!(*self, Some(_))", " }", "", " /// Returns `true` if the option is a [`Some`] and the value inside of it matches a predicate.", " ///", " /// # Examples", " ///", " /// ```", " /// #![feature(is_some_with)]", " ///", " /// let x: Option = Some(2);", " /// assert_eq!(x.is_some_and(|&x| x > 1), true);", " ///", " /// let x: Option = Some(0);", " /// assert_eq!(x.is_some_and(|&x| x > 1), false);", " ///", " /// let x: Option = None;", " /// assert_eq!(x.is_some_and(|&x| x > 1), false);", " /// ```", " #[must_use]", " #[inline]", " #[unstable(feature = \"is_some_with\", issue = \"93050\")]", " pub fn is_some_and(&self, f: impl FnOnce(&T) -> bool) -> bool {", " matches!(self, Some(x) if f(x))", " }", "", " /// Returns `true` if the option is a [`None`] value.", " ///", " /// # Examples", " ///", " /// ```", " /// let x: Option = Some(2);", " /// assert_eq!(x.is_none(), false);", " ///", " /// let x: Option = None;", " /// assert_eq!(x.is_none(), true);", " /// ```", " #[must_use = \"if you intended to assert that this doesn't have a value, consider \\", " `.and_then(|_| panic!(\\\"`Option` had a value when expected `None`\\\"))` instead\"]", " #[inline]", " #[stable(feature = \"rust1\", since = \"1.0.0\")]", " #[rustc_const_stable(feature = \"const_option_basics\", since = \"1.48.0\")]", " pub const fn is_none(&self) -> bool {", " !self.is_some()", " }", "", " /////////////////////////////////////////////////////////////////////////", " // Adapter for working with references", " /////////////////////////////////////////////////////////////////////////", "", " /// Converts from `&Option` to `Option<&T>`.", " ///", " /// # Examples", " ///", " /// Converts an Option<[String]> into an Option<[usize]>, preserving", " /// the original. The [`map`] method takes the `self` argument by value, consuming the original,", " /// so this technique uses `as_ref` to first take an `Option` to a reference", " /// to the value inside the original.", " ///", " /// [`map`]: Option::map", " /// [String]: ../../std/string/struct.String.html \"String\"", " ///", " /// ```", " /// let text: Option = Some(\"Hello, world!\".to_string());", " /// // First, cast `Option` to `Option<&String>` with `as_ref`,", " /// // then consume *that* with `map`, leaving `text` on the stack.", " /// let text_length: Option = text.as_ref().map(|s| s.len());", " /// println!(\"still can print text: {text:?}\");", " /// ```", " #[inline]", " #[rustc_const_stable(feature = \"const_option_basics\", since = \"1.48.0\")]", " #[stable(feature = \"rust1\", since = \"1.0.0\")]", " pub const fn as_ref(&self) -> Option<&T> {", " match *self {", " Some(ref x) => Some(x),", " None => None,", " }", " }", "", " /// Converts from `&mut Option` to `Option<&mut T>`.", " ///", " /// # Examples", " ///", " /// ```", " /// let mut x = Some(2);", " /// match x.as_mut() {", " /// Some(v) => *v = 42,", " /// None => {},", " /// }", " /// assert_eq!(x, Some(42));", " /// ```", " #[inline]", " #[stable(feature = \"rust1\", since = \"1.0.0\")]", " #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]", " pub const fn as_mut(&mut self) -> Option<&mut T> {", " match *self {", " Some(ref mut x) => Some(x),", " None => None,", " }", " }", "", " /// Converts from [Pin]<[&]Option\\> to Option<[Pin]<[&]T>>.", " ///", " /// [&]: reference \"shared reference\"", " #[inline]", " #[must_use]", " #[stable(feature = \"pin\", since = \"1.33.0\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn as_pin_ref(self: Pin<&Self>) -> Option> {", " match Pin::get_ref(self).as_ref() {", " // SAFETY: `x` is guaranteed to be pinned because it comes from `self`", " // which is pinned.", " Some(x) => unsafe { Some(Pin::new_unchecked(x)) },", " None => None,", " }", " }", "", " /// Converts from [Pin]<[&mut] Option\\> to Option<[Pin]<[&mut] T>>.", " ///", " /// [&mut]: reference \"mutable reference\"", " #[inline]", " #[must_use]", " #[stable(feature = \"pin\", since = \"1.33.0\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn as_pin_mut(self: Pin<&mut Self>) -> Option> {", " // SAFETY: `get_unchecked_mut` is never used to move the `Option` inside `self`.", " // `x` is guaranteed to be pinned because it comes from `self` which is pinned.", " unsafe {", " match Pin::get_unchecked_mut(self).as_mut() {", " Some(x) => Some(Pin::new_unchecked(x)),", " None => None,", " }", " }", " }", "", " /////////////////////////////////////////////////////////////////////////", " // Getting to contained values", " /////////////////////////////////////////////////////////////////////////", "", " /// Returns the contained [`Some`] value, consuming the `self` value.", " ///", " /// # Panics", " ///", " /// Panics if the value is a [`None`] with a custom panic message provided by", " /// `msg`.", " ///", " /// # Examples", " ///", " /// ```", " /// let x = Some(\"value\");", " /// assert_eq!(x.expect(\"fruits are healthy\"), \"value\");", " /// ```", " ///", " /// ```should_panic", " /// let x: Option<&str> = None;", " /// x.expect(\"fruits are healthy\"); // panics with `fruits are healthy`", " /// ```", " ///", " /// # Recommended Message Style", " ///", " /// We recommend that `expect` messages are used to describe the reason you", " /// _expect_ the `Option` should be `Some`.", " ///", " /// ```should_panic", " /// # let slice: &[u8] = &[];", " /// let item = slice.get(0)", " /// .expect(\"slice should not be empty\");", " /// ```", " ///", " /// **Hint**: If you're having trouble remembering how to phrase expect", " /// error messages remember to focus on the word \"should\" as in \"env", " /// variable should be set by blah\" or \"the given binary should be available", " /// and executable by the current user\".", " ///", " /// For more detail on expect message styles and the reasoning behind our", " /// recommendation please refer to the section on [\"Common Message", " /// Styles\"](../../std/error/index.html#common-message-styles) in the [`std::error`](../../std/error/index.html) module docs.", " #[inline]", " #[track_caller]", " #[stable(feature = \"rust1\", since = \"1.0.0\")]", " #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]", " pub const fn expect(self, msg: &str) -> T {", " match self {", " Some(val) => val,", " None => expect_failed(msg),", " }", " }", "", " /// Returns the contained [`Some`] value, consuming the `self` value.", " ///", " /// Because this function may panic, its use is generally discouraged.", " /// Instead, prefer to use pattern matching and handle the [`None`]", " /// case explicitly, or call [`unwrap_or`], [`unwrap_or_else`], or", " /// [`unwrap_or_default`].", " ///", " /// [`unwrap_or`]: Option::unwrap_or", " /// [`unwrap_or_else`]: Option::unwrap_or_else", " /// [`unwrap_or_default`]: Option::unwrap_or_default", " ///", " /// # Panics", " ///", " /// Panics if the self value equals [`None`].", " ///", " /// # Examples", " ///", " /// ```", " /// let x = Some(\"air\");", " /// assert_eq!(x.unwrap(), \"air\");", " /// ```", " ///", " /// ```should_panic", " /// let x: Option<&str> = None;", " /// assert_eq!(x.unwrap(), \"air\"); // fails", " /// ```", " #[inline]", " #[track_caller]", " #[stable(feature = \"rust1\", since = \"1.0.0\")]", " #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]", " pub const fn unwrap(self) -> T {", " match self {", " Some(val) => val,", " None => panic(\"called `Option::unwrap()` on a `None` value\"),", " }", " }", "", " /// Returns the contained [`Some`] value or a provided default.", " ///", " /// Arguments passed to `unwrap_or` are eagerly evaluated; if you are passing", " /// the result of a function call, it is recommended to use [`unwrap_or_else`],", " /// which is lazily evaluated.", " ///", " /// [`unwrap_or_else`]: Option::unwrap_or_else", " ///", " /// # Examples", " ///", " /// ```", " /// assert_eq!(Some(\"car\").unwrap_or(\"bike\"), \"car\");", " /// assert_eq!(None.unwrap_or(\"bike\"), \"bike\");", " /// ```", " #[inline]", " #[stable(feature = \"rust1\", since = \"1.0.0\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn unwrap_or(self, default: T) -> T", " where", " T: ~const Destruct,", " {", " match self {", " Some(x) => x,", " None => default,", " }", " }", "", " /// Returns the contained [`Some`] value or computes it from a closure.", " ///", " /// # Examples", " ///", " /// ```", " /// let k = 10;", " /// assert_eq!(Some(4).unwrap_or_else(|| 2 * k), 4);", " /// assert_eq!(None.unwrap_or_else(|| 2 * k), 20);", " /// ```", " #[inline]", " #[stable(feature = \"rust1\", since = \"1.0.0\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn unwrap_or_else(self, f: F) -> T", " where", " F: ~const FnOnce() -> T,", " F: ~const Destruct,", " {", " match self {", " Some(x) => x,", " None => f(),", " }", " }", "", " /// Returns the contained [`Some`] value or a default.", " ///", " /// Consumes the `self` argument then, if [`Some`], returns the contained", " /// value, otherwise if [`None`], returns the [default value] for that", " /// type.", " ///", " /// # Examples", " ///", " /// Converts a string to an integer, turning poorly-formed strings", " /// into 0 (the default value for integers). [`parse`] converts", " /// a string to any other type that implements [`FromStr`], returning", " /// [`None`] on error.", " ///", " /// ```", " /// let good_year_from_input = \"1909\";", " /// let bad_year_from_input = \"190blarg\";", " /// let good_year = good_year_from_input.parse().ok().unwrap_or_default();", " /// let bad_year = bad_year_from_input.parse().ok().unwrap_or_default();", " ///", " /// assert_eq!(1909, good_year);", " /// assert_eq!(0, bad_year);", " /// ```", " ///", " /// [default value]: Default::default", " /// [`parse`]: str::parse", " /// [`FromStr`]: crate::str::FromStr", " #[inline]", " #[stable(feature = \"rust1\", since = \"1.0.0\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn unwrap_or_default(self) -> T", " where", " T: ~const Default,", " {", " match self {", " Some(x) => x,", " None => Default::default(),", " }", " }", "", " /// Returns the contained [`Some`] value, consuming the `self` value,", " /// without checking that the value is not [`None`].", " ///", " /// # Safety", " ///", " /// Calling this method on [`None`] is *[undefined behavior]*.", " ///", " /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html", " ///", " /// # Examples", " ///", " /// ```", " /// let x = Some(\"air\");", " /// assert_eq!(unsafe { x.unwrap_unchecked() }, \"air\");", " /// ```", " ///", " /// ```no_run", " /// let x: Option<&str> = None;", " /// assert_eq!(unsafe { x.unwrap_unchecked() }, \"air\"); // Undefined behavior!", " /// ```", " #[inline]", " #[track_caller]", " #[stable(feature = \"option_result_unwrap_unchecked\", since = \"1.58.0\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const unsafe fn unwrap_unchecked(self) -> T {", " debug_assert!(self.is_some());", " match self {", " Some(val) => val,", " // SAFETY: the safety contract must be upheld by the caller.", " None => unsafe { hint::unreachable_unchecked() },", " }", " }", "", " /////////////////////////////////////////////////////////////////////////", " // Transforming contained values", " /////////////////////////////////////////////////////////////////////////", "", " /// Maps an `Option` to `Option` by applying a function to a contained value.", " ///", " /// # Examples", " ///", " /// Converts an Option<[String]> into an Option<[usize]>, consuming", " /// the original:", " ///", " /// [String]: ../../std/string/struct.String.html \"String\"", " /// ```", " /// let maybe_some_string = Some(String::from(\"Hello, World!\"));", " /// // `Option::map` takes self *by value*, consuming `maybe_some_string`", " /// let maybe_some_len = maybe_some_string.map(|s| s.len());", " ///", " /// assert_eq!(maybe_some_len, Some(13));", " /// ```", " #[inline]", " #[stable(feature = \"rust1\", since = \"1.0.0\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn map(self, f: F) -> Option", " where", " F: ~const FnOnce(T) -> U,", " F: ~const Destruct,", " {", " match self {", " Some(x) => Some(f(x)),", " None => None,", " }", " }", "", " /// Calls the provided closure with a reference to the contained value (if [`Some`]).", " ///", " /// # Examples", " ///", " /// ```", " /// #![feature(result_option_inspect)]", " ///", " /// let v = vec![1, 2, 3, 4, 5];", " ///", " /// // prints \"got: 4\"", " /// let x: Option<&usize> = v.get(3).inspect(|x| println!(\"got: {x}\"));", " ///", " /// // prints nothing", " /// let x: Option<&usize> = v.get(5).inspect(|x| println!(\"got: {x}\"));", " /// ```", " #[inline]", " #[unstable(feature = \"result_option_inspect\", issue = \"91345\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn inspect(self, f: F) -> Self", " where", " F: ~const FnOnce(&T),", " F: ~const Destruct,", " {", " if let Some(ref x) = self {", " f(x);", " }", "", " self", " }", "", " /// Returns the provided default result (if none),", " /// or applies a function to the contained value (if any).", " ///", " /// Arguments passed to `map_or` are eagerly evaluated; if you are passing", " /// the result of a function call, it is recommended to use [`map_or_else`],", " /// which is lazily evaluated.", " ///", " /// [`map_or_else`]: Option::map_or_else", " ///", " /// # Examples", " ///", " /// ```", " /// let x = Some(\"foo\");", " /// assert_eq!(x.map_or(42, |v| v.len()), 3);", " ///", " /// let x: Option<&str> = None;", " /// assert_eq!(x.map_or(42, |v| v.len()), 42);", " /// ```", " #[inline]", " #[stable(feature = \"rust1\", since = \"1.0.0\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn map_or(self, default: U, f: F) -> U", " where", " F: ~const FnOnce(T) -> U,", " F: ~const Destruct,", " U: ~const Destruct,", " {", " match self {", " Some(t) => f(t),", " None => default,", " }", " }", "", " /// Computes a default function result (if none), or", " /// applies a different function to the contained value (if any).", " ///", " /// # Examples", " ///", " /// ```", " /// let k = 21;", " ///", " /// let x = Some(\"foo\");", " /// assert_eq!(x.map_or_else(|| 2 * k, |v| v.len()), 3);", " ///", " /// let x: Option<&str> = None;", " /// assert_eq!(x.map_or_else(|| 2 * k, |v| v.len()), 42);", " /// ```", " #[inline]", " #[stable(feature = \"rust1\", since = \"1.0.0\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn map_or_else(self, default: D, f: F) -> U", " where", " D: ~const FnOnce() -> U,", " D: ~const Destruct,", " F: ~const FnOnce(T) -> U,", " F: ~const Destruct,", " {", " match self {", " Some(t) => f(t),", " None => default(),", " }", " }", "", " /// Transforms the `Option` into a [`Result`], mapping [`Some(v)`] to", " /// [`Ok(v)`] and [`None`] to [`Err(err)`].", " ///", " /// Arguments passed to `ok_or` are eagerly evaluated; if you are passing the", " /// result of a function call, it is recommended to use [`ok_or_else`], which is", " /// lazily evaluated.", " ///", " /// [`Ok(v)`]: Ok", " /// [`Err(err)`]: Err", " /// [`Some(v)`]: Some", " /// [`ok_or_else`]: Option::ok_or_else", " ///", " /// # Examples", " ///", " /// ```", " /// let x = Some(\"foo\");", " /// assert_eq!(x.ok_or(0), Ok(\"foo\"));", " ///", " /// let x: Option<&str> = None;", " /// assert_eq!(x.ok_or(0), Err(0));", " /// ```", " #[inline]", " #[stable(feature = \"rust1\", since = \"1.0.0\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn ok_or(self, err: E) -> Result", " where", " E: ~const Destruct,", " {", " match self {", " Some(v) => Ok(v),", " None => Err(err),", " }", " }", "", " /// Transforms the `Option` into a [`Result`], mapping [`Some(v)`] to", " /// [`Ok(v)`] and [`None`] to [`Err(err())`].", " ///", " /// [`Ok(v)`]: Ok", " /// [`Err(err())`]: Err", " /// [`Some(v)`]: Some", " ///", " /// # Examples", " ///", " /// ```", " /// let x = Some(\"foo\");", " /// assert_eq!(x.ok_or_else(|| 0), Ok(\"foo\"));", " ///", " /// let x: Option<&str> = None;", " /// assert_eq!(x.ok_or_else(|| 0), Err(0));", " /// ```", " #[inline]", " #[stable(feature = \"rust1\", since = \"1.0.0\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn ok_or_else(self, err: F) -> Result", " where", " F: ~const FnOnce() -> E,", " F: ~const Destruct,", " {", " match self {", " Some(v) => Ok(v),", " None => Err(err()),", " }", " }", "", " /// Converts from `Option` (or `&Option`) to `Option<&T::Target>`.", " ///", " /// Leaves the original Option in-place, creating a new one with a reference", " /// to the original one, additionally coercing the contents via [`Deref`].", " ///", " /// # Examples", " ///", " /// ```", " /// let x: Option = Some(\"hey\".to_owned());", " /// assert_eq!(x.as_deref(), Some(\"hey\"));", " ///", " /// let x: Option = None;", " /// assert_eq!(x.as_deref(), None);", " /// ```", " #[stable(feature = \"option_deref\", since = \"1.40.0\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn as_deref(&self) -> Option<&T::Target>", " where", " T: ~const Deref,", " {", " match self.as_ref() {", " Some(t) => Some(t.deref()),", " None => None,", " }", " }", "", " /// Converts from `Option` (or `&mut Option`) to `Option<&mut T::Target>`.", " ///", " /// Leaves the original `Option` in-place, creating a new one containing a mutable reference to", " /// the inner type's [`Deref::Target`] type.", " ///", " /// # Examples", " ///", " /// ```", " /// let mut x: Option = Some(\"hey\".to_owned());", " /// assert_eq!(x.as_deref_mut().map(|x| {", " /// x.make_ascii_uppercase();", " /// x", " /// }), Some(\"HEY\".to_owned().as_mut_str()));", " /// ```", " #[stable(feature = \"option_deref\", since = \"1.40.0\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn as_deref_mut(&mut self) -> Option<&mut T::Target>", " where", " T: ~const DerefMut,", " {", " match self.as_mut() {", " Some(t) => Some(t.deref_mut()),", " None => None,", " }", " }", "", " /////////////////////////////////////////////////////////////////////////", " // Iterator constructors", " /////////////////////////////////////////////////////////////////////////", "", " /// Returns an iterator over the possibly contained value.", " ///", " /// # Examples", " ///", " /// ```", " /// let x = Some(4);", " /// assert_eq!(x.iter().next(), Some(&4));", " ///", " /// let x: Option = None;", " /// assert_eq!(x.iter().next(), None);", " /// ```", " #[inline]", " #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]", " #[stable(feature = \"rust1\", since = \"1.0.0\")]", " pub const fn iter(&self) -> Iter<'_, T> {", " Iter { inner: Item { opt: self.as_ref() } }", " }", "", " /// Returns a mutable iterator over the possibly contained value.", " ///", " /// # Examples", " ///", " /// ```", " /// let mut x = Some(4);", " /// match x.iter_mut().next() {", " /// Some(v) => *v = 42,", " /// None => {},", " /// }", " /// assert_eq!(x, Some(42));", " ///", " /// let mut x: Option = None;", " /// assert_eq!(x.iter_mut().next(), None);", " /// ```", " #[inline]", " #[stable(feature = \"rust1\", since = \"1.0.0\")]", " pub fn iter_mut(&mut self) -> IterMut<'_, T> {", " IterMut { inner: Item { opt: self.as_mut() } }", " }", "", " /////////////////////////////////////////////////////////////////////////", " // Boolean operations on the values, eager and lazy", " /////////////////////////////////////////////////////////////////////////", "", " /// Returns [`None`] if the option is [`None`], otherwise returns `optb`.", " ///", " /// # Examples", " ///", " /// ```", " /// let x = Some(2);", " /// let y: Option<&str> = None;", " /// assert_eq!(x.and(y), None);", " ///", " /// let x: Option = None;", " /// let y = Some(\"foo\");", " /// assert_eq!(x.and(y), None);", " ///", " /// let x = Some(2);", " /// let y = Some(\"foo\");", " /// assert_eq!(x.and(y), Some(\"foo\"));", " ///", " /// let x: Option = None;", " /// let y: Option<&str> = None;", " /// assert_eq!(x.and(y), None);", " /// ```", " #[inline]", " #[stable(feature = \"rust1\", since = \"1.0.0\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn and(self, optb: Option) -> Option", " where", " T: ~const Destruct,", " U: ~const Destruct,", " {", " match self {", " Some(_) => optb,", " None => None,", " }", " }", "", " /// Returns [`None`] if the option is [`None`], otherwise calls `f` with the", " /// wrapped value and returns the result.", " ///", " /// Some languages call this operation flatmap.", " ///", " /// # Examples", " ///", " /// ```", " /// fn sq_then_to_string(x: u32) -> Option {", " /// x.checked_mul(x).map(|sq| sq.to_string())", " /// }", " ///", " /// assert_eq!(Some(2).and_then(sq_then_to_string), Some(4.to_string()));", " /// assert_eq!(Some(1_000_000).and_then(sq_then_to_string), None); // overflowed!", " /// assert_eq!(None.and_then(sq_then_to_string), None);", " /// ```", " ///", " /// Often used to chain fallible operations that may return [`None`].", " ///", " /// ```", " /// let arr_2d = [[\"A0\", \"A1\"], [\"B0\", \"B1\"]];", " ///", " /// let item_0_1 = arr_2d.get(0).and_then(|row| row.get(1));", " /// assert_eq!(item_0_1, Some(&\"A1\"));", " ///", " /// let item_2_0 = arr_2d.get(2).and_then(|row| row.get(0));", " /// assert_eq!(item_2_0, None);", " /// ```", " #[inline]", " #[stable(feature = \"rust1\", since = \"1.0.0\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn and_then(self, f: F) -> Option", " where", " F: ~const FnOnce(T) -> Option,", " F: ~const Destruct,", " {", " match self {", " Some(x) => f(x),", " None => None,", " }", " }", "", " /// Returns [`None`] if the option is [`None`], otherwise calls `predicate`", " /// with the wrapped value and returns:", " ///", " /// - [`Some(t)`] if `predicate` returns `true` (where `t` is the wrapped", " /// value), and", " /// - [`None`] if `predicate` returns `false`.", " ///", " /// This function works similar to [`Iterator::filter()`]. You can imagine", " /// the `Option` being an iterator over one or zero elements. `filter()`", " /// lets you decide which elements to keep.", " ///", " /// # Examples", " ///", " /// ```rust", " /// fn is_even(n: &i32) -> bool {", " /// n % 2 == 0", " /// }", " ///", " /// assert_eq!(None.filter(is_even), None);", " /// assert_eq!(Some(3).filter(is_even), None);", " /// assert_eq!(Some(4).filter(is_even), Some(4));", " /// ```", " ///", " /// [`Some(t)`]: Some", " #[inline]", " #[stable(feature = \"option_filter\", since = \"1.27.0\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn filter

(self, predicate: P) -> Self", " where", " T: ~const Destruct,", " P: ~const FnOnce(&T) -> bool,", " P: ~const Destruct,", " {", " if let Some(x) = self {", " if predicate(&x) {", " return Some(x);", " }", " }", " None", " }", "", " /// Returns the option if it contains a value, otherwise returns `optb`.", " ///", " /// Arguments passed to `or` are eagerly evaluated; if you are passing the", " /// result of a function call, it is recommended to use [`or_else`], which is", " /// lazily evaluated.", " ///", " /// [`or_else`]: Option::or_else", " ///", " /// # Examples", " ///", " /// ```", " /// let x = Some(2);", " /// let y = None;", " /// assert_eq!(x.or(y), Some(2));", " ///", " /// let x = None;", " /// let y = Some(100);", " /// assert_eq!(x.or(y), Some(100));", " ///", " /// let x = Some(2);", " /// let y = Some(100);", " /// assert_eq!(x.or(y), Some(2));", " ///", " /// let x: Option = None;", " /// let y = None;", " /// assert_eq!(x.or(y), None);", " /// ```", " #[inline]", " #[stable(feature = \"rust1\", since = \"1.0.0\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn or(self, optb: Option) -> Option", " where", " T: ~const Destruct,", " {", " match self {", " Some(x) => Some(x),", " None => optb,", " }", " }", "", " /// Returns the option if it contains a value, otherwise calls `f` and", " /// returns the result.", " ///", " /// # Examples", " ///", " /// ```", " /// fn nobody() -> Option<&'static str> { None }", " /// fn vikings() -> Option<&'static str> { Some(\"vikings\") }", " ///", " /// assert_eq!(Some(\"barbarians\").or_else(vikings), Some(\"barbarians\"));", " /// assert_eq!(None.or_else(vikings), Some(\"vikings\"));", " /// assert_eq!(None.or_else(nobody), None);", " /// ```", " #[inline]", " #[stable(feature = \"rust1\", since = \"1.0.0\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn or_else(self, f: F) -> Option", " where", " F: ~const FnOnce() -> Option,", " F: ~const Destruct,", " {", " match self {", " Some(x) => Some(x),", " None => f(),", " }", " }", "", " /// Returns [`Some`] if exactly one of `self`, `optb` is [`Some`], otherwise returns [`None`].", " ///", " /// # Examples", " ///", " /// ```", " /// let x = Some(2);", " /// let y: Option = None;", " /// assert_eq!(x.xor(y), Some(2));", " ///", " /// let x: Option = None;", " /// let y = Some(2);", " /// assert_eq!(x.xor(y), Some(2));", " ///", " /// let x = Some(2);", " /// let y = Some(2);", " /// assert_eq!(x.xor(y), None);", " ///", " /// let x: Option = None;", " /// let y: Option = None;", " /// assert_eq!(x.xor(y), None);", " /// ```", " #[inline]", " #[stable(feature = \"option_xor\", since = \"1.37.0\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn xor(self, optb: Option) -> Option", " where", " T: ~const Destruct,", " {", " match (self, optb) {", " (Some(a), None) => Some(a),", " (None, Some(b)) => Some(b),", " _ => None,", " }", " }", "", " /////////////////////////////////////////////////////////////////////////", " // Entry-like operations to insert a value and return a reference", " /////////////////////////////////////////////////////////////////////////", "", " /// Inserts `value` into the option, then returns a mutable reference to it.", " ///", " /// If the option already contains a value, the old value is dropped.", " ///", " /// See also [`Option::get_or_insert`], which doesn't update the value if", " /// the option already contains [`Some`].", " ///", " /// # Example", " ///", " /// ```", " /// let mut opt = None;", " /// let val = opt.insert(1);", " /// assert_eq!(*val, 1);", " /// assert_eq!(opt.unwrap(), 1);", " /// let val = opt.insert(2);", " /// assert_eq!(*val, 2);", " /// *val = 3;", " /// assert_eq!(opt.unwrap(), 3);", " /// ```", " #[must_use = \"if you intended to set a value, consider assignment instead\"]", " #[inline]", " #[stable(feature = \"option_insert\", since = \"1.53.0\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn insert(&mut self, value: T) -> &mut T", " where", " T: ~const Destruct,", " {", " *self = Some(value);", "", " // SAFETY: the code above just filled the option", " unsafe { self.as_mut().unwrap_unchecked() }", " }", "", " /// Inserts `value` into the option if it is [`None`], then", " /// returns a mutable reference to the contained value.", " ///", " /// See also [`Option::insert`], which updates the value even if", " /// the option already contains [`Some`].", " ///", " /// # Examples", " ///", " /// ```", " /// let mut x = None;", " ///", " /// {", " /// let y: &mut u32 = x.get_or_insert(5);", " /// assert_eq!(y, &5);", " ///", " /// *y = 7;", " /// }", " ///", " /// assert_eq!(x, Some(7));", " /// ```", " #[inline]", " #[stable(feature = \"option_entry\", since = \"1.20.0\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn get_or_insert(&mut self, value: T) -> &mut T", " where", " T: ~const Destruct,", " {", " if let None = *self {", " *self = Some(value);", " }", "", " // SAFETY: a `None` variant for `self` would have been replaced by a `Some`", " // variant in the code above.", " unsafe { self.as_mut().unwrap_unchecked() }", " }", "", " /// Inserts the default value into the option if it is [`None`], then", " /// returns a mutable reference to the contained value.", " ///", " /// # Examples", " ///", " /// ```", " /// #![feature(option_get_or_insert_default)]", " ///", " /// let mut x = None;", " ///", " /// {", " /// let y: &mut u32 = x.get_or_insert_default();", " /// assert_eq!(y, &0);", " ///", " /// *y = 7;", " /// }", " ///", " /// assert_eq!(x, Some(7));", " /// ```", " #[inline]", " #[unstable(feature = \"option_get_or_insert_default\", issue = \"82901\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn get_or_insert_default(&mut self) -> &mut T", " where", " T: ~const Default,", " {", " const fn default() -> T {", " T::default()", " }", "", " self.get_or_insert_with(default)", " }", "", " /// Inserts a value computed from `f` into the option if it is [`None`],", " /// then returns a mutable reference to the contained value.", " ///", " /// # Examples", " ///", " /// ```", " /// let mut x = None;", " ///", " /// {", " /// let y: &mut u32 = x.get_or_insert_with(|| 5);", " /// assert_eq!(y, &5);", " ///", " /// *y = 7;", " /// }", " ///", " /// assert_eq!(x, Some(7));", " /// ```", " #[inline]", " #[stable(feature = \"option_entry\", since = \"1.20.0\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn get_or_insert_with(&mut self, f: F) -> &mut T", " where", " F: ~const FnOnce() -> T,", " F: ~const Destruct,", " {", " if let None = *self {", " // the compiler isn't smart enough to know that we are not dropping a `T`", " // here and wants us to ensure `T` can be dropped at compile time.", " mem::forget(mem::replace(self, Some(f())))", " }", "", " // SAFETY: a `None` variant for `self` would have been replaced by a `Some`", " // variant in the code above.", " unsafe { self.as_mut().unwrap_unchecked() }", " }", "", " /////////////////////////////////////////////////////////////////////////", " // Misc", " /////////////////////////////////////////////////////////////////////////", "", " /// Takes the value out of the option, leaving a [`None`] in its place.", " ///", " /// # Examples", " ///", " /// ```", " /// let mut x = Some(2);", " /// let y = x.take();", " /// assert_eq!(x, None);", " /// assert_eq!(y, Some(2));", " ///", " /// let mut x: Option = None;", " /// let y = x.take();", " /// assert_eq!(x, None);", " /// assert_eq!(y, None);", " /// ```", " #[inline]", " #[stable(feature = \"rust1\", since = \"1.0.0\")]", " #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]", " pub const fn take(&mut self) -> Option {", " // FIXME replace `mem::replace` by `mem::take` when the latter is const ready", " mem::replace(self, None)", " }", "", " /// Replaces the actual value in the option by the value given in parameter,", " /// returning the old value if present,", " /// leaving a [`Some`] in its place without deinitializing either one.", " ///", " /// # Examples", " ///", " /// ```", " /// let mut x = Some(2);", " /// let old = x.replace(5);", " /// assert_eq!(x, Some(5));", " /// assert_eq!(old, Some(2));", " ///", " /// let mut x = None;", " /// let old = x.replace(3);", " /// assert_eq!(x, Some(3));", " /// assert_eq!(old, None);", " /// ```", " #[inline]", " #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]", " #[stable(feature = \"option_replace\", since = \"1.31.0\")]", " pub const fn replace(&mut self, value: T) -> Option {", " mem::replace(self, Some(value))", " }", "", " /// Returns `true` if the option is a [`Some`] value containing the given value.", " ///", " /// # Examples", " ///", " /// ```", " /// #![feature(option_result_contains)]", " ///", " /// let x: Option = Some(2);", " /// assert_eq!(x.contains(&2), true);", " ///", " /// let x: Option = Some(3);", " /// assert_eq!(x.contains(&2), false);", " ///", " /// let x: Option = None;", " /// assert_eq!(x.contains(&2), false);", " /// ```", " #[must_use]", " #[inline]", " #[unstable(feature = \"option_result_contains\", issue = \"62358\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn contains(&self, x: &U) -> bool", " where", " U: ~const PartialEq,", " {", " match self {", " Some(y) => x.eq(y),", " None => false,", " }", " }", "", " /// Zips `self` with another `Option`.", " ///", " /// If `self` is `Some(s)` and `other` is `Some(o)`, this method returns `Some((s, o))`.", " /// Otherwise, `None` is returned.", " ///", " /// # Examples", " ///", " /// ```", " /// let x = Some(1);", " /// let y = Some(\"hi\");", " /// let z = None::;", " ///", " /// assert_eq!(x.zip(y), Some((1, \"hi\")));", " /// assert_eq!(x.zip(z), None);", " /// ```", " #[stable(feature = \"option_zip_option\", since = \"1.46.0\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn zip(self, other: Option) -> Option<(T, U)>", " where", " T: ~const Destruct,", " U: ~const Destruct,", " {", " match (self, other) {", " (Some(a), Some(b)) => Some((a, b)),", " _ => None,", " }", " }", "", " /// Zips `self` and another `Option` with function `f`.", " ///", " /// If `self` is `Some(s)` and `other` is `Some(o)`, this method returns `Some(f(s, o))`.", " /// Otherwise, `None` is returned.", " ///", " /// # Examples", " ///", " /// ```", " /// #![feature(option_zip)]", " ///", " /// #[derive(Debug, PartialEq)]", " /// struct Point {", " /// x: f64,", " /// y: f64,", " /// }", " ///", " /// impl Point {", " /// fn new(x: f64, y: f64) -> Self {", " /// Self { x, y }", " /// }", " /// }", " ///", " /// let x = Some(17.5);", " /// let y = Some(42.7);", " ///", " /// assert_eq!(x.zip_with(y, Point::new), Some(Point { x: 17.5, y: 42.7 }));", " /// assert_eq!(x.zip_with(None, Point::new), None);", " /// ```", " #[unstable(feature = \"option_zip\", issue = \"70086\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn zip_with(self, other: Option, f: F) -> Option", " where", " F: ~const FnOnce(T, U) -> R,", " F: ~const Destruct,", " T: ~const Destruct,", " U: ~const Destruct,", " {", " match (self, other) {", " (Some(a), Some(b)) => Some(f(a, b)),", " _ => None,", " }", " }", "}", "", "impl Option<(T, U)> {", " /// Unzips an option containing a tuple of two options.", " ///", " /// If `self` is `Some((a, b))` this method returns `(Some(a), Some(b))`.", " /// Otherwise, `(None, None)` is returned.", " ///", " /// # Examples", " ///", " /// ```", " /// #![feature(unzip_option)]", " ///", " /// let x = Some((1, \"hi\"));", " /// let y = None::<(u8, u32)>;", " ///", " /// assert_eq!(x.unzip(), (Some(1), Some(\"hi\")));", " /// assert_eq!(y.unzip(), (None, None));", " /// ```", " #[inline]", " #[unstable(feature = \"unzip_option\", issue = \"87800\", reason = \"recently added\")]", " pub const fn unzip(self) -> (Option, Option) {", " match self {", " Some((a, b)) => (Some(a), Some(b)),", " None => (None, None),", " }", " }", "}", "", "impl Option<&T> {", " /// Maps an `Option<&T>` to an `Option` by copying the contents of the", " /// option.", " ///", " /// # Examples", " ///", " /// ```", " /// let x = 12;", " /// let opt_x = Some(&x);", " /// assert_eq!(opt_x, Some(&12));", " /// let copied = opt_x.copied();", " /// assert_eq!(copied, Some(12));", " /// ```", " #[must_use = \"`self` will be dropped if the result is not used\"]", " #[stable(feature = \"copied\", since = \"1.35.0\")]", " #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]", " pub const fn copied(self) -> Option", " where", " T: Copy,", " {", " // FIXME: this implementation, which sidesteps using `Option::map` since it's not const", " // ready yet, should be reverted when possible to avoid code repetition", " match self {", " Some(&v) => Some(v),", " None => None,", " }", " }", "", " /// Maps an `Option<&T>` to an `Option` by cloning the contents of the", " /// option.", " ///", " /// # Examples", " ///", " /// ```", " /// let x = 12;", " /// let opt_x = Some(&x);", " /// assert_eq!(opt_x, Some(&12));", " /// let cloned = opt_x.cloned();", " /// assert_eq!(cloned, Some(12));", " /// ```", " #[must_use = \"`self` will be dropped if the result is not used\"]", " #[stable(feature = \"rust1\", since = \"1.0.0\")]", " #[rustc_const_unstable(feature = \"const_option_cloned\", issue = \"91582\")]", " pub const fn cloned(self) -> Option", " where", " T: ~const Clone,", " {", " match self {", " Some(t) => Some(t.clone()),", " None => None,", " }", " }", "}", "", "impl Option<&mut T> {", " /// Maps an `Option<&mut T>` to an `Option` by copying the contents of the", " /// option.", " ///", " /// # Examples", " ///", " /// ```", " /// let mut x = 12;", " /// let opt_x = Some(&mut x);", " /// assert_eq!(opt_x, Some(&mut 12));", " /// let copied = opt_x.copied();", " /// assert_eq!(copied, Some(12));", " /// ```", " #[must_use = \"`self` will be dropped if the result is not used\"]", " #[stable(feature = \"copied\", since = \"1.35.0\")]", " #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]", " pub const fn copied(self) -> Option", " where", " T: Copy,", " {", " match self {", " Some(&mut t) => Some(t),", " None => None,", " }", " }", "", " /// Maps an `Option<&mut T>` to an `Option` by cloning the contents of the", " /// option.", " ///", " /// # Examples", " ///", " /// ```", " /// let mut x = 12;", " /// let opt_x = Some(&mut x);", " /// assert_eq!(opt_x, Some(&mut 12));", " /// let cloned = opt_x.cloned();", " /// assert_eq!(cloned, Some(12));", " /// ```", " #[must_use = \"`self` will be dropped if the result is not used\"]", " #[stable(since = \"1.26.0\", feature = \"option_ref_mut_cloned\")]", " #[rustc_const_unstable(feature = \"const_option_cloned\", issue = \"91582\")]", " pub const fn cloned(self) -> Option", " where", " T: ~const Clone,", " {", " match self {", " Some(t) => Some(t.clone()),", " None => None,", " }", " }", "}", "", "impl Option> {", " /// Transposes an `Option` of a [`Result`] into a [`Result`] of an `Option`.", " ///", " /// [`None`] will be mapped to [Ok]\\([None]).", " /// [Some]\\([Ok]\\(\\_)) and [Some]\\([Err]\\(\\_)) will be mapped to", " /// [Ok]\\([Some]\\(\\_)) and [Err]\\(\\_).", " ///", " /// # Examples", " ///", " /// ```", " /// #[derive(Debug, Eq, PartialEq)]", " /// struct SomeErr;", " ///", " /// let x: Result, SomeErr> = Ok(Some(5));", " /// let y: Option> = Some(Ok(5));", " /// assert_eq!(x, y.transpose());", " /// ```", " #[inline]", " #[stable(feature = \"transpose_result\", since = \"1.33.0\")]", " #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]", " pub const fn transpose(self) -> Result, E> {", " match self {", " Some(Ok(x)) => Ok(Some(x)),", " Some(Err(e)) => Err(e),", " None => Ok(None),", " }", " }", "}", "", "// This is a separate function to reduce the code size of .expect() itself.", "#[cfg_attr(not(feature = \"panic_immediate_abort\"), inline(never))]", "#[cfg_attr(feature = \"panic_immediate_abort\", inline)]", "#[cold]", "#[track_caller]", "#[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]", "const fn expect_failed(msg: &str) -> ! {", " panic_str(msg)", "}", "", "/////////////////////////////////////////////////////////////////////////////", "// Trait implementations", "/////////////////////////////////////////////////////////////////////////////", "", "#[stable(feature = \"rust1\", since = \"1.0.0\")]", "#[rustc_const_unstable(feature = \"const_clone\", issue = \"91805\")]", "impl const Clone for Option", "where", " T: ~const Clone + ~const Destruct,", "{", " #[inline]", " fn clone(&self) -> Self {", " match self {", " Some(x) => Some(x.clone()),", " None => None,", " }", " }", "", " #[inline]", " fn clone_from(&mut self, source: &Self) {", " match (self, source) {", " (Some(to), Some(from)) => to.clone_from(from),", " (to, from) => *to = from.clone(),", " }", " }", "}", "", "#[stable(feature = \"rust1\", since = \"1.0.0\")]", "#[rustc_const_unstable(feature = \"const_default_impls\", issue = \"87864\")]", "impl const Default for Option {", " /// Returns [`None`][Option::None].", " ///", " /// # Examples", " ///", " /// ```", " /// let opt: Option = Option::default();", " /// assert!(opt.is_none());", " /// ```", " #[inline]", " fn default() -> Option {", " None", " }", "}", "", "#[stable(feature = \"rust1\", since = \"1.0.0\")]", "impl IntoIterator for Option {", " type Item = T;", " type IntoIter = IntoIter;", "", " /// Returns a consuming iterator over the possibly contained value.", " ///", " /// # Examples", " ///", " /// ```", " /// let x = Some(\"string\");", " /// let v: Vec<&str> = x.into_iter().collect();", " /// assert_eq!(v, [\"string\"]);", " ///", " /// let x = None;", " /// let v: Vec<&str> = x.into_iter().collect();", " /// assert!(v.is_empty());", " /// ```", " #[inline]", " fn into_iter(self) -> IntoIter {", " IntoIter { inner: Item { opt: self } }", " }", "}", "", "#[stable(since = \"1.4.0\", feature = \"option_iter\")]", "impl<'a, T> IntoIterator for &'a Option {", " type Item = &'a T;", " type IntoIter = Iter<'a, T>;", "", " fn into_iter(self) -> Iter<'a, T> {", " self.iter()", " }", "}", "", "#[stable(since = \"1.4.0\", feature = \"option_iter\")]", "impl<'a, T> IntoIterator for &'a mut Option {", " type Item = &'a mut T;", " type IntoIter = IterMut<'a, T>;", "", " fn into_iter(self) -> IterMut<'a, T> {", " self.iter_mut()", " }", "}", "", "#[stable(since = \"1.12.0\", feature = \"option_from\")]", "#[rustc_const_unstable(feature = \"const_convert\", issue = \"88674\")]", "impl const From for Option {", " /// Moves `val` into a new [`Some`].", " ///", " /// # Examples", " ///", " /// ```", " /// let o: Option = Option::from(67);", " ///", " /// assert_eq!(Some(67), o);", " /// ```", " fn from(val: T) -> Option {", " Some(val)", " }", "}", "", "#[stable(feature = \"option_ref_from_ref_option\", since = \"1.30.0\")]", "#[rustc_const_unstable(feature = \"const_convert\", issue = \"88674\")]", "impl<'a, T> const From<&'a Option> for Option<&'a T> {", " /// Converts from `&Option` to `Option<&T>`.", " ///", " /// # Examples", " ///", " /// Converts an [Option]<[String]> into an [Option]<[usize]>, preserving", " /// the original. The [`map`] method takes the `self` argument by value, consuming the original,", " /// so this technique uses `from` to first take an [`Option`] to a reference", " /// to the value inside the original.", " ///", " /// [`map`]: Option::map", " /// [String]: ../../std/string/struct.String.html \"String\"", " ///", " /// ```", " /// let s: Option = Some(String::from(\"Hello, Rustaceans!\"));", " /// let o: Option = Option::from(&s).map(|ss: &String| ss.len());", " ///", " /// println!(\"Can still print s: {s:?}\");", " ///", " /// assert_eq!(o, Some(18));", " /// ```", " fn from(o: &'a Option) -> Option<&'a T> {", " o.as_ref()", " }", "}", "", "#[stable(feature = \"option_ref_from_ref_option\", since = \"1.30.0\")]", "#[rustc_const_unstable(feature = \"const_convert\", issue = \"88674\")]", "impl<'a, T> const From<&'a mut Option> for Option<&'a mut T> {", " /// Converts from `&mut Option` to `Option<&mut T>`", " ///", " /// # Examples", " ///", " /// ```", " /// let mut s = Some(String::from(\"Hello\"));", " /// let o: Option<&mut String> = Option::from(&mut s);", " ///", " /// match o {", " /// Some(t) => *t = String::from(\"Hello, Rustaceans!\"),", " /// None => (),", " /// }", " ///", " /// assert_eq!(s, Some(String::from(\"Hello, Rustaceans!\")));", " /// ```", " fn from(o: &'a mut Option) -> Option<&'a mut T> {", " o.as_mut()", " }", "}", "", "/////////////////////////////////////////////////////////////////////////////", "// The Option Iterators", "/////////////////////////////////////////////////////////////////////////////", "", "#[derive(Clone, Debug)]", "struct Item {", " opt: Option,", "}", "", "impl Iterator for Item {", " type Item = A;", "", " #[inline]", " fn next(&mut self) -> Option {", " self.opt.take()", " }", "", " #[inline]", " fn size_hint(&self) -> (usize, Option) {", " match self.opt {", " Some(_) => (1, Some(1)),", " None => (0, Some(0)),", " }", " }", "}", "", "impl DoubleEndedIterator for Item {", " #[inline]", " fn next_back(&mut self) -> Option {", " self.opt.take()", " }", "}", "", "impl ExactSizeIterator for Item {}", "impl FusedIterator for Item {}", "unsafe impl TrustedLen for Item {}", "", "/// An iterator over a reference to the [`Some`] variant of an [`Option`].", "///", "/// The iterator yields one value if the [`Option`] is a [`Some`], otherwise none.", "///", "/// This `struct` is created by the [`Option::iter`] function.", "#[stable(feature = \"rust1\", since = \"1.0.0\")]", "#[derive(Debug)]", "pub struct Iter<'a, A: 'a> {", " inner: Item<&'a A>,", "}", "", "#[stable(feature = \"rust1\", since = \"1.0.0\")]", "impl<'a, A> Iterator for Iter<'a, A> {", " type Item = &'a A;", "", " #[inline]", " fn next(&mut self) -> Option<&'a A> {", " self.inner.next()", " }", " #[inline]", " fn size_hint(&self) -> (usize, Option) {", " self.inner.size_hint()", " }", "}", "", "#[stable(feature = \"rust1\", since = \"1.0.0\")]", "impl<'a, A> DoubleEndedIterator for Iter<'a, A> {", " #[inline]", " fn next_back(&mut self) -> Option<&'a A> {", " self.inner.next_back()", " }", "}", "", "#[stable(feature = \"rust1\", since = \"1.0.0\")]", "impl ExactSizeIterator for Iter<'_, A> {}", "", "#[stable(feature = \"fused\", since = \"1.26.0\")]", "impl FusedIterator for Iter<'_, A> {}", "", "#[unstable(feature = \"trusted_len\", issue = \"37572\")]", "unsafe impl TrustedLen for Iter<'_, A> {}", "", "#[stable(feature = \"rust1\", since = \"1.0.0\")]", "impl Clone for Iter<'_, A> {", " #[inline]", " fn clone(&self) -> Self {", " Iter { inner: self.inner.clone() }", " }", "}", "", "/// An iterator over a mutable reference to the [`Some`] variant of an [`Option`].", "///", "/// The iterator yields one value if the [`Option`] is a [`Some`], otherwise none.", "///", "/// This `struct` is created by the [`Option::iter_mut`] function.", "#[stable(feature = \"rust1\", since = \"1.0.0\")]", "#[derive(Debug)]", "pub struct IterMut<'a, A: 'a> {", " inner: Item<&'a mut A>,", "}", "", "#[stable(feature = \"rust1\", since = \"1.0.0\")]", "impl<'a, A> Iterator for IterMut<'a, A> {", " type Item = &'a mut A;", "", " #[inline]", " fn next(&mut self) -> Option<&'a mut A> {", " self.inner.next()", " }", " #[inline]", " fn size_hint(&self) -> (usize, Option) {", " self.inner.size_hint()", " }", "}", "", "#[stable(feature = \"rust1\", since = \"1.0.0\")]", "impl<'a, A> DoubleEndedIterator for IterMut<'a, A> {", " #[inline]", " fn next_back(&mut self) -> Option<&'a mut A> {", " self.inner.next_back()", " }", "}", "", "#[stable(feature = \"rust1\", since = \"1.0.0\")]", "impl ExactSizeIterator for IterMut<'_, A> {}", "", "#[stable(feature = \"fused\", since = \"1.26.0\")]", "impl FusedIterator for IterMut<'_, A> {}", "#[unstable(feature = \"trusted_len\", issue = \"37572\")]", "unsafe impl TrustedLen for IterMut<'_, A> {}", "", "/// An iterator over the value in [`Some`] variant of an [`Option`].", "///", "/// The iterator yields one value if the [`Option`] is a [`Some`], otherwise none.", "///", "/// This `struct` is created by the [`Option::into_iter`] function.", "#[derive(Clone, Debug)]", "#[stable(feature = \"rust1\", since = \"1.0.0\")]", "pub struct IntoIter {", " inner: Item,", "}", "", "#[stable(feature = \"rust1\", since = \"1.0.0\")]", "impl Iterator for IntoIter {", " type Item = A;", "", " #[inline]", " fn next(&mut self) -> Option {", " self.inner.next()", " }", " #[inline]", " fn size_hint(&self) -> (usize, Option) {", " self.inner.size_hint()", " }", "}", "", "#[stable(feature = \"rust1\", since = \"1.0.0\")]", "impl DoubleEndedIterator for IntoIter {", " #[inline]", " fn next_back(&mut self) -> Option {", " self.inner.next_back()", " }", "}", "", "#[stable(feature = \"rust1\", since = \"1.0.0\")]", "impl ExactSizeIterator for IntoIter {}", "", "#[stable(feature = \"fused\", since = \"1.26.0\")]", "impl FusedIterator for IntoIter {}", "", "#[unstable(feature = \"trusted_len\", issue = \"37572\")]", "unsafe impl TrustedLen for IntoIter {}", "", "/////////////////////////////////////////////////////////////////////////////", "// FromIterator", "/////////////////////////////////////////////////////////////////////////////", "", "#[stable(feature = \"rust1\", since = \"1.0.0\")]", "impl> FromIterator> for Option {", " /// Takes each element in the [`Iterator`]: if it is [`None`][Option::None],", " /// no further elements are taken, and the [`None`][Option::None] is", " /// returned. Should no [`None`][Option::None] occur, a container of type", " /// `V` containing the values of each [`Option`] is returned.", " ///", " /// # Examples", " ///", " /// Here is an example which increments every integer in a vector.", " /// We use the checked variant of `add` that returns `None` when the", " /// calculation would result in an overflow.", " ///", " /// ```", " /// let items = vec![0_u16, 1, 2];", " ///", " /// let res: Option> = items", " /// .iter()", " /// .map(|x| x.checked_add(1))", " /// .collect();", " ///", " /// assert_eq!(res, Some(vec![1, 2, 3]));", " /// ```", " ///", " /// As you can see, this will return the expected, valid items.", " ///", " /// Here is another example that tries to subtract one from another list", " /// of integers, this time checking for underflow:", " ///", " /// ```", " /// let items = vec![2_u16, 1, 0];", " ///", " /// let res: Option> = items", " /// .iter()", " /// .map(|x| x.checked_sub(1))", " /// .collect();", " ///", " /// assert_eq!(res, None);", " /// ```", " ///", " /// Since the last element is zero, it would underflow. Thus, the resulting", " /// value is `None`.", " ///", " /// Here is a variation on the previous example, showing that no", " /// further elements are taken from `iter` after the first `None`.", " ///", " /// ```", " /// let items = vec![3_u16, 2, 1, 10];", " ///", " /// let mut shared = 0;", " ///", " /// let res: Option> = items", " /// .iter()", " /// .map(|x| { shared += x; x.checked_sub(2) })", " /// .collect();", " ///", " /// assert_eq!(res, None);", " /// assert_eq!(shared, 6);", " /// ```", " ///", " /// Since the third element caused an underflow, no further elements were taken,", " /// so the final value of `shared` is 6 (= `3 + 2 + 1`), not 16.", " #[inline]", " fn from_iter>>(iter: I) -> Option {", " // FIXME(#11084): This could be replaced with Iterator::scan when this", " // performance bug is closed.", "", " iter::try_process(iter.into_iter(), |i| i.collect())", " }", "}", "", "#[unstable(feature = \"try_trait_v2\", issue = \"84277\")]", "#[rustc_const_unstable(feature = \"const_convert\", issue = \"88674\")]", "impl const ops::Try for Option {", " type Output = T;", " type Residual = Option;", "", " #[inline]", " fn from_output(output: Self::Output) -> Self {", " Some(output)", " }", "", " #[inline]", " fn branch(self) -> ControlFlow {", " match self {", " Some(v) => ControlFlow::Continue(v),", " None => ControlFlow::Break(None),", " }", " }", "}", "", "#[unstable(feature = \"try_trait_v2\", issue = \"84277\")]", "#[rustc_const_unstable(feature = \"const_convert\", issue = \"88674\")]", "impl const ops::FromResidual for Option {", " #[inline]", " fn from_residual(residual: Option) -> Self {", " match residual {", " None => None,", " }", " }", "}", "", "#[unstable(feature = \"try_trait_v2_yeet\", issue = \"96374\")]", "impl ops::FromResidual> for Option {", " #[inline]", " fn from_residual(ops::Yeet(()): ops::Yeet<()>) -> Self {", " None", " }", "}", "", "#[unstable(feature = \"try_trait_v2_residual\", issue = \"91285\")]", "impl ops::Residual for Option {", " type TryType = Option;", "}", "", "impl Option> {", " /// Converts from `Option>` to `Option`.", " ///", " /// # Examples", " ///", " /// Basic usage:", " ///", " /// ```", " /// let x: Option> = Some(Some(6));", " /// assert_eq!(Some(6), x.flatten());", " ///", " /// let x: Option> = Some(None);", " /// assert_eq!(None, x.flatten());", " ///", " /// let x: Option> = None;", " /// assert_eq!(None, x.flatten());", " /// ```", " ///", " /// Flattening only removes one level of nesting at a time:", " ///", " /// ```", " /// let x: Option>> = Some(Some(Some(6)));", " /// assert_eq!(Some(Some(6)), x.flatten());", " /// assert_eq!(Some(6), x.flatten().flatten());", " /// ```", " #[inline]", " #[stable(feature = \"option_flattening\", since = \"1.40.0\")]", " #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]", " pub const fn flatten(self) -> Option {", " match self {", " Some(inner) => inner,", " None => None,", " }", " }", "}", ""]} 17:00:16 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"eval","params":["s:GetVar('LanguageClient_setOmnifunc', v:true)"],"id":30} 17:00:16 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 30, "jsonrpc": "2.0", "result": true} 17:00:16 DEBUG unnamed src/language_client.rs:108 state.text_documents./home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs: null ==> {"languageId":"rust","text":"//! Optional values.\n//!\n//! Type [`Option`] represents an optional value: every [`Option`]\n//! is either [`Some`] and contains a value, or [`None`], and\n//! does not. [`Option`] types are very common in Rust code, as\n//! they have a number of uses:\n//!\n//! * Initial values\n//! * Return values for functions that are not defined\n//! over their entire input range (partial functions)\n//! * Return value for otherwise reporting simple errors, where [`None`] is\n//! returned on error\n//! * Optional struct fields\n//! * Struct fields that can be loaned or \"taken\"\n//! * Optional function arguments\n//! * Nullable pointers\n//! * Swapping things out of difficult situations\n//!\n//! [`Option`]s are commonly paired with pattern matching to query the presence\n//! of a value and take action, always accounting for the [`None`] case.\n//!\n//! ```\n//! fn divide(numerator: f64, denominator: f64) -> Option {\n//! if denominator == 0.0 {\n//! None\n//! } else {\n//! Some(numerator / denominator)\n//! }\n//! }\n//!\n//! // The return value of the function is an option\n//! let result = divide(2.0, 3.0);\n//!\n//! // Pattern match to retrieve the value\n//! match result {\n//! // The division was valid\n//! Some(x) => println!(\"Result: {x}\"),\n//! // The division was invalid\n//! None => println!(\"Cannot divide by 0\"),\n//! }\n//! ```\n//!\n//\n// FIXME: Show how `Option` is used in practice, with lots of methods\n//\n//! # Options and pointers (\"nullable\" pointers)\n//!\n//! Rust's pointer types must always point to a valid location; there are\n//! no \"null\" references. Instead, Rust has *optional* pointers, like\n//! the optional owned box, [Option]<[Box\\]>.\n//!\n//! [Box\\]: ../../std/boxed/struct.Box.html\n//!\n//! The following example uses [`Option`] to create an optional box of\n//! [`i32`]. Notice that in order to use the inner [`i32`] value, the\n//! `check_optional` function first needs to use pattern matching to\n//! determine whether the box has a value (i.e., it is [`Some(...)`][`Some`]) or\n//! not ([`None`]).\n//!\n//! ```\n//! let optional = None;\n//! check_optional(optional);\n//!\n//! let optional = Some(Box::new(9000));\n//! check_optional(optional);\n//!\n//! fn check_optional(optional: Option>) {\n//! match optional {\n//! Some(p) => println!(\"has value {p}\"),\n//! None => println!(\"has no value\"),\n//! }\n//! }\n//! ```\n//!\n//! # Representation\n//!\n//! Rust guarantees to optimize the following types `T` such that\n//! [`Option`] has the same size as `T`:\n//!\n//! * [`Box`]\n//! * `&U`\n//! * `&mut U`\n//! * `fn`, `extern \"C\" fn`[^extern_fn]\n//! * [`num::NonZero*`]\n//! * [`ptr::NonNull`]\n//! * `#[repr(transparent)]` struct around one of the types in this list.\n//!\n//! [^extern_fn]: this remains true for any other ABI: `extern \"abi\" fn` (_e.g._, `extern \"system\" fn`)\n//!\n//! [`Box`]: ../../std/boxed/struct.Box.html\n//! [`num::NonZero*`]: crate::num\n//! [`ptr::NonNull`]: crate::ptr::NonNull\n//!\n//! This is called the \"null pointer optimization\" or NPO.\n//!\n//! It is further guaranteed that, for the cases above, one can\n//! [`mem::transmute`] from all valid values of `T` to `Option` and\n//! from `Some::(_)` to `T` (but transmuting `None::` to `T`\n//! is undefined behaviour).\n//!\n//! # Method overview\n//!\n//! In addition to working with pattern matching, [`Option`] provides a wide\n//! variety of different methods.\n//!\n//! ## Querying the variant\n//!\n//! The [`is_some`] and [`is_none`] methods return [`true`] if the [`Option`]\n//! is [`Some`] or [`None`], respectively.\n//!\n//! [`is_none`]: Option::is_none\n//! [`is_some`]: Option::is_some\n//!\n//! ## Adapters for working with references\n//!\n//! * [`as_ref`] converts from [&][][Option]\\ to [Option]<[&]T>\n//! * [`as_mut`] converts from [&mut] [Option]\\ to [Option]<[&mut] T>\n//! * [`as_deref`] converts from [&][][Option]\\ to\n//! [Option]<[&]T::[Target]>\n//! * [`as_deref_mut`] converts from [&mut] [Option]\\ to\n//! [Option]<[&mut] T::[Target]>\n//! * [`as_pin_ref`] converts from [Pin]<[&][][Option]\\> to\n//! [Option]<[Pin]<[&]T>>\n//! * [`as_pin_mut`] converts from [Pin]<[&mut] [Option]\\> to\n//! [Option]<[Pin]<[&mut] T>>\n//!\n//! [&]: reference \"shared reference\"\n//! [&mut]: reference \"mutable reference\"\n//! [Target]: Deref::Target \"ops::Deref::Target\"\n//! [`as_deref`]: Option::as_deref\n//! [`as_deref_mut`]: Option::as_deref_mut\n//! [`as_mut`]: Option::as_mut\n//! [`as_pin_mut`]: Option::as_pin_mut\n//! [`as_pin_ref`]: Option::as_pin_ref\n//! [`as_ref`]: Option::as_ref\n//!\n//! ## Extracting the contained value\n//!\n//! These methods extract the contained value in an [`Option`] when it\n//! is the [`Some`] variant. If the [`Option`] is [`None`]:\n//!\n//! * [`expect`] panics with a provided custom message\n//! * [`unwrap`] panics with a generic message\n//! * [`unwrap_or`] returns the provided default value\n//! * [`unwrap_or_default`] returns the default value of the type `T`\n//! (which must implement the [`Default`] trait)\n//! * [`unwrap_or_else`] returns the result of evaluating the provided\n//! function\n//!\n//! [`expect`]: Option::expect\n//! [`unwrap`]: Option::unwrap\n//! [`unwrap_or`]: Option::unwrap_or\n//! [`unwrap_or_default`]: Option::unwrap_or_default\n//! [`unwrap_or_else`]: Option::unwrap_or_else\n//!\n//! ## Transforming contained values\n//!\n//! These methods transform [`Option`] to [`Result`]:\n//!\n//! * [`ok_or`] transforms [`Some(v)`] to [`Ok(v)`], and [`None`] to\n//! [`Err(err)`] using the provided default `err` value\n//! * [`ok_or_else`] transforms [`Some(v)`] to [`Ok(v)`], and [`None`] to\n//! a value of [`Err`] using the provided function\n//! * [`transpose`] transposes an [`Option`] of a [`Result`] into a\n//! [`Result`] of an [`Option`]\n//!\n//! [`Err(err)`]: Err\n//! [`Ok(v)`]: Ok\n//! [`Some(v)`]: Some\n//! [`ok_or`]: Option::ok_or\n//! [`ok_or_else`]: Option::ok_or_else\n//! [`transpose`]: Option::transpose\n//!\n//! These methods transform the [`Some`] variant:\n//!\n//! * [`filter`] calls the provided predicate function on the contained\n//! value `t` if the [`Option`] is [`Some(t)`], and returns [`Some(t)`]\n//! if the function returns `true`; otherwise, returns [`None`]\n//! * [`flatten`] removes one level of nesting from an\n//! [`Option>`]\n//! * [`map`] transforms [`Option`] to [`Option`] by applying the\n//! provided function to the contained value of [`Some`] and leaving\n//! [`None`] values unchanged\n//!\n//! [`Some(t)`]: Some\n//! [`filter`]: Option::filter\n//! [`flatten`]: Option::flatten\n//! [`map`]: Option::map\n//!\n//! These methods transform [`Option`] to a value of a possibly\n//! different type `U`:\n//!\n//! * [`map_or`] applies the provided function to the contained value of\n//! [`Some`], or returns the provided default value if the [`Option`] is\n//! [`None`]\n//! * [`map_or_else`] applies the provided function to the contained value\n//! of [`Some`], or returns the result of evaluating the provided\n//! fallback function if the [`Option`] is [`None`]\n//!\n//! [`map_or`]: Option::map_or\n//! [`map_or_else`]: Option::map_or_else\n//!\n//! These methods combine the [`Some`] variants of two [`Option`] values:\n//!\n//! * [`zip`] returns [`Some((s, o))`] if `self` is [`Some(s)`] and the\n//! provided [`Option`] value is [`Some(o)`]; otherwise, returns [`None`]\n//! * [`zip_with`] calls the provided function `f` and returns\n//! [`Some(f(s, o))`] if `self` is [`Some(s)`] and the provided\n//! [`Option`] value is [`Some(o)`]; otherwise, returns [`None`]\n//!\n//! [`Some(f(s, o))`]: Some\n//! [`Some(o)`]: Some\n//! [`Some(s)`]: Some\n//! [`Some((s, o))`]: Some\n//! [`zip`]: Option::zip\n//! [`zip_with`]: Option::zip_with\n//!\n//! ## Boolean operators\n//!\n//! These methods treat the [`Option`] as a boolean value, where [`Some`]\n//! acts like [`true`] and [`None`] acts like [`false`]. There are two\n//! categories of these methods: ones that take an [`Option`] as input, and\n//! ones that take a function as input (to be lazily evaluated).\n//!\n//! The [`and`], [`or`], and [`xor`] methods take another [`Option`] as\n//! input, and produce an [`Option`] as output. Only the [`and`] method can\n//! produce an [`Option`] value having a different inner type `U` than\n//! [`Option`].\n//!\n//! | method | self | input | output |\n//! |---------|-----------|-----------|-----------|\n//! | [`and`] | `None` | (ignored) | `None` |\n//! | [`and`] | `Some(x)` | `None` | `None` |\n//! | [`and`] | `Some(x)` | `Some(y)` | `Some(y)` |\n//! | [`or`] | `None` | `None` | `None` |\n//! | [`or`] | `None` | `Some(y)` | `Some(y)` |\n//! | [`or`] | `Some(x)` | (ignored) | `Some(x)` |\n//! | [`xor`] | `None` | `None` | `None` |\n//! | [`xor`] | `None` | `Some(y)` | `Some(y)` |\n//! | [`xor`] | `Some(x)` | `None` | `Some(x)` |\n//! | [`xor`] | `Some(x)` | `Some(y)` | `None` |\n//!\n//! [`and`]: Option::and\n//! [`or`]: Option::or\n//! [`xor`]: Option::xor\n//!\n//! The [`and_then`] and [`or_else`] methods take a function as input, and\n//! only evaluate the function when they need to produce a new value. Only\n//! the [`and_then`] method can produce an [`Option`] value having a\n//! different inner type `U` than [`Option`].\n//!\n//! | method | self | function input | function result | output |\n//! |--------------|-----------|----------------|-----------------|-----------|\n//! | [`and_then`] | `None` | (not provided) | (not evaluated) | `None` |\n//! | [`and_then`] | `Some(x)` | `x` | `None` | `None` |\n//! | [`and_then`] | `Some(x)` | `x` | `Some(y)` | `Some(y)` |\n//! | [`or_else`] | `None` | (not provided) | `None` | `None` |\n//! | [`or_else`] | `None` | (not provided) | `Some(y)` | `Some(y)` |\n//! | [`or_else`] | `Some(x)` | (not provided) | (not evaluated) | `Some(x)` |\n//!\n//! [`and_then`]: Option::and_then\n//! [`or_else`]: Option::or_else\n//!\n//! This is an example of using methods like [`and_then`] and [`or`] in a\n//! pipeline of method calls. Early stages of the pipeline pass failure\n//! values ([`None`]) through unchanged, and continue processing on\n//! success values ([`Some`]). Toward the end, [`or`] substitutes an error\n//! message if it receives [`None`].\n//!\n//! ```\n//! # use std::collections::BTreeMap;\n//! let mut bt = BTreeMap::new();\n//! bt.insert(20u8, \"foo\");\n//! bt.insert(42u8, \"bar\");\n//! let res = [0u8, 1, 11, 200, 22]\n//! .into_iter()\n//! .map(|x| {\n//! // `checked_sub()` returns `None` on error\n//! x.checked_sub(1)\n//! // same with `checked_mul()`\n//! .and_then(|x| x.checked_mul(2))\n//! // `BTreeMap::get` returns `None` on error\n//! .and_then(|x| bt.get(&x))\n//! // Substitute an error message if we have `None` so far\n//! .or(Some(&\"error!\"))\n//! .copied()\n//! // Won't panic because we unconditionally used `Some` above\n//! .unwrap()\n//! })\n//! .collect::>();\n//! assert_eq!(res, [\"error!\", \"error!\", \"foo\", \"error!\", \"bar\"]);\n//! ```\n//!\n//! ## Comparison operators\n//!\n//! If `T` implements [`PartialOrd`] then [`Option`] will derive its\n//! [`PartialOrd`] implementation. With this order, [`None`] compares as\n//! less than any [`Some`], and two [`Some`] compare the same way as their\n//! contained values would in `T`. If `T` also implements\n//! [`Ord`], then so does [`Option`].\n//!\n//! ```\n//! assert!(None < Some(0));\n//! assert!(Some(0) < Some(1));\n//! ```\n//!\n//! ## Iterating over `Option`\n//!\n//! An [`Option`] can be iterated over. This can be helpful if you need an\n//! iterator that is conditionally empty. The iterator will either produce\n//! a single value (when the [`Option`] is [`Some`]), or produce no values\n//! (when the [`Option`] is [`None`]). For example, [`into_iter`] acts like\n//! [`once(v)`] if the [`Option`] is [`Some(v)`], and like [`empty()`] if\n//! the [`Option`] is [`None`].\n//!\n//! [`Some(v)`]: Some\n//! [`empty()`]: crate::iter::empty\n//! [`once(v)`]: crate::iter::once\n//!\n//! Iterators over [`Option`] come in three types:\n//!\n//! * [`into_iter`] consumes the [`Option`] and produces the contained\n//! value\n//! * [`iter`] produces an immutable reference of type `&T` to the\n//! contained value\n//! * [`iter_mut`] produces a mutable reference of type `&mut T` to the\n//! contained value\n//!\n//! [`into_iter`]: Option::into_iter\n//! [`iter`]: Option::iter\n//! [`iter_mut`]: Option::iter_mut\n//!\n//! An iterator over [`Option`] can be useful when chaining iterators, for\n//! example, to conditionally insert items. (It's not always necessary to\n//! explicitly call an iterator constructor: many [`Iterator`] methods that\n//! accept other iterators will also accept iterable types that implement\n//! [`IntoIterator`], which includes [`Option`].)\n//!\n//! ```\n//! let yep = Some(42);\n//! let nope = None;\n//! // chain() already calls into_iter(), so we don't have to do so\n//! let nums: Vec = (0..4).chain(yep).chain(4..8).collect();\n//! assert_eq!(nums, [0, 1, 2, 3, 42, 4, 5, 6, 7]);\n//! let nums: Vec = (0..4).chain(nope).chain(4..8).collect();\n//! assert_eq!(nums, [0, 1, 2, 3, 4, 5, 6, 7]);\n//! ```\n//!\n//! One reason to chain iterators in this way is that a function returning\n//! `impl Iterator` must have all possible return values be of the same\n//! concrete type. Chaining an iterated [`Option`] can help with that.\n//!\n//! ```\n//! fn make_iter(do_insert: bool) -> impl Iterator {\n//! // Explicit returns to illustrate return types matching\n//! match do_insert {\n//! true => return (0..4).chain(Some(42)).chain(4..8),\n//! false => return (0..4).chain(None).chain(4..8),\n//! }\n//! }\n//! println!(\"{:?}\", make_iter(true).collect::>());\n//! println!(\"{:?}\", make_iter(false).collect::>());\n//! ```\n//!\n//! If we try to do the same thing, but using [`once()`] and [`empty()`],\n//! we can't return `impl Iterator` anymore because the concrete types of\n//! the return values differ.\n//!\n//! [`empty()`]: crate::iter::empty\n//! [`once()`]: crate::iter::once\n//!\n//! ```compile_fail,E0308\n//! # use std::iter::{empty, once};\n//! // This won't compile because all possible returns from the function\n//! // must have the same concrete type.\n//! fn make_iter(do_insert: bool) -> impl Iterator {\n//! // Explicit returns to illustrate return types not matching\n//! match do_insert {\n//! true => return (0..4).chain(once(42)).chain(4..8),\n//! false => return (0..4).chain(empty()).chain(4..8),\n//! }\n//! }\n//! ```\n//!\n//! ## Collecting into `Option`\n//!\n//! [`Option`] implements the [`FromIterator`][impl-FromIterator] trait,\n//! which allows an iterator over [`Option`] values to be collected into an\n//! [`Option`] of a collection of each contained value of the original\n//! [`Option`] values, or [`None`] if any of the elements was [`None`].\n//!\n//! [impl-FromIterator]: Option#impl-FromIterator%3COption%3CA%3E%3E\n//!\n//! ```\n//! let v = [Some(2), Some(4), None, Some(8)];\n//! let res: Option> = v.into_iter().collect();\n//! assert_eq!(res, None);\n//! let v = [Some(2), Some(4), Some(8)];\n//! let res: Option> = v.into_iter().collect();\n//! assert_eq!(res, Some(vec![2, 4, 8]));\n//! ```\n//!\n//! [`Option`] also implements the [`Product`][impl-Product] and\n//! [`Sum`][impl-Sum] traits, allowing an iterator over [`Option`] values\n//! to provide the [`product`][Iterator::product] and\n//! [`sum`][Iterator::sum] methods.\n//!\n//! [impl-Product]: Option#impl-Product%3COption%3CU%3E%3E\n//! [impl-Sum]: Option#impl-Sum%3COption%3CU%3E%3E\n//!\n//! ```\n//! let v = [None, Some(1), Some(2), Some(3)];\n//! let res: Option = v.into_iter().sum();\n//! assert_eq!(res, None);\n//! let v = [Some(1), Some(2), Some(21)];\n//! let res: Option = v.into_iter().product();\n//! assert_eq!(res, Some(42));\n//! ```\n//!\n//! ## Modifying an [`Option`] in-place\n//!\n//! These methods return a mutable reference to the contained value of an\n//! [`Option`]:\n//!\n//! * [`insert`] inserts a value, dropping any old contents\n//! * [`get_or_insert`] gets the current value, inserting a provided\n//! default value if it is [`None`]\n//! * [`get_or_insert_default`] gets the current value, inserting the\n//! default value of type `T` (which must implement [`Default`]) if it is\n//! [`None`]\n//! * [`get_or_insert_with`] gets the current value, inserting a default\n//! computed by the provided function if it is [`None`]\n//!\n//! [`get_or_insert`]: Option::get_or_insert\n//! [`get_or_insert_default`]: Option::get_or_insert_default\n//! [`get_or_insert_with`]: Option::get_or_insert_with\n//! [`insert`]: Option::insert\n//!\n//! These methods transfer ownership of the contained value of an\n//! [`Option`]:\n//!\n//! * [`take`] takes ownership of the contained value of an [`Option`], if\n//! any, replacing the [`Option`] with [`None`]\n//! * [`replace`] takes ownership of the contained value of an [`Option`],\n//! if any, replacing the [`Option`] with a [`Some`] containing the\n//! provided value\n//!\n//! [`replace`]: Option::replace\n//! [`take`]: Option::take\n//!\n//! # Examples\n//!\n//! Basic pattern matching on [`Option`]:\n//!\n//! ```\n//! let msg = Some(\"howdy\");\n//!\n//! // Take a reference to the contained string\n//! if let Some(m) = &msg {\n//! println!(\"{}\", *m);\n//! }\n//!\n//! // Remove the contained string, destroying the Option\n//! let unwrapped_msg = msg.unwrap_or(\"default message\");\n//! ```\n//!\n//! Initialize a result to [`None`] before a loop:\n//!\n//! ```\n//! enum Kingdom { Plant(u32, &'static str), Animal(u32, &'static str) }\n//!\n//! // A list of data to search through.\n//! let all_the_big_things = [\n//! Kingdom::Plant(250, \"redwood\"),\n//! Kingdom::Plant(230, \"noble fir\"),\n//! Kingdom::Plant(229, \"sugar pine\"),\n//! Kingdom::Animal(25, \"blue whale\"),\n//! Kingdom::Animal(19, \"fin whale\"),\n//! Kingdom::Animal(15, \"north pacific right whale\"),\n//! ];\n//!\n//! // We're going to search for the name of the biggest animal,\n//! // but to start with we've just got `None`.\n//! let mut name_of_biggest_animal = None;\n//! let mut size_of_biggest_animal = 0;\n//! for big_thing in &all_the_big_things {\n//! match *big_thing {\n//! Kingdom::Animal(size, name) if size > size_of_biggest_animal => {\n//! // Now we've found the name of some big animal\n//! size_of_biggest_animal = size;\n//! name_of_biggest_animal = Some(name);\n//! }\n//! Kingdom::Animal(..) | Kingdom::Plant(..) => ()\n//! }\n//! }\n//!\n//! match name_of_biggest_animal {\n//! Some(name) => println!(\"the biggest animal is {name}\"),\n//! None => println!(\"there are no animals :(\"),\n//! }\n//! ```\n\n#![stable(feature = \"rust1\", since = \"1.0.0\")]\n\nuse crate::iter::{self, FromIterator, FusedIterator, TrustedLen};\nuse crate::marker::Destruct;\nuse crate::panicking::{panic, panic_str};\nuse crate::pin::Pin;\nuse crate::{\n convert, hint, mem,\n ops::{self, ControlFlow, Deref, DerefMut},\n};\n\n/// The `Option` type. See [the module level documentation](self) for more.\n#[derive(Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]\n#[rustc_diagnostic_item = \"Option\"]\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\npub enum Option {\n /// No value.\n #[lang = \"None\"]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n None,\n /// Some value of type `T`.\n #[lang = \"Some\"]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n Some(#[stable(feature = \"rust1\", since = \"1.0.0\")] T),\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// Type implementation\n/////////////////////////////////////////////////////////////////////////////\n\nimpl Option {\n /////////////////////////////////////////////////////////////////////////\n // Querying the contained values\n /////////////////////////////////////////////////////////////////////////\n\n /// Returns `true` if the option is a [`Some`] value.\n ///\n /// # Examples\n ///\n /// ```\n /// let x: Option = Some(2);\n /// assert_eq!(x.is_some(), true);\n ///\n /// let x: Option = None;\n /// assert_eq!(x.is_some(), false);\n /// ```\n #[must_use = \"if you intended to assert that this has a value, consider `.unwrap()` instead\"]\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_stable(feature = \"const_option_basics\", since = \"1.48.0\")]\n pub const fn is_some(&self) -> bool {\n matches!(*self, Some(_))\n }\n\n /// Returns `true` if the option is a [`Some`] and the value inside of it matches a predicate.\n ///\n /// # Examples\n ///\n /// ```\n /// #![feature(is_some_with)]\n ///\n /// let x: Option = Some(2);\n /// assert_eq!(x.is_some_and(|&x| x > 1), true);\n ///\n /// let x: Option = Some(0);\n /// assert_eq!(x.is_some_and(|&x| x > 1), false);\n ///\n /// let x: Option = None;\n /// assert_eq!(x.is_some_and(|&x| x > 1), false);\n /// ```\n #[must_use]\n #[inline]\n #[unstable(feature = \"is_some_with\", issue = \"93050\")]\n pub fn is_some_and(&self, f: impl FnOnce(&T) -> bool) -> bool {\n matches!(self, Some(x) if f(x))\n }\n\n /// Returns `true` if the option is a [`None`] value.\n ///\n /// # Examples\n ///\n /// ```\n /// let x: Option = Some(2);\n /// assert_eq!(x.is_none(), false);\n ///\n /// let x: Option = None;\n /// assert_eq!(x.is_none(), true);\n /// ```\n #[must_use = \"if you intended to assert that this doesn't have a value, consider \\\n `.and_then(|_| panic!(\\\"`Option` had a value when expected `None`\\\"))` instead\"]\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_stable(feature = \"const_option_basics\", since = \"1.48.0\")]\n pub const fn is_none(&self) -> bool {\n !self.is_some()\n }\n\n /////////////////////////////////////////////////////////////////////////\n // Adapter for working with references\n /////////////////////////////////////////////////////////////////////////\n\n /// Converts from `&Option` to `Option<&T>`.\n ///\n /// # Examples\n ///\n /// Converts an Option<[String]> into an Option<[usize]>, preserving\n /// the original. The [`map`] method takes the `self` argument by value, consuming the original,\n /// so this technique uses `as_ref` to first take an `Option` to a reference\n /// to the value inside the original.\n ///\n /// [`map`]: Option::map\n /// [String]: ../../std/string/struct.String.html \"String\"\n ///\n /// ```\n /// let text: Option = Some(\"Hello, world!\".to_string());\n /// // First, cast `Option` to `Option<&String>` with `as_ref`,\n /// // then consume *that* with `map`, leaving `text` on the stack.\n /// let text_length: Option = text.as_ref().map(|s| s.len());\n /// println!(\"still can print text: {text:?}\");\n /// ```\n #[inline]\n #[rustc_const_stable(feature = \"const_option_basics\", since = \"1.48.0\")]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n pub const fn as_ref(&self) -> Option<&T> {\n match *self {\n Some(ref x) => Some(x),\n None => None,\n }\n }\n\n /// Converts from `&mut Option` to `Option<&mut T>`.\n ///\n /// # Examples\n ///\n /// ```\n /// let mut x = Some(2);\n /// match x.as_mut() {\n /// Some(v) => *v = 42,\n /// None => {},\n /// }\n /// assert_eq!(x, Some(42));\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]\n pub const fn as_mut(&mut self) -> Option<&mut T> {\n match *self {\n Some(ref mut x) => Some(x),\n None => None,\n }\n }\n\n /// Converts from [Pin]<[&]Option\\> to Option<[Pin]<[&]T>>.\n ///\n /// [&]: reference \"shared reference\"\n #[inline]\n #[must_use]\n #[stable(feature = \"pin\", since = \"1.33.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn as_pin_ref(self: Pin<&Self>) -> Option> {\n match Pin::get_ref(self).as_ref() {\n // SAFETY: `x` is guaranteed to be pinned because it comes from `self`\n // which is pinned.\n Some(x) => unsafe { Some(Pin::new_unchecked(x)) },\n None => None,\n }\n }\n\n /// Converts from [Pin]<[&mut] Option\\> to Option<[Pin]<[&mut] T>>.\n ///\n /// [&mut]: reference \"mutable reference\"\n #[inline]\n #[must_use]\n #[stable(feature = \"pin\", since = \"1.33.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn as_pin_mut(self: Pin<&mut Self>) -> Option> {\n // SAFETY: `get_unchecked_mut` is never used to move the `Option` inside `self`.\n // `x` is guaranteed to be pinned because it comes from `self` which is pinned.\n unsafe {\n match Pin::get_unchecked_mut(self).as_mut() {\n Some(x) => Some(Pin::new_unchecked(x)),\n None => None,\n }\n }\n }\n\n /////////////////////////////////////////////////////////////////////////\n // Getting to contained values\n /////////////////////////////////////////////////////////////////////////\n\n /// Returns the contained [`Some`] value, consuming the `self` value.\n ///\n /// # Panics\n ///\n /// Panics if the value is a [`None`] with a custom panic message provided by\n /// `msg`.\n ///\n /// # Examples\n ///\n /// ```\n /// let x = Some(\"value\");\n /// assert_eq!(x.expect(\"fruits are healthy\"), \"value\");\n /// ```\n ///\n /// ```should_panic\n /// let x: Option<&str> = None;\n /// x.expect(\"fruits are healthy\"); // panics with `fruits are healthy`\n /// ```\n ///\n /// # Recommended Message Style\n ///\n /// We recommend that `expect` messages are used to describe the reason you\n /// _expect_ the `Option` should be `Some`.\n ///\n /// ```should_panic\n /// # let slice: &[u8] = &[];\n /// let item = slice.get(0)\n /// .expect(\"slice should not be empty\");\n /// ```\n ///\n /// **Hint**: If you're having trouble remembering how to phrase expect\n /// error messages remember to focus on the word \"should\" as in \"env\n /// variable should be set by blah\" or \"the given binary should be available\n /// and executable by the current user\".\n ///\n /// For more detail on expect message styles and the reasoning behind our\n /// recommendation please refer to the section on [\"Common Message\n /// Styles\"](../../std/error/index.html#common-message-styles) in the [`std::error`](../../std/error/index.html) module docs.\n #[inline]\n #[track_caller]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]\n pub const fn expect(self, msg: &str) -> T {\n match self {\n Some(val) => val,\n None => expect_failed(msg),\n }\n }\n\n /// Returns the contained [`Some`] value, consuming the `self` value.\n ///\n /// Because this function may panic, its use is generally discouraged.\n /// Instead, prefer to use pattern matching and handle the [`None`]\n /// case explicitly, or call [`unwrap_or`], [`unwrap_or_else`], or\n /// [`unwrap_or_default`].\n ///\n /// [`unwrap_or`]: Option::unwrap_or\n /// [`unwrap_or_else`]: Option::unwrap_or_else\n /// [`unwrap_or_default`]: Option::unwrap_or_default\n ///\n /// # Panics\n ///\n /// Panics if the self value equals [`None`].\n ///\n /// # Examples\n ///\n /// ```\n /// let x = Some(\"air\");\n /// assert_eq!(x.unwrap(), \"air\");\n /// ```\n ///\n /// ```should_panic\n /// let x: Option<&str> = None;\n /// assert_eq!(x.unwrap(), \"air\"); // fails\n /// ```\n #[inline]\n #[track_caller]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]\n pub const fn unwrap(self) -> T {\n match self {\n Some(val) => val,\n None => panic(\"called `Option::unwrap()` on a `None` value\"),\n }\n }\n\n /// Returns the contained [`Some`] value or a provided default.\n ///\n /// Arguments passed to `unwrap_or` are eagerly evaluated; if you are passing\n /// the result of a function call, it is recommended to use [`unwrap_or_else`],\n /// which is lazily evaluated.\n ///\n /// [`unwrap_or_else`]: Option::unwrap_or_else\n ///\n /// # Examples\n ///\n /// ```\n /// assert_eq!(Some(\"car\").unwrap_or(\"bike\"), \"car\");\n /// assert_eq!(None.unwrap_or(\"bike\"), \"bike\");\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn unwrap_or(self, default: T) -> T\n where\n T: ~const Destruct,\n {\n match self {\n Some(x) => x,\n None => default,\n }\n }\n\n /// Returns the contained [`Some`] value or computes it from a closure.\n ///\n /// # Examples\n ///\n /// ```\n /// let k = 10;\n /// assert_eq!(Some(4).unwrap_or_else(|| 2 * k), 4);\n /// assert_eq!(None.unwrap_or_else(|| 2 * k), 20);\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn unwrap_or_else(self, f: F) -> T\n where\n F: ~const FnOnce() -> T,\n F: ~const Destruct,\n {\n match self {\n Some(x) => x,\n None => f(),\n }\n }\n\n /// Returns the contained [`Some`] value or a default.\n ///\n /// Consumes the `self` argument then, if [`Some`], returns the contained\n /// value, otherwise if [`None`], returns the [default value] for that\n /// type.\n ///\n /// # Examples\n ///\n /// Converts a string to an integer, turning poorly-formed strings\n /// into 0 (the default value for integers). [`parse`] converts\n /// a string to any other type that implements [`FromStr`], returning\n /// [`None`] on error.\n ///\n /// ```\n /// let good_year_from_input = \"1909\";\n /// let bad_year_from_input = \"190blarg\";\n /// let good_year = good_year_from_input.parse().ok().unwrap_or_default();\n /// let bad_year = bad_year_from_input.parse().ok().unwrap_or_default();\n ///\n /// assert_eq!(1909, good_year);\n /// assert_eq!(0, bad_year);\n /// ```\n ///\n /// [default value]: Default::default\n /// [`parse`]: str::parse\n /// [`FromStr`]: crate::str::FromStr\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn unwrap_or_default(self) -> T\n where\n T: ~const Default,\n {\n match self {\n Some(x) => x,\n None => Default::default(),\n }\n }\n\n /// Returns the contained [`Some`] value, consuming the `self` value,\n /// without checking that the value is not [`None`].\n ///\n /// # Safety\n ///\n /// Calling this method on [`None`] is *[undefined behavior]*.\n ///\n /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html\n ///\n /// # Examples\n ///\n /// ```\n /// let x = Some(\"air\");\n /// assert_eq!(unsafe { x.unwrap_unchecked() }, \"air\");\n /// ```\n ///\n /// ```no_run\n /// let x: Option<&str> = None;\n /// assert_eq!(unsafe { x.unwrap_unchecked() }, \"air\"); // Undefined behavior!\n /// ```\n #[inline]\n #[track_caller]\n #[stable(feature = \"option_result_unwrap_unchecked\", since = \"1.58.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const unsafe fn unwrap_unchecked(self) -> T {\n debug_assert!(self.is_some());\n match self {\n Some(val) => val,\n // SAFETY: the safety contract must be upheld by the caller.\n None => unsafe { hint::unreachable_unchecked() },\n }\n }\n\n /////////////////////////////////////////////////////////////////////////\n // Transforming contained values\n /////////////////////////////////////////////////////////////////////////\n\n /// Maps an `Option` to `Option` by applying a function to a contained value.\n ///\n /// # Examples\n ///\n /// Converts an Option<[String]> into an Option<[usize]>, consuming\n /// the original:\n ///\n /// [String]: ../../std/string/struct.String.html \"String\"\n /// ```\n /// let maybe_some_string = Some(String::from(\"Hello, World!\"));\n /// // `Option::map` takes self *by value*, consuming `maybe_some_string`\n /// let maybe_some_len = maybe_some_string.map(|s| s.len());\n ///\n /// assert_eq!(maybe_some_len, Some(13));\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn map(self, f: F) -> Option\n where\n F: ~const FnOnce(T) -> U,\n F: ~const Destruct,\n {\n match self {\n Some(x) => Some(f(x)),\n None => None,\n }\n }\n\n /// Calls the provided closure with a reference to the contained value (if [`Some`]).\n ///\n /// # Examples\n ///\n /// ```\n /// #![feature(result_option_inspect)]\n ///\n /// let v = vec![1, 2, 3, 4, 5];\n ///\n /// // prints \"got: 4\"\n /// let x: Option<&usize> = v.get(3).inspect(|x| println!(\"got: {x}\"));\n ///\n /// // prints nothing\n /// let x: Option<&usize> = v.get(5).inspect(|x| println!(\"got: {x}\"));\n /// ```\n #[inline]\n #[unstable(feature = \"result_option_inspect\", issue = \"91345\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn inspect(self, f: F) -> Self\n where\n F: ~const FnOnce(&T),\n F: ~const Destruct,\n {\n if let Some(ref x) = self {\n f(x);\n }\n\n self\n }\n\n /// Returns the provided default result (if none),\n /// or applies a function to the contained value (if any).\n ///\n /// Arguments passed to `map_or` are eagerly evaluated; if you are passing\n /// the result of a function call, it is recommended to use [`map_or_else`],\n /// which is lazily evaluated.\n ///\n /// [`map_or_else`]: Option::map_or_else\n ///\n /// # Examples\n ///\n /// ```\n /// let x = Some(\"foo\");\n /// assert_eq!(x.map_or(42, |v| v.len()), 3);\n ///\n /// let x: Option<&str> = None;\n /// assert_eq!(x.map_or(42, |v| v.len()), 42);\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn map_or(self, default: U, f: F) -> U\n where\n F: ~const FnOnce(T) -> U,\n F: ~const Destruct,\n U: ~const Destruct,\n {\n match self {\n Some(t) => f(t),\n None => default,\n }\n }\n\n /// Computes a default function result (if none), or\n /// applies a different function to the contained value (if any).\n ///\n /// # Examples\n ///\n /// ```\n /// let k = 21;\n ///\n /// let x = Some(\"foo\");\n /// assert_eq!(x.map_or_else(|| 2 * k, |v| v.len()), 3);\n ///\n /// let x: Option<&str> = None;\n /// assert_eq!(x.map_or_else(|| 2 * k, |v| v.len()), 42);\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn map_or_else(self, default: D, f: F) -> U\n where\n D: ~const FnOnce() -> U,\n D: ~const Destruct,\n F: ~const FnOnce(T) -> U,\n F: ~const Destruct,\n {\n match self {\n Some(t) => f(t),\n None => default(),\n }\n }\n\n /// Transforms the `Option` into a [`Result`], mapping [`Some(v)`] to\n /// [`Ok(v)`] and [`None`] to [`Err(err)`].\n ///\n /// Arguments passed to `ok_or` are eagerly evaluated; if you are passing the\n /// result of a function call, it is recommended to use [`ok_or_else`], which is\n /// lazily evaluated.\n ///\n /// [`Ok(v)`]: Ok\n /// [`Err(err)`]: Err\n /// [`Some(v)`]: Some\n /// [`ok_or_else`]: Option::ok_or_else\n ///\n /// # Examples\n ///\n /// ```\n /// let x = Some(\"foo\");\n /// assert_eq!(x.ok_or(0), Ok(\"foo\"));\n ///\n /// let x: Option<&str> = None;\n /// assert_eq!(x.ok_or(0), Err(0));\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn ok_or(self, err: E) -> Result\n where\n E: ~const Destruct,\n {\n match self {\n Some(v) => Ok(v),\n None => Err(err),\n }\n }\n\n /// Transforms the `Option` into a [`Result`], mapping [`Some(v)`] to\n /// [`Ok(v)`] and [`None`] to [`Err(err())`].\n ///\n /// [`Ok(v)`]: Ok\n /// [`Err(err())`]: Err\n /// [`Some(v)`]: Some\n ///\n /// # Examples\n ///\n /// ```\n /// let x = Some(\"foo\");\n /// assert_eq!(x.ok_or_else(|| 0), Ok(\"foo\"));\n ///\n /// let x: Option<&str> = None;\n /// assert_eq!(x.ok_or_else(|| 0), Err(0));\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn ok_or_else(self, err: F) -> Result\n where\n F: ~const FnOnce() -> E,\n F: ~const Destruct,\n {\n match self {\n Some(v) => Ok(v),\n None => Err(err()),\n }\n }\n\n /// Converts from `Option` (or `&Option`) to `Option<&T::Target>`.\n ///\n /// Leaves the original Option in-place, creating a new one with a reference\n /// to the original one, additionally coercing the contents via [`Deref`].\n ///\n /// # Examples\n ///\n /// ```\n /// let x: Option = Some(\"hey\".to_owned());\n /// assert_eq!(x.as_deref(), Some(\"hey\"));\n ///\n /// let x: Option = None;\n /// assert_eq!(x.as_deref(), None);\n /// ```\n #[stable(feature = \"option_deref\", since = \"1.40.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn as_deref(&self) -> Option<&T::Target>\n where\n T: ~const Deref,\n {\n match self.as_ref() {\n Some(t) => Some(t.deref()),\n None => None,\n }\n }\n\n /// Converts from `Option` (or `&mut Option`) to `Option<&mut T::Target>`.\n ///\n /// Leaves the original `Option` in-place, creating a new one containing a mutable reference to\n /// the inner type's [`Deref::Target`] type.\n ///\n /// # Examples\n ///\n /// ```\n /// let mut x: Option = Some(\"hey\".to_owned());\n /// assert_eq!(x.as_deref_mut().map(|x| {\n /// x.make_ascii_uppercase();\n /// x\n /// }), Some(\"HEY\".to_owned().as_mut_str()));\n /// ```\n #[stable(feature = \"option_deref\", since = \"1.40.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn as_deref_mut(&mut self) -> Option<&mut T::Target>\n where\n T: ~const DerefMut,\n {\n match self.as_mut() {\n Some(t) => Some(t.deref_mut()),\n None => None,\n }\n }\n\n /////////////////////////////////////////////////////////////////////////\n // Iterator constructors\n /////////////////////////////////////////////////////////////////////////\n\n /// Returns an iterator over the possibly contained value.\n ///\n /// # Examples\n ///\n /// ```\n /// let x = Some(4);\n /// assert_eq!(x.iter().next(), Some(&4));\n ///\n /// let x: Option = None;\n /// assert_eq!(x.iter().next(), None);\n /// ```\n #[inline]\n #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n pub const fn iter(&self) -> Iter<'_, T> {\n Iter { inner: Item { opt: self.as_ref() } }\n }\n\n /// Returns a mutable iterator over the possibly contained value.\n ///\n /// # Examples\n ///\n /// ```\n /// let mut x = Some(4);\n /// match x.iter_mut().next() {\n /// Some(v) => *v = 42,\n /// None => {},\n /// }\n /// assert_eq!(x, Some(42));\n ///\n /// let mut x: Option = None;\n /// assert_eq!(x.iter_mut().next(), None);\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n pub fn iter_mut(&mut self) -> IterMut<'_, T> {\n IterMut { inner: Item { opt: self.as_mut() } }\n }\n\n /////////////////////////////////////////////////////////////////////////\n // Boolean operations on the values, eager and lazy\n /////////////////////////////////////////////////////////////////////////\n\n /// Returns [`None`] if the option is [`None`], otherwise returns `optb`.\n ///\n /// # Examples\n ///\n /// ```\n /// let x = Some(2);\n /// let y: Option<&str> = None;\n /// assert_eq!(x.and(y), None);\n ///\n /// let x: Option = None;\n /// let y = Some(\"foo\");\n /// assert_eq!(x.and(y), None);\n ///\n /// let x = Some(2);\n /// let y = Some(\"foo\");\n /// assert_eq!(x.and(y), Some(\"foo\"));\n ///\n /// let x: Option = None;\n /// let y: Option<&str> = None;\n /// assert_eq!(x.and(y), None);\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn and(self, optb: Option) -> Option\n where\n T: ~const Destruct,\n U: ~const Destruct,\n {\n match self {\n Some(_) => optb,\n None => None,\n }\n }\n\n /// Returns [`None`] if the option is [`None`], otherwise calls `f` with the\n /// wrapped value and returns the result.\n ///\n /// Some languages call this operation flatmap.\n ///\n /// # Examples\n ///\n /// ```\n /// fn sq_then_to_string(x: u32) -> Option {\n /// x.checked_mul(x).map(|sq| sq.to_string())\n /// }\n ///\n /// assert_eq!(Some(2).and_then(sq_then_to_string), Some(4.to_string()));\n /// assert_eq!(Some(1_000_000).and_then(sq_then_to_string), None); // overflowed!\n /// assert_eq!(None.and_then(sq_then_to_string), None);\n /// ```\n ///\n /// Often used to chain fallible operations that may return [`None`].\n ///\n /// ```\n /// let arr_2d = [[\"A0\", \"A1\"], [\"B0\", \"B1\"]];\n ///\n /// let item_0_1 = arr_2d.get(0).and_then(|row| row.get(1));\n /// assert_eq!(item_0_1, Some(&\"A1\"));\n ///\n /// let item_2_0 = arr_2d.get(2).and_then(|row| row.get(0));\n /// assert_eq!(item_2_0, None);\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn and_then(self, f: F) -> Option\n where\n F: ~const FnOnce(T) -> Option,\n F: ~const Destruct,\n {\n match self {\n Some(x) => f(x),\n None => None,\n }\n }\n\n /// Returns [`None`] if the option is [`None`], otherwise calls `predicate`\n /// with the wrapped value and returns:\n ///\n /// - [`Some(t)`] if `predicate` returns `true` (where `t` is the wrapped\n /// value), and\n /// - [`None`] if `predicate` returns `false`.\n ///\n /// This function works similar to [`Iterator::filter()`]. You can imagine\n /// the `Option` being an iterator over one or zero elements. `filter()`\n /// lets you decide which elements to keep.\n ///\n /// # Examples\n ///\n /// ```rust\n /// fn is_even(n: &i32) -> bool {\n /// n % 2 == 0\n /// }\n ///\n /// assert_eq!(None.filter(is_even), None);\n /// assert_eq!(Some(3).filter(is_even), None);\n /// assert_eq!(Some(4).filter(is_even), Some(4));\n /// ```\n ///\n /// [`Some(t)`]: Some\n #[inline]\n #[stable(feature = \"option_filter\", since = \"1.27.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn filter

(self, predicate: P) -> Self\n where\n T: ~const Destruct,\n P: ~const FnOnce(&T) -> bool,\n P: ~const Destruct,\n {\n if let Some(x) = self {\n if predicate(&x) {\n return Some(x);\n }\n }\n None\n }\n\n /// Returns the option if it contains a value, otherwise returns `optb`.\n ///\n /// Arguments passed to `or` are eagerly evaluated; if you are passing the\n /// result of a function call, it is recommended to use [`or_else`], which is\n /// lazily evaluated.\n ///\n /// [`or_else`]: Option::or_else\n ///\n /// # Examples\n ///\n /// ```\n /// let x = Some(2);\n /// let y = None;\n /// assert_eq!(x.or(y), Some(2));\n ///\n /// let x = None;\n /// let y = Some(100);\n /// assert_eq!(x.or(y), Some(100));\n ///\n /// let x = Some(2);\n /// let y = Some(100);\n /// assert_eq!(x.or(y), Some(2));\n ///\n /// let x: Option = None;\n /// let y = None;\n /// assert_eq!(x.or(y), None);\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn or(self, optb: Option) -> Option\n where\n T: ~const Destruct,\n {\n match self {\n Some(x) => Some(x),\n None => optb,\n }\n }\n\n /// Returns the option if it contains a value, otherwise calls `f` and\n /// returns the result.\n ///\n /// # Examples\n ///\n /// ```\n /// fn nobody() -> Option<&'static str> { None }\n /// fn vikings() -> Option<&'static str> { Some(\"vikings\") }\n ///\n /// assert_eq!(Some(\"barbarians\").or_else(vikings), Some(\"barbarians\"));\n /// assert_eq!(None.or_else(vikings), Some(\"vikings\"));\n /// assert_eq!(None.or_else(nobody), None);\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn or_else(self, f: F) -> Option\n where\n F: ~const FnOnce() -> Option,\n F: ~const Destruct,\n {\n match self {\n Some(x) => Some(x),\n None => f(),\n }\n }\n\n /// Returns [`Some`] if exactly one of `self`, `optb` is [`Some`], otherwise returns [`None`].\n ///\n /// # Examples\n ///\n /// ```\n /// let x = Some(2);\n /// let y: Option = None;\n /// assert_eq!(x.xor(y), Some(2));\n ///\n /// let x: Option = None;\n /// let y = Some(2);\n /// assert_eq!(x.xor(y), Some(2));\n ///\n /// let x = Some(2);\n /// let y = Some(2);\n /// assert_eq!(x.xor(y), None);\n ///\n /// let x: Option = None;\n /// let y: Option = None;\n /// assert_eq!(x.xor(y), None);\n /// ```\n #[inline]\n #[stable(feature = \"option_xor\", since = \"1.37.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn xor(self, optb: Option) -> Option\n where\n T: ~const Destruct,\n {\n match (self, optb) {\n (Some(a), None) => Some(a),\n (None, Some(b)) => Some(b),\n _ => None,\n }\n }\n\n /////////////////////////////////////////////////////////////////////////\n // Entry-like operations to insert a value and return a reference\n /////////////////////////////////////////////////////////////////////////\n\n /// Inserts `value` into the option, then returns a mutable reference to it.\n ///\n /// If the option already contains a value, the old value is dropped.\n ///\n /// See also [`Option::get_or_insert`], which doesn't update the value if\n /// the option already contains [`Some`].\n ///\n /// # Example\n ///\n /// ```\n /// let mut opt = None;\n /// let val = opt.insert(1);\n /// assert_eq!(*val, 1);\n /// assert_eq!(opt.unwrap(), 1);\n /// let val = opt.insert(2);\n /// assert_eq!(*val, 2);\n /// *val = 3;\n /// assert_eq!(opt.unwrap(), 3);\n /// ```\n #[must_use = \"if you intended to set a value, consider assignment instead\"]\n #[inline]\n #[stable(feature = \"option_insert\", since = \"1.53.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn insert(&mut self, value: T) -> &mut T\n where\n T: ~const Destruct,\n {\n *self = Some(value);\n\n // SAFETY: the code above just filled the option\n unsafe { self.as_mut().unwrap_unchecked() }\n }\n\n /// Inserts `value` into the option if it is [`None`], then\n /// returns a mutable reference to the contained value.\n ///\n /// See also [`Option::insert`], which updates the value even if\n /// the option already contains [`Some`].\n ///\n /// # Examples\n ///\n /// ```\n /// let mut x = None;\n ///\n /// {\n /// let y: &mut u32 = x.get_or_insert(5);\n /// assert_eq!(y, &5);\n ///\n /// *y = 7;\n /// }\n ///\n /// assert_eq!(x, Some(7));\n /// ```\n #[inline]\n #[stable(feature = \"option_entry\", since = \"1.20.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn get_or_insert(&mut self, value: T) -> &mut T\n where\n T: ~const Destruct,\n {\n if let None = *self {\n *self = Some(value);\n }\n\n // SAFETY: a `None` variant for `self` would have been replaced by a `Some`\n // variant in the code above.\n unsafe { self.as_mut().unwrap_unchecked() }\n }\n\n /// Inserts the default value into the option if it is [`None`], then\n /// returns a mutable reference to the contained value.\n ///\n /// # Examples\n ///\n /// ```\n /// #![feature(option_get_or_insert_default)]\n ///\n /// let mut x = None;\n ///\n /// {\n /// let y: &mut u32 = x.get_or_insert_default();\n /// assert_eq!(y, &0);\n ///\n /// *y = 7;\n /// }\n ///\n /// assert_eq!(x, Some(7));\n /// ```\n #[inline]\n #[unstable(feature = \"option_get_or_insert_default\", issue = \"82901\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn get_or_insert_default(&mut self) -> &mut T\n where\n T: ~const Default,\n {\n const fn default() -> T {\n T::default()\n }\n\n self.get_or_insert_with(default)\n }\n\n /// Inserts a value computed from `f` into the option if it is [`None`],\n /// then returns a mutable reference to the contained value.\n ///\n /// # Examples\n ///\n /// ```\n /// let mut x = None;\n ///\n /// {\n /// let y: &mut u32 = x.get_or_insert_with(|| 5);\n /// assert_eq!(y, &5);\n ///\n /// *y = 7;\n /// }\n ///\n /// assert_eq!(x, Some(7));\n /// ```\n #[inline]\n #[stable(feature = \"option_entry\", since = \"1.20.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn get_or_insert_with(&mut self, f: F) -> &mut T\n where\n F: ~const FnOnce() -> T,\n F: ~const Destruct,\n {\n if let None = *self {\n // the compiler isn't smart enough to know that we are not dropping a `T`\n // here and wants us to ensure `T` can be dropped at compile time.\n mem::forget(mem::replace(self, Some(f())))\n }\n\n // SAFETY: a `None` variant for `self` would have been replaced by a `Some`\n // variant in the code above.\n unsafe { self.as_mut().unwrap_unchecked() }\n }\n\n /////////////////////////////////////////////////////////////////////////\n // Misc\n /////////////////////////////////////////////////////////////////////////\n\n /// Takes the value out of the option, leaving a [`None`] in its place.\n ///\n /// # Examples\n ///\n /// ```\n /// let mut x = Some(2);\n /// let y = x.take();\n /// assert_eq!(x, None);\n /// assert_eq!(y, Some(2));\n ///\n /// let mut x: Option = None;\n /// let y = x.take();\n /// assert_eq!(x, None);\n /// assert_eq!(y, None);\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]\n pub const fn take(&mut self) -> Option {\n // FIXME replace `mem::replace` by `mem::take` when the latter is const ready\n mem::replace(self, None)\n }\n\n /// Replaces the actual value in the option by the value given in parameter,\n /// returning the old value if present,\n /// leaving a [`Some`] in its place without deinitializing either one.\n ///\n /// # Examples\n ///\n /// ```\n /// let mut x = Some(2);\n /// let old = x.replace(5);\n /// assert_eq!(x, Some(5));\n /// assert_eq!(old, Some(2));\n ///\n /// let mut x = None;\n /// let old = x.replace(3);\n /// assert_eq!(x, Some(3));\n /// assert_eq!(old, None);\n /// ```\n #[inline]\n #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]\n #[stable(feature = \"option_replace\", since = \"1.31.0\")]\n pub const fn replace(&mut self, value: T) -> Option {\n mem::replace(self, Some(value))\n }\n\n /// Returns `true` if the option is a [`Some`] value containing the given value.\n ///\n /// # Examples\n ///\n /// ```\n /// #![feature(option_result_contains)]\n ///\n /// let x: Option = Some(2);\n /// assert_eq!(x.contains(&2), true);\n ///\n /// let x: Option = Some(3);\n /// assert_eq!(x.contains(&2), false);\n ///\n /// let x: Option = None;\n /// assert_eq!(x.contains(&2), false);\n /// ```\n #[must_use]\n #[inline]\n #[unstable(feature = \"option_result_contains\", issue = \"62358\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn contains(&self, x: &U) -> bool\n where\n U: ~const PartialEq,\n {\n match self {\n Some(y) => x.eq(y),\n None => false,\n }\n }\n\n /// Zips `self` with another `Option`.\n ///\n /// If `self` is `Some(s)` and `other` is `Some(o)`, this method returns `Some((s, o))`.\n /// Otherwise, `None` is returned.\n ///\n /// # Examples\n ///\n /// ```\n /// let x = Some(1);\n /// let y = Some(\"hi\");\n /// let z = None::;\n ///\n /// assert_eq!(x.zip(y), Some((1, \"hi\")));\n /// assert_eq!(x.zip(z), None);\n /// ```\n #[stable(feature = \"option_zip_option\", since = \"1.46.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn zip(self, other: Option) -> Option<(T, U)>\n where\n T: ~const Destruct,\n U: ~const Destruct,\n {\n match (self, other) {\n (Some(a), Some(b)) => Some((a, b)),\n _ => None,\n }\n }\n\n /// Zips `self` and another `Option` with function `f`.\n ///\n /// If `self` is `Some(s)` and `other` is `Some(o)`, this method returns `Some(f(s, o))`.\n /// Otherwise, `None` is returned.\n ///\n /// # Examples\n ///\n /// ```\n /// #![feature(option_zip)]\n ///\n /// #[derive(Debug, PartialEq)]\n /// struct Point {\n /// x: f64,\n /// y: f64,\n /// }\n ///\n /// impl Point {\n /// fn new(x: f64, y: f64) -> Self {\n /// Self { x, y }\n /// }\n /// }\n ///\n /// let x = Some(17.5);\n /// let y = Some(42.7);\n ///\n /// assert_eq!(x.zip_with(y, Point::new), Some(Point { x: 17.5, y: 42.7 }));\n /// assert_eq!(x.zip_with(None, Point::new), None);\n /// ```\n #[unstable(feature = \"option_zip\", issue = \"70086\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn zip_with(self, other: Option, f: F) -> Option\n where\n F: ~const FnOnce(T, U) -> R,\n F: ~const Destruct,\n T: ~const Destruct,\n U: ~const Destruct,\n {\n match (self, other) {\n (Some(a), Some(b)) => Some(f(a, b)),\n _ => None,\n }\n }\n}\n\nimpl Option<(T, U)> {\n /// Unzips an option containing a tuple of two options.\n ///\n /// If `self` is `Some((a, b))` this method returns `(Some(a), Some(b))`.\n /// Otherwise, `(None, None)` is returned.\n ///\n /// # Examples\n ///\n /// ```\n /// #![feature(unzip_option)]\n ///\n /// let x = Some((1, \"hi\"));\n /// let y = None::<(u8, u32)>;\n ///\n /// assert_eq!(x.unzip(), (Some(1), Some(\"hi\")));\n /// assert_eq!(y.unzip(), (None, None));\n /// ```\n #[inline]\n #[unstable(feature = \"unzip_option\", issue = \"87800\", reason = \"recently added\")]\n pub const fn unzip(self) -> (Option, Option) {\n match self {\n Some((a, b)) => (Some(a), Some(b)),\n None => (None, None),\n }\n }\n}\n\nimpl Option<&T> {\n /// Maps an `Option<&T>` to an `Option` by copying the contents of the\n /// option.\n ///\n /// # Examples\n ///\n /// ```\n /// let x = 12;\n /// let opt_x = Some(&x);\n /// assert_eq!(opt_x, Some(&12));\n /// let copied = opt_x.copied();\n /// assert_eq!(copied, Some(12));\n /// ```\n #[must_use = \"`self` will be dropped if the result is not used\"]\n #[stable(feature = \"copied\", since = \"1.35.0\")]\n #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]\n pub const fn copied(self) -> Option\n where\n T: Copy,\n {\n // FIXME: this implementation, which sidesteps using `Option::map` since it's not const\n // ready yet, should be reverted when possible to avoid code repetition\n match self {\n Some(&v) => Some(v),\n None => None,\n }\n }\n\n /// Maps an `Option<&T>` to an `Option` by cloning the contents of the\n /// option.\n ///\n /// # Examples\n ///\n /// ```\n /// let x = 12;\n /// let opt_x = Some(&x);\n /// assert_eq!(opt_x, Some(&12));\n /// let cloned = opt_x.cloned();\n /// assert_eq!(cloned, Some(12));\n /// ```\n #[must_use = \"`self` will be dropped if the result is not used\"]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_cloned\", issue = \"91582\")]\n pub const fn cloned(self) -> Option\n where\n T: ~const Clone,\n {\n match self {\n Some(t) => Some(t.clone()),\n None => None,\n }\n }\n}\n\nimpl Option<&mut T> {\n /// Maps an `Option<&mut T>` to an `Option` by copying the contents of the\n /// option.\n ///\n /// # Examples\n ///\n /// ```\n /// let mut x = 12;\n /// let opt_x = Some(&mut x);\n /// assert_eq!(opt_x, Some(&mut 12));\n /// let copied = opt_x.copied();\n /// assert_eq!(copied, Some(12));\n /// ```\n #[must_use = \"`self` will be dropped if the result is not used\"]\n #[stable(feature = \"copied\", since = \"1.35.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn copied(self) -> Option\n where\n T: Copy,\n {\n match self {\n Some(&mut t) => Some(t),\n None => None,\n }\n }\n\n /// Maps an `Option<&mut T>` to an `Option` by cloning the contents of the\n /// option.\n ///\n /// # Examples\n ///\n /// ```\n /// let mut x = 12;\n /// let opt_x = Some(&mut x);\n /// assert_eq!(opt_x, Some(&mut 12));\n /// let cloned = opt_x.cloned();\n /// assert_eq!(cloned, Some(12));\n /// ```\n #[must_use = \"`self` will be dropped if the result is not used\"]\n #[stable(since = \"1.26.0\", feature = \"option_ref_mut_cloned\")]\n #[rustc_const_unstable(feature = \"const_option_cloned\", issue = \"91582\")]\n pub const fn cloned(self) -> Option\n where\n T: ~const Clone,\n {\n match self {\n Some(t) => Some(t.clone()),\n None => None,\n }\n }\n}\n\nimpl Option> {\n /// Transposes an `Option` of a [`Result`] into a [`Result`] of an `Option`.\n ///\n /// [`None`] will be mapped to [Ok]\\([None]).\n /// [Some]\\([Ok]\\(\\_)) and [Some]\\([Err]\\(\\_)) will be mapped to\n /// [Ok]\\([Some]\\(\\_)) and [Err]\\(\\_).\n ///\n /// # Examples\n ///\n /// ```\n /// #[derive(Debug, Eq, PartialEq)]\n /// struct SomeErr;\n ///\n /// let x: Result, SomeErr> = Ok(Some(5));\n /// let y: Option> = Some(Ok(5));\n /// assert_eq!(x, y.transpose());\n /// ```\n #[inline]\n #[stable(feature = \"transpose_result\", since = \"1.33.0\")]\n #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]\n pub const fn transpose(self) -> Result, E> {\n match self {\n Some(Ok(x)) => Ok(Some(x)),\n Some(Err(e)) => Err(e),\n None => Ok(None),\n }\n }\n}\n\n// This is a separate function to reduce the code size of .expect() itself.\n#[cfg_attr(not(feature = \"panic_immediate_abort\"), inline(never))]\n#[cfg_attr(feature = \"panic_immediate_abort\", inline)]\n#[cold]\n#[track_caller]\n#[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]\nconst fn expect_failed(msg: &str) -> ! {\n panic_str(msg)\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// Trait implementations\n/////////////////////////////////////////////////////////////////////////////\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\n#[rustc_const_unstable(feature = \"const_clone\", issue = \"91805\")]\nimpl const Clone for Option\nwhere\n T: ~const Clone + ~const Destruct,\n{\n #[inline]\n fn clone(&self) -> Self {\n match self {\n Some(x) => Some(x.clone()),\n None => None,\n }\n }\n\n #[inline]\n fn clone_from(&mut self, source: &Self) {\n match (self, source) {\n (Some(to), Some(from)) => to.clone_from(from),\n (to, from) => *to = from.clone(),\n }\n }\n}\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\n#[rustc_const_unstable(feature = \"const_default_impls\", issue = \"87864\")]\nimpl const Default for Option {\n /// Returns [`None`][Option::None].\n ///\n /// # Examples\n ///\n /// ```\n /// let opt: Option = Option::default();\n /// assert!(opt.is_none());\n /// ```\n #[inline]\n fn default() -> Option {\n None\n }\n}\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\nimpl IntoIterator for Option {\n type Item = T;\n type IntoIter = IntoIter;\n\n /// Returns a consuming iterator over the possibly contained value.\n ///\n /// # Examples\n ///\n /// ```\n /// let x = Some(\"string\");\n /// let v: Vec<&str> = x.into_iter().collect();\n /// assert_eq!(v, [\"string\"]);\n ///\n /// let x = None;\n /// let v: Vec<&str> = x.into_iter().collect();\n /// assert!(v.is_empty());\n /// ```\n #[inline]\n fn into_iter(self) -> IntoIter {\n IntoIter { inner: Item { opt: self } }\n }\n}\n\n#[stable(since = \"1.4.0\", feature = \"option_iter\")]\nimpl<'a, T> IntoIterator for &'a Option {\n type Item = &'a T;\n type IntoIter = Iter<'a, T>;\n\n fn into_iter(self) -> Iter<'a, T> {\n self.iter()\n }\n}\n\n#[stable(since = \"1.4.0\", feature = \"option_iter\")]\nimpl<'a, T> IntoIterator for &'a mut Option {\n type Item = &'a mut T;\n type IntoIter = IterMut<'a, T>;\n\n fn into_iter(self) -> IterMut<'a, T> {\n self.iter_mut()\n }\n}\n\n#[stable(since = \"1.12.0\", feature = \"option_from\")]\n#[rustc_const_unstable(feature = \"const_convert\", issue = \"88674\")]\nimpl const From for Option {\n /// Moves `val` into a new [`Some`].\n ///\n /// # Examples\n ///\n /// ```\n /// let o: Option = Option::from(67);\n ///\n /// assert_eq!(Some(67), o);\n /// ```\n fn from(val: T) -> Option {\n Some(val)\n }\n}\n\n#[stable(feature = \"option_ref_from_ref_option\", since = \"1.30.0\")]\n#[rustc_const_unstable(feature = \"const_convert\", issue = \"88674\")]\nimpl<'a, T> const From<&'a Option> for Option<&'a T> {\n /// Converts from `&Option` to `Option<&T>`.\n ///\n /// # Examples\n ///\n /// Converts an [Option]<[String]> into an [Option]<[usize]>, preserving\n /// the original. The [`map`] method takes the `self` argument by value, consuming the original,\n /// so this technique uses `from` to first take an [`Option`] to a reference\n /// to the value inside the original.\n ///\n /// [`map`]: Option::map\n /// [String]: ../../std/string/struct.String.html \"String\"\n ///\n /// ```\n /// let s: Option = Some(String::from(\"Hello, Rustaceans!\"));\n /// let o: Option = Option::from(&s).map(|ss: &String| ss.len());\n ///\n /// println!(\"Can still print s: {s:?}\");\n ///\n /// assert_eq!(o, Some(18));\n /// ```\n fn from(o: &'a Option) -> Option<&'a T> {\n o.as_ref()\n }\n}\n\n#[stable(feature = \"option_ref_from_ref_option\", since = \"1.30.0\")]\n#[rustc_const_unstable(feature = \"const_convert\", issue = \"88674\")]\nimpl<'a, T> const From<&'a mut Option> for Option<&'a mut T> {\n /// Converts from `&mut Option` to `Option<&mut T>`\n ///\n /// # Examples\n ///\n /// ```\n /// let mut s = Some(String::from(\"Hello\"));\n /// let o: Option<&mut String> = Option::from(&mut s);\n ///\n /// match o {\n /// Some(t) => *t = String::from(\"Hello, Rustaceans!\"),\n /// None => (),\n /// }\n ///\n /// assert_eq!(s, Some(String::from(\"Hello, Rustaceans!\")));\n /// ```\n fn from(o: &'a mut Option) -> Option<&'a mut T> {\n o.as_mut()\n }\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// The Option Iterators\n/////////////////////////////////////////////////////////////////////////////\n\n#[derive(Clone, Debug)]\nstruct Item {\n opt: Option,\n}\n\nimpl Iterator for Item {\n type Item = A;\n\n #[inline]\n fn next(&mut self) -> Option {\n self.opt.take()\n }\n\n #[inline]\n fn size_hint(&self) -> (usize, Option) {\n match self.opt {\n Some(_) => (1, Some(1)),\n None => (0, Some(0)),\n }\n }\n}\n\nimpl DoubleEndedIterator for Item {\n #[inline]\n fn next_back(&mut self) -> Option {\n self.opt.take()\n }\n}\n\nimpl ExactSizeIterator for Item {}\nimpl FusedIterator for Item {}\nunsafe impl TrustedLen for Item {}\n\n/// An iterator over a reference to the [`Some`] variant of an [`Option`].\n///\n/// The iterator yields one value if the [`Option`] is a [`Some`], otherwise none.\n///\n/// This `struct` is created by the [`Option::iter`] function.\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\n#[derive(Debug)]\npub struct Iter<'a, A: 'a> {\n inner: Item<&'a A>,\n}\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\nimpl<'a, A> Iterator for Iter<'a, A> {\n type Item = &'a A;\n\n #[inline]\n fn next(&mut self) -> Option<&'a A> {\n self.inner.next()\n }\n #[inline]\n fn size_hint(&self) -> (usize, Option) {\n self.inner.size_hint()\n }\n}\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\nimpl<'a, A> DoubleEndedIterator for Iter<'a, A> {\n #[inline]\n fn next_back(&mut self) -> Option<&'a A> {\n self.inner.next_back()\n }\n}\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\nimpl ExactSizeIterator for Iter<'_, A> {}\n\n#[stable(feature = \"fused\", since = \"1.26.0\")]\nimpl FusedIterator for Iter<'_, A> {}\n\n#[unstable(feature = \"trusted_len\", issue = \"37572\")]\nunsafe impl TrustedLen for Iter<'_, A> {}\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\nimpl Clone for Iter<'_, A> {\n #[inline]\n fn clone(&self) -> Self {\n Iter { inner: self.inner.clone() }\n }\n}\n\n/// An iterator over a mutable reference to the [`Some`] variant of an [`Option`].\n///\n/// The iterator yields one value if the [`Option`] is a [`Some`], otherwise none.\n///\n/// This `struct` is created by the [`Option::iter_mut`] function.\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\n#[derive(Debug)]\npub struct IterMut<'a, A: 'a> {\n inner: Item<&'a mut A>,\n}\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\nimpl<'a, A> Iterator for IterMut<'a, A> {\n type Item = &'a mut A;\n\n #[inline]\n fn next(&mut self) -> Option<&'a mut A> {\n self.inner.next()\n }\n #[inline]\n fn size_hint(&self) -> (usize, Option) {\n self.inner.size_hint()\n }\n}\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\nimpl<'a, A> DoubleEndedIterator for IterMut<'a, A> {\n #[inline]\n fn next_back(&mut self) -> Option<&'a mut A> {\n self.inner.next_back()\n }\n}\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\nimpl ExactSizeIterator for IterMut<'_, A> {}\n\n#[stable(feature = \"fused\", since = \"1.26.0\")]\nimpl FusedIterator for IterMut<'_, A> {}\n#[unstable(feature = \"trusted_len\", issue = \"37572\")]\nunsafe impl TrustedLen for IterMut<'_, A> {}\n\n/// An iterator over the value in [`Some`] variant of an [`Option`].\n///\n/// The iterator yields one value if the [`Option`] is a [`Some`], otherwise none.\n///\n/// This `struct` is created by the [`Option::into_iter`] function.\n#[derive(Clone, Debug)]\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\npub struct IntoIter {\n inner: Item,\n}\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\nimpl Iterator for IntoIter {\n type Item = A;\n\n #[inline]\n fn next(&mut self) -> Option {\n self.inner.next()\n }\n #[inline]\n fn size_hint(&self) -> (usize, Option) {\n self.inner.size_hint()\n }\n}\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\nimpl DoubleEndedIterator for IntoIter {\n #[inline]\n fn next_back(&mut self) -> Option {\n self.inner.next_back()\n }\n}\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\nimpl ExactSizeIterator for IntoIter {}\n\n#[stable(feature = \"fused\", since = \"1.26.0\")]\nimpl FusedIterator for IntoIter {}\n\n#[unstable(feature = \"trusted_len\", issue = \"37572\")]\nunsafe impl TrustedLen for IntoIter {}\n\n/////////////////////////////////////////////////////////////////////////////\n// FromIterator\n/////////////////////////////////////////////////////////////////////////////\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\nimpl> FromIterator> for Option {\n /// Takes each element in the [`Iterator`]: if it is [`None`][Option::None],\n /// no further elements are taken, and the [`None`][Option::None] is\n /// returned. Should no [`None`][Option::None] occur, a container of type\n /// `V` containing the values of each [`Option`] is returned.\n ///\n /// # Examples\n ///\n /// Here is an example which increments every integer in a vector.\n /// We use the checked variant of `add` that returns `None` when the\n /// calculation would result in an overflow.\n ///\n /// ```\n /// let items = vec![0_u16, 1, 2];\n ///\n /// let res: Option> = items\n /// .iter()\n /// .map(|x| x.checked_add(1))\n /// .collect();\n ///\n /// assert_eq!(res, Some(vec![1, 2, 3]));\n /// ```\n ///\n /// As you can see, this will return the expected, valid items.\n ///\n /// Here is another example that tries to subtract one from another list\n /// of integers, this time checking for underflow:\n ///\n /// ```\n /// let items = vec![2_u16, 1, 0];\n ///\n /// let res: Option> = items\n /// .iter()\n /// .map(|x| x.checked_sub(1))\n /// .collect();\n ///\n /// assert_eq!(res, None);\n /// ```\n ///\n /// Since the last element is zero, it would underflow. Thus, the resulting\n /// value is `None`.\n ///\n /// Here is a variation on the previous example, showing that no\n /// further elements are taken from `iter` after the first `None`.\n ///\n /// ```\n /// let items = vec![3_u16, 2, 1, 10];\n ///\n /// let mut shared = 0;\n ///\n /// let res: Option> = items\n /// .iter()\n /// .map(|x| { shared += x; x.checked_sub(2) })\n /// .collect();\n ///\n /// assert_eq!(res, None);\n /// assert_eq!(shared, 6);\n /// ```\n ///\n /// Since the third element caused an underflow, no further elements were taken,\n /// so the final value of `shared` is 6 (= `3 + 2 + 1`), not 16.\n #[inline]\n fn from_iter>>(iter: I) -> Option {\n // FIXME(#11084): This could be replaced with Iterator::scan when this\n // performance bug is closed.\n\n iter::try_process(iter.into_iter(), |i| i.collect())\n }\n}\n\n#[unstable(feature = \"try_trait_v2\", issue = \"84277\")]\n#[rustc_const_unstable(feature = \"const_convert\", issue = \"88674\")]\nimpl const ops::Try for Option {\n type Output = T;\n type Residual = Option;\n\n #[inline]\n fn from_output(output: Self::Output) -> Self {\n Some(output)\n }\n\n #[inline]\n fn branch(self) -> ControlFlow {\n match self {\n Some(v) => ControlFlow::Continue(v),\n None => ControlFlow::Break(None),\n }\n }\n}\n\n#[unstable(feature = \"try_trait_v2\", issue = \"84277\")]\n#[rustc_const_unstable(feature = \"const_convert\", issue = \"88674\")]\nimpl const ops::FromResidual for Option {\n #[inline]\n fn from_residual(residual: Option) -> Self {\n match residual {\n None => None,\n }\n }\n}\n\n#[unstable(feature = \"try_trait_v2_yeet\", issue = \"96374\")]\nimpl ops::FromResidual> for Option {\n #[inline]\n fn from_residual(ops::Yeet(()): ops::Yeet<()>) -> Self {\n None\n }\n}\n\n#[unstable(feature = \"try_trait_v2_residual\", issue = \"91285\")]\nimpl ops::Residual for Option {\n type TryType = Option;\n}\n\nimpl Option> {\n /// Converts from `Option>` to `Option`.\n ///\n /// # Examples\n ///\n /// Basic usage:\n ///\n /// ```\n /// let x: Option> = Some(Some(6));\n /// assert_eq!(Some(6), x.flatten());\n ///\n /// let x: Option> = Some(None);\n /// assert_eq!(None, x.flatten());\n ///\n /// let x: Option> = None;\n /// assert_eq!(None, x.flatten());\n /// ```\n ///\n /// Flattening only removes one level of nesting at a time:\n ///\n /// ```\n /// let x: Option>> = Some(Some(Some(6)));\n /// assert_eq!(Some(Some(6)), x.flatten());\n /// assert_eq!(Some(6), x.flatten().flatten());\n /// ```\n #[inline]\n #[stable(feature = \"option_flattening\", since = \"1.40.0\")]\n #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]\n pub const fn flatten(self) -> Option {\n match self {\n Some(inner) => inner,\n None => None,\n }\n }\n}\n","uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","version":0} 17:00:16 INFO unnamed src/language_server_protocol.rs:1888 text_document_code_lens; params=Object({"bufnr": Number(2), "filename": String("/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"), "languageId": String("rust"), "position": Object({"character": Number(0), "line": Number(0)}), "viewport": Object({"end": Number(22), "start": Number(0)})}) 17:00:16 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:command","params":["setlocal omnifunc=LanguageClient#complete"]} 17:00:16 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"setbufvar","params":["/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","LanguageClient_projectRoot","/home/dick/LanguageClient-neovim"]} 17:00:16 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:ExecuteAutocmd","params":["LanguageClientTextDocumentDidOpenPost"]} 17:00:16 DEBUG writer-Some("rust") src/rpcclient.rs:254 => Some("rust") {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"rust","text":"//! Optional values.\n//!\n//! Type [`Option`] represents an optional value: every [`Option`]\n//! is either [`Some`] and contains a value, or [`None`], and\n//! does not. [`Option`] types are very common in Rust code, as\n//! they have a number of uses:\n//!\n//! * Initial values\n//! * Return values for functions that are not defined\n//! over their entire input range (partial functions)\n//! * Return value for otherwise reporting simple errors, where [`None`] is\n//! returned on error\n//! * Optional struct fields\n//! * Struct fields that can be loaned or \"taken\"\n//! * Optional function arguments\n//! * Nullable pointers\n//! * Swapping things out of difficult situations\n//!\n//! [`Option`]s are commonly paired with pattern matching to query the presence\n//! of a value and take action, always accounting for the [`None`] case.\n//!\n//! ```\n//! fn divide(numerator: f64, denominator: f64) -> Option {\n//! if denominator == 0.0 {\n//! None\n//! } else {\n//! Some(numerator / denominator)\n//! }\n//! }\n//!\n//! // The return value of the function is an option\n//! let result = divide(2.0, 3.0);\n//!\n//! // Pattern match to retrieve the value\n//! match result {\n//! // The division was valid\n//! Some(x) => println!(\"Result: {x}\"),\n//! // The division was invalid\n//! None => println!(\"Cannot divide by 0\"),\n//! }\n//! ```\n//!\n//\n// FIXME: Show how `Option` is used in practice, with lots of methods\n//\n//! # Options and pointers (\"nullable\" pointers)\n//!\n//! Rust's pointer types must always point to a valid location; there are\n//! no \"null\" references. Instead, Rust has *optional* pointers, like\n//! the optional owned box, [Option]<[Box\\]>.\n//!\n//! [Box\\]: ../../std/boxed/struct.Box.html\n//!\n//! The following example uses [`Option`] to create an optional box of\n//! [`i32`]. Notice that in order to use the inner [`i32`] value, the\n//! `check_optional` function first needs to use pattern matching to\n//! determine whether the box has a value (i.e., it is [`Some(...)`][`Some`]) or\n//! not ([`None`]).\n//!\n//! ```\n//! let optional = None;\n//! check_optional(optional);\n//!\n//! let optional = Some(Box::new(9000));\n//! check_optional(optional);\n//!\n//! fn check_optional(optional: Option>) {\n//! match optional {\n//! Some(p) => println!(\"has value {p}\"),\n//! None => println!(\"has no value\"),\n//! }\n//! }\n//! ```\n//!\n//! # Representation\n//!\n//! Rust guarantees to optimize the following types `T` such that\n//! [`Option`] has the same size as `T`:\n//!\n//! * [`Box`]\n//! * `&U`\n//! * `&mut U`\n//! * `fn`, `extern \"C\" fn`[^extern_fn]\n//! * [`num::NonZero*`]\n//! * [`ptr::NonNull`]\n//! * `#[repr(transparent)]` struct around one of the types in this list.\n//!\n//! [^extern_fn]: this remains true for any other ABI: `extern \"abi\" fn` (_e.g._, `extern \"system\" fn`)\n//!\n//! [`Box`]: ../../std/boxed/struct.Box.html\n//! [`num::NonZero*`]: crate::num\n//! [`ptr::NonNull`]: crate::ptr::NonNull\n//!\n//! This is called the \"null pointer optimization\" or NPO.\n//!\n//! It is further guaranteed that, for the cases above, one can\n//! [`mem::transmute`] from all valid values of `T` to `Option` and\n//! from `Some::(_)` to `T` (but transmuting `None::` to `T`\n//! is undefined behaviour).\n//!\n//! # Method overview\n//!\n//! In addition to working with pattern matching, [`Option`] provides a wide\n//! variety of different methods.\n//!\n//! ## Querying the variant\n//!\n//! The [`is_some`] and [`is_none`] methods return [`true`] if the [`Option`]\n//! is [`Some`] or [`None`], respectively.\n//!\n//! [`is_none`]: Option::is_none\n//! [`is_some`]: Option::is_some\n//!\n//! ## Adapters for working with references\n//!\n//! * [`as_ref`] converts from [&][][Option]\\ to [Option]<[&]T>\n//! * [`as_mut`] converts from [&mut] [Option]\\ to [Option]<[&mut] T>\n//! * [`as_deref`] converts from [&][][Option]\\ to\n//! [Option]<[&]T::[Target]>\n//! * [`as_deref_mut`] converts from [&mut] [Option]\\ to\n//! [Option]<[&mut] T::[Target]>\n//! * [`as_pin_ref`] converts from [Pin]<[&][][Option]\\> to\n//! [Option]<[Pin]<[&]T>>\n//! * [`as_pin_mut`] converts from [Pin]<[&mut] [Option]\\> to\n//! [Option]<[Pin]<[&mut] T>>\n//!\n//! [&]: reference \"shared reference\"\n//! [&mut]: reference \"mutable reference\"\n//! [Target]: Deref::Target \"ops::Deref::Target\"\n//! [`as_deref`]: Option::as_deref\n//! [`as_deref_mut`]: Option::as_deref_mut\n//! [`as_mut`]: Option::as_mut\n//! [`as_pin_mut`]: Option::as_pin_mut\n//! [`as_pin_ref`]: Option::as_pin_ref\n//! [`as_ref`]: Option::as_ref\n//!\n//! ## Extracting the contained value\n//!\n//! These methods extract the contained value in an [`Option`] when it\n//! is the [`Some`] variant. If the [`Option`] is [`None`]:\n//!\n//! * [`expect`] panics with a provided custom message\n//! * [`unwrap`] panics with a generic message\n//! * [`unwrap_or`] returns the provided default value\n//! * [`unwrap_or_default`] returns the default value of the type `T`\n//! (which must implement the [`Default`] trait)\n//! * [`unwrap_or_else`] returns the result of evaluating the provided\n//! function\n//!\n//! [`expect`]: Option::expect\n//! [`unwrap`]: Option::unwrap\n//! [`unwrap_or`]: Option::unwrap_or\n//! [`unwrap_or_default`]: Option::unwrap_or_default\n//! [`unwrap_or_else`]: Option::unwrap_or_else\n//!\n//! ## Transforming contained values\n//!\n//! These methods transform [`Option`] to [`Result`]:\n//!\n//! * [`ok_or`] transforms [`Some(v)`] to [`Ok(v)`], and [`None`] to\n//! [`Err(err)`] using the provided default `err` value\n//! * [`ok_or_else`] transforms [`Some(v)`] to [`Ok(v)`], and [`None`] to\n//! a value of [`Err`] using the provided function\n//! * [`transpose`] transposes an [`Option`] of a [`Result`] into a\n//! [`Result`] of an [`Option`]\n//!\n//! [`Err(err)`]: Err\n//! [`Ok(v)`]: Ok\n//! [`Some(v)`]: Some\n//! [`ok_or`]: Option::ok_or\n//! [`ok_or_else`]: Option::ok_or_else\n//! [`transpose`]: Option::transpose\n//!\n//! These methods transform the [`Some`] variant:\n//!\n//! * [`filter`] calls the provided predicate function on the contained\n//! value `t` if the [`Option`] is [`Some(t)`], and returns [`Some(t)`]\n//! if the function returns `true`; otherwise, returns [`None`]\n//! * [`flatten`] removes one level of nesting from an\n//! [`Option>`]\n//! * [`map`] transforms [`Option`] to [`Option`] by applying the\n//! provided function to the contained value of [`Some`] and leaving\n//! [`None`] values unchanged\n//!\n//! [`Some(t)`]: Some\n//! [`filter`]: Option::filter\n//! [`flatten`]: Option::flatten\n//! [`map`]: Option::map\n//!\n//! These methods transform [`Option`] to a value of a possibly\n//! different type `U`:\n//!\n//! * [`map_or`] applies the provided function to the contained value of\n//! [`Some`], or returns the provided default value if the [`Option`] is\n//! [`None`]\n//! * [`map_or_else`] applies the provided function to the contained value\n//! of [`Some`], or returns the result of evaluating the provided\n//! fallback function if the [`Option`] is [`None`]\n//!\n//! [`map_or`]: Option::map_or\n//! [`map_or_else`]: Option::map_or_else\n//!\n//! These methods combine the [`Some`] variants of two [`Option`] values:\n//!\n//! * [`zip`] returns [`Some((s, o))`] if `self` is [`Some(s)`] and the\n//! provided [`Option`] value is [`Some(o)`]; otherwise, returns [`None`]\n//! * [`zip_with`] calls the provided function `f` and returns\n//! [`Some(f(s, o))`] if `self` is [`Some(s)`] and the provided\n//! [`Option`] value is [`Some(o)`]; otherwise, returns [`None`]\n//!\n//! [`Some(f(s, o))`]: Some\n//! [`Some(o)`]: Some\n//! [`Some(s)`]: Some\n//! [`Some((s, o))`]: Some\n//! [`zip`]: Option::zip\n//! [`zip_with`]: Option::zip_with\n//!\n//! ## Boolean operators\n//!\n//! These methods treat the [`Option`] as a boolean value, where [`Some`]\n//! acts like [`true`] and [`None`] acts like [`false`]. There are two\n//! categories of these methods: ones that take an [`Option`] as input, and\n//! ones that take a function as input (to be lazily evaluated).\n//!\n//! The [`and`], [`or`], and [`xor`] methods take another [`Option`] as\n//! input, and produce an [`Option`] as output. Only the [`and`] method can\n//! produce an [`Option`] value having a different inner type `U` than\n//! [`Option`].\n//!\n//! | method | self | input | output |\n//! |---------|-----------|-----------|-----------|\n//! | [`and`] | `None` | (ignored) | `None` |\n//! | [`and`] | `Some(x)` | `None` | `None` |\n//! | [`and`] | `Some(x)` | `Some(y)` | `Some(y)` |\n//! | [`or`] | `None` | `None` | `None` |\n//! | [`or`] | `None` | `Some(y)` | `Some(y)` |\n//! | [`or`] | `Some(x)` | (ignored) | `Some(x)` |\n//! | [`xor`] | `None` | `None` | `None` |\n//! | [`xor`] | `None` | `Some(y)` | `Some(y)` |\n//! | [`xor`] | `Some(x)` | `None` | `Some(x)` |\n//! | [`xor`] | `Some(x)` | `Some(y)` | `None` |\n//!\n//! [`and`]: Option::and\n//! [`or`]: Option::or\n//! [`xor`]: Option::xor\n//!\n//! The [`and_then`] and [`or_else`] methods take a function as input, and\n//! only evaluate the function when they need to produce a new value. Only\n//! the [`and_then`] method can produce an [`Option`] value having a\n//! different inner type `U` than [`Option`].\n//!\n//! | method | self | function input | function result | output |\n//! |--------------|-----------|----------------|-----------------|-----------|\n//! | [`and_then`] | `None` | (not provided) | (not evaluated) | `None` |\n//! | [`and_then`] | `Some(x)` | `x` | `None` | `None` |\n//! | [`and_then`] | `Some(x)` | `x` | `Some(y)` | `Some(y)` |\n//! | [`or_else`] | `None` | (not provided) | `None` | `None` |\n//! | [`or_else`] | `None` | (not provided) | `Some(y)` | `Some(y)` |\n//! | [`or_else`] | `Some(x)` | (not provided) | (not evaluated) | `Some(x)` |\n//!\n//! [`and_then`]: Option::and_then\n//! [`or_else`]: Option::or_else\n//!\n//! This is an example of using methods like [`and_then`] and [`or`] in a\n//! pipeline of method calls. Early stages of the pipeline pass failure\n//! values ([`None`]) through unchanged, and continue processing on\n//! success values ([`Some`]). Toward the end, [`or`] substitutes an error\n//! message if it receives [`None`].\n//!\n//! ```\n//! # use std::collections::BTreeMap;\n//! let mut bt = BTreeMap::new();\n//! bt.insert(20u8, \"foo\");\n//! bt.insert(42u8, \"bar\");\n//! let res = [0u8, 1, 11, 200, 22]\n//! .into_iter()\n//! .map(|x| {\n//! // `checked_sub()` returns `None` on error\n//! x.checked_sub(1)\n//! // same with `checked_mul()`\n//! .and_then(|x| x.checked_mul(2))\n//! // `BTreeMap::get` returns `None` on error\n//! .and_then(|x| bt.get(&x))\n//! // Substitute an error message if we have `None` so far\n//! .or(Some(&\"error!\"))\n//! .copied()\n//! // Won't panic because we unconditionally used `Some` above\n//! .unwrap()\n//! })\n//! .collect::>();\n//! assert_eq!(res, [\"error!\", \"error!\", \"foo\", \"error!\", \"bar\"]);\n//! ```\n//!\n//! ## Comparison operators\n//!\n//! If `T` implements [`PartialOrd`] then [`Option`] will derive its\n//! [`PartialOrd`] implementation. With this order, [`None`] compares as\n//! less than any [`Some`], and two [`Some`] compare the same way as their\n//! contained values would in `T`. If `T` also implements\n//! [`Ord`], then so does [`Option`].\n//!\n//! ```\n//! assert!(None < Some(0));\n//! assert!(Some(0) < Some(1));\n//! ```\n//!\n//! ## Iterating over `Option`\n//!\n//! An [`Option`] can be iterated over. This can be helpful if you need an\n//! iterator that is conditionally empty. The iterator will either produce\n//! a single value (when the [`Option`] is [`Some`]), or produce no values\n//! (when the [`Option`] is [`None`]). For example, [`into_iter`] acts like\n//! [`once(v)`] if the [`Option`] is [`Some(v)`], and like [`empty()`] if\n//! the [`Option`] is [`None`].\n//!\n//! [`Some(v)`]: Some\n//! [`empty()`]: crate::iter::empty\n//! [`once(v)`]: crate::iter::once\n//!\n//! Iterators over [`Option`] come in three types:\n//!\n//! * [`into_iter`] consumes the [`Option`] and produces the contained\n//! value\n//! * [`iter`] produces an immutable reference of type `&T` to the\n//! contained value\n//! * [`iter_mut`] produces a mutable reference of type `&mut T` to the\n//! contained value\n//!\n//! [`into_iter`]: Option::into_iter\n//! [`iter`]: Option::iter\n//! [`iter_mut`]: Option::iter_mut\n//!\n//! An iterator over [`Option`] can be useful when chaining iterators, for\n//! example, to conditionally insert items. (It's not always necessary to\n//! explicitly call an iterator constructor: many [`Iterator`] methods that\n//! accept other iterators will also accept iterable types that implement\n//! [`IntoIterator`], which includes [`Option`].)\n//!\n//! ```\n//! let yep = Some(42);\n//! let nope = None;\n//! // chain() already calls into_iter(), so we don't have to do so\n//! let nums: Vec = (0..4).chain(yep).chain(4..8).collect();\n//! assert_eq!(nums, [0, 1, 2, 3, 42, 4, 5, 6, 7]);\n//! let nums: Vec = (0..4).chain(nope).chain(4..8).collect();\n//! assert_eq!(nums, [0, 1, 2, 3, 4, 5, 6, 7]);\n//! ```\n//!\n//! One reason to chain iterators in this way is that a function returning\n//! `impl Iterator` must have all possible return values be of the same\n//! concrete type. Chaining an iterated [`Option`] can help with that.\n//!\n//! ```\n//! fn make_iter(do_insert: bool) -> impl Iterator {\n//! // Explicit returns to illustrate return types matching\n//! match do_insert {\n//! true => return (0..4).chain(Some(42)).chain(4..8),\n//! false => return (0..4).chain(None).chain(4..8),\n//! }\n//! }\n//! println!(\"{:?}\", make_iter(true).collect::>());\n//! println!(\"{:?}\", make_iter(false).collect::>());\n//! ```\n//!\n//! If we try to do the same thing, but using [`once()`] and [`empty()`],\n//! we can't return `impl Iterator` anymore because the concrete types of\n//! the return values differ.\n//!\n//! [`empty()`]: crate::iter::empty\n//! [`once()`]: crate::iter::once\n//!\n//! ```compile_fail,E0308\n//! # use std::iter::{empty, once};\n//! // This won't compile because all possible returns from the function\n//! // must have the same concrete type.\n//! fn make_iter(do_insert: bool) -> impl Iterator {\n//! // Explicit returns to illustrate return types not matching\n//! match do_insert {\n//! true => return (0..4).chain(once(42)).chain(4..8),\n//! false => return (0..4).chain(empty()).chain(4..8),\n//! }\n//! }\n//! ```\n//!\n//! ## Collecting into `Option`\n//!\n//! [`Option`] implements the [`FromIterator`][impl-FromIterator] trait,\n//! which allows an iterator over [`Option`] values to be collected into an\n//! [`Option`] of a collection of each contained value of the original\n//! [`Option`] values, or [`None`] if any of the elements was [`None`].\n//!\n//! [impl-FromIterator]: Option#impl-FromIterator%3COption%3CA%3E%3E\n//!\n//! ```\n//! let v = [Some(2), Some(4), None, Some(8)];\n//! let res: Option> = v.into_iter().collect();\n//! assert_eq!(res, None);\n//! let v = [Some(2), Some(4), Some(8)];\n//! let res: Option> = v.into_iter().collect();\n//! assert_eq!(res, Some(vec![2, 4, 8]));\n//! ```\n//!\n//! [`Option`] also implements the [`Product`][impl-Product] and\n//! [`Sum`][impl-Sum] traits, allowing an iterator over [`Option`] values\n//! to provide the [`product`][Iterator::product] and\n//! [`sum`][Iterator::sum] methods.\n//!\n//! [impl-Product]: Option#impl-Product%3COption%3CU%3E%3E\n//! [impl-Sum]: Option#impl-Sum%3COption%3CU%3E%3E\n//!\n//! ```\n//! let v = [None, Some(1), Some(2), Some(3)];\n//! let res: Option = v.into_iter().sum();\n//! assert_eq!(res, None);\n//! let v = [Some(1), Some(2), Some(21)];\n//! let res: Option = v.into_iter().product();\n//! assert_eq!(res, Some(42));\n//! ```\n//!\n//! ## Modifying an [`Option`] in-place\n//!\n//! These methods return a mutable reference to the contained value of an\n//! [`Option`]:\n//!\n//! * [`insert`] inserts a value, dropping any old contents\n//! * [`get_or_insert`] gets the current value, inserting a provided\n//! default value if it is [`None`]\n//! * [`get_or_insert_default`] gets the current value, inserting the\n//! default value of type `T` (which must implement [`Default`]) if it is\n//! [`None`]\n//! * [`get_or_insert_with`] gets the current value, inserting a default\n//! computed by the provided function if it is [`None`]\n//!\n//! [`get_or_insert`]: Option::get_or_insert\n//! [`get_or_insert_default`]: Option::get_or_insert_default\n//! [`get_or_insert_with`]: Option::get_or_insert_with\n//! [`insert`]: Option::insert\n//!\n//! These methods transfer ownership of the contained value of an\n//! [`Option`]:\n//!\n//! * [`take`] takes ownership of the contained value of an [`Option`], if\n//! any, replacing the [`Option`] with [`None`]\n//! * [`replace`] takes ownership of the contained value of an [`Option`],\n//! if any, replacing the [`Option`] with a [`Some`] containing the\n//! provided value\n//!\n//! [`replace`]: Option::replace\n//! [`take`]: Option::take\n//!\n//! # Examples\n//!\n//! Basic pattern matching on [`Option`]:\n//!\n//! ```\n//! let msg = Some(\"howdy\");\n//!\n//! // Take a reference to the contained string\n//! if let Some(m) = &msg {\n//! println!(\"{}\", *m);\n//! }\n//!\n//! // Remove the contained string, destroying the Option\n//! let unwrapped_msg = msg.unwrap_or(\"default message\");\n//! ```\n//!\n//! Initialize a result to [`None`] before a loop:\n//!\n//! ```\n//! enum Kingdom { Plant(u32, &'static str), Animal(u32, &'static str) }\n//!\n//! // A list of data to search through.\n//! let all_the_big_things = [\n//! Kingdom::Plant(250, \"redwood\"),\n//! Kingdom::Plant(230, \"noble fir\"),\n//! Kingdom::Plant(229, \"sugar pine\"),\n//! Kingdom::Animal(25, \"blue whale\"),\n//! Kingdom::Animal(19, \"fin whale\"),\n//! Kingdom::Animal(15, \"north pacific right whale\"),\n//! ];\n//!\n//! // We're going to search for the name of the biggest animal,\n//! // but to start with we've just got `None`.\n//! let mut name_of_biggest_animal = None;\n//! let mut size_of_biggest_animal = 0;\n//! for big_thing in &all_the_big_things {\n//! match *big_thing {\n//! Kingdom::Animal(size, name) if size > size_of_biggest_animal => {\n//! // Now we've found the name of some big animal\n//! size_of_biggest_animal = size;\n//! name_of_biggest_animal = Some(name);\n//! }\n//! Kingdom::Animal(..) | Kingdom::Plant(..) => ()\n//! }\n//! }\n//!\n//! match name_of_biggest_animal {\n//! Some(name) => println!(\"the biggest animal is {name}\"),\n//! None => println!(\"there are no animals :(\"),\n//! }\n//! ```\n\n#![stable(feature = \"rust1\", since = \"1.0.0\")]\n\nuse crate::iter::{self, FromIterator, FusedIterator, TrustedLen};\nuse crate::marker::Destruct;\nuse crate::panicking::{panic, panic_str};\nuse crate::pin::Pin;\nuse crate::{\n convert, hint, mem,\n ops::{self, ControlFlow, Deref, DerefMut},\n};\n\n/// The `Option` type. See [the module level documentation](self) for more.\n#[derive(Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]\n#[rustc_diagnostic_item = \"Option\"]\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\npub enum Option {\n /// No value.\n #[lang = \"None\"]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n None,\n /// Some value of type `T`.\n #[lang = \"Some\"]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n Some(#[stable(feature = \"rust1\", since = \"1.0.0\")] T),\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// Type implementation\n/////////////////////////////////////////////////////////////////////////////\n\nimpl Option {\n /////////////////////////////////////////////////////////////////////////\n // Querying the contained values\n /////////////////////////////////////////////////////////////////////////\n\n /// Returns `true` if the option is a [`Some`] value.\n ///\n /// # Examples\n ///\n /// ```\n /// let x: Option = Some(2);\n /// assert_eq!(x.is_some(), true);\n ///\n /// let x: Option = None;\n /// assert_eq!(x.is_some(), false);\n /// ```\n #[must_use = \"if you intended to assert that this has a value, consider `.unwrap()` instead\"]\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_stable(feature = \"const_option_basics\", since = \"1.48.0\")]\n pub const fn is_some(&self) -> bool {\n matches!(*self, Some(_))\n }\n\n /// Returns `true` if the option is a [`Some`] and the value inside of it matches a predicate.\n ///\n /// # Examples\n ///\n /// ```\n /// #![feature(is_some_with)]\n ///\n /// let x: Option = Some(2);\n /// assert_eq!(x.is_some_and(|&x| x > 1), true);\n ///\n /// let x: Option = Some(0);\n /// assert_eq!(x.is_some_and(|&x| x > 1), false);\n ///\n /// let x: Option = None;\n /// assert_eq!(x.is_some_and(|&x| x > 1), false);\n /// ```\n #[must_use]\n #[inline]\n #[unstable(feature = \"is_some_with\", issue = \"93050\")]\n pub fn is_some_and(&self, f: impl FnOnce(&T) -> bool) -> bool {\n matches!(self, Some(x) if f(x))\n }\n\n /// Returns `true` if the option is a [`None`] value.\n ///\n /// # Examples\n ///\n /// ```\n /// let x: Option = Some(2);\n /// assert_eq!(x.is_none(), false);\n ///\n /// let x: Option = None;\n /// assert_eq!(x.is_none(), true);\n /// ```\n #[must_use = \"if you intended to assert that this doesn't have a value, consider \\\n `.and_then(|_| panic!(\\\"`Option` had a value when expected `None`\\\"))` instead\"]\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_stable(feature = \"const_option_basics\", since = \"1.48.0\")]\n pub const fn is_none(&self) -> bool {\n !self.is_some()\n }\n\n /////////////////////////////////////////////////////////////////////////\n // Adapter for working with references\n /////////////////////////////////////////////////////////////////////////\n\n /// Converts from `&Option` to `Option<&T>`.\n ///\n /// # Examples\n ///\n /// Converts an Option<[String]> into an Option<[usize]>, preserving\n /// the original. The [`map`] method takes the `self` argument by value, consuming the original,\n /// so this technique uses `as_ref` to first take an `Option` to a reference\n /// to the value inside the original.\n ///\n /// [`map`]: Option::map\n /// [String]: ../../std/string/struct.String.html \"String\"\n ///\n /// ```\n /// let text: Option = Some(\"Hello, world!\".to_string());\n /// // First, cast `Option` to `Option<&String>` with `as_ref`,\n /// // then consume *that* with `map`, leaving `text` on the stack.\n /// let text_length: Option = text.as_ref().map(|s| s.len());\n /// println!(\"still can print text: {text:?}\");\n /// ```\n #[inline]\n #[rustc_const_stable(feature = \"const_option_basics\", since = \"1.48.0\")]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n pub const fn as_ref(&self) -> Option<&T> {\n match *self {\n Some(ref x) => Some(x),\n None => None,\n }\n }\n\n /// Converts from `&mut Option` to `Option<&mut T>`.\n ///\n /// # Examples\n ///\n /// ```\n /// let mut x = Some(2);\n /// match x.as_mut() {\n /// Some(v) => *v = 42,\n /// None => {},\n /// }\n /// assert_eq!(x, Some(42));\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]\n pub const fn as_mut(&mut self) -> Option<&mut T> {\n match *self {\n Some(ref mut x) => Some(x),\n None => None,\n }\n }\n\n /// Converts from [Pin]<[&]Option\\> to Option<[Pin]<[&]T>>.\n ///\n /// [&]: reference \"shared reference\"\n #[inline]\n #[must_use]\n #[stable(feature = \"pin\", since = \"1.33.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn as_pin_ref(self: Pin<&Self>) -> Option> {\n match Pin::get_ref(self).as_ref() {\n // SAFETY: `x` is guaranteed to be pinned because it comes from `self`\n // which is pinned.\n Some(x) => unsafe { Some(Pin::new_unchecked(x)) },\n None => None,\n }\n }\n\n /// Converts from [Pin]<[&mut] Option\\> to Option<[Pin]<[&mut] T>>.\n ///\n /// [&mut]: reference \"mutable reference\"\n #[inline]\n #[must_use]\n #[stable(feature = \"pin\", since = \"1.33.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn as_pin_mut(self: Pin<&mut Self>) -> Option> {\n // SAFETY: `get_unchecked_mut` is never used to move the `Option` inside `self`.\n // `x` is guaranteed to be pinned because it comes from `self` which is pinned.\n unsafe {\n match Pin::get_unchecked_mut(self).as_mut() {\n Some(x) => Some(Pin::new_unchecked(x)),\n None => None,\n }\n }\n }\n\n /////////////////////////////////////////////////////////////////////////\n // Getting to contained values\n /////////////////////////////////////////////////////////////////////////\n\n /// Returns the contained [`Some`] value, consuming the `self` value.\n ///\n /// # Panics\n ///\n /// Panics if the value is a [`None`] with a custom panic message provided by\n /// `msg`.\n ///\n /// # Examples\n ///\n /// ```\n /// let x = Some(\"value\");\n /// assert_eq!(x.expect(\"fruits are healthy\"), \"value\");\n /// ```\n ///\n /// ```should_panic\n /// let x: Option<&str> = None;\n /// x.expect(\"fruits are healthy\"); // panics with `fruits are healthy`\n /// ```\n ///\n /// # Recommended Message Style\n ///\n /// We recommend that `expect` messages are used to describe the reason you\n /// _expect_ the `Option` should be `Some`.\n ///\n /// ```should_panic\n /// # let slice: &[u8] = &[];\n /// let item = slice.get(0)\n /// .expect(\"slice should not be empty\");\n /// ```\n ///\n /// **Hint**: If you're having trouble remembering how to phrase expect\n /// error messages remember to focus on the word \"should\" as in \"env\n /// variable should be set by blah\" or \"the given binary should be available\n /// and executable by the current user\".\n ///\n /// For more detail on expect message styles and the reasoning behind our\n /// recommendation please refer to the section on [\"Common Message\n /// Styles\"](../../std/error/index.html#common-message-styles) in the [`std::error`](../../std/error/index.html) module docs.\n #[inline]\n #[track_caller]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]\n pub const fn expect(self, msg: &str) -> T {\n match self {\n Some(val) => val,\n None => expect_failed(msg),\n }\n }\n\n /// Returns the contained [`Some`] value, consuming the `self` value.\n ///\n /// Because this function may panic, its use is generally discouraged.\n /// Instead, prefer to use pattern matching and handle the [`None`]\n /// case explicitly, or call [`unwrap_or`], [`unwrap_or_else`], or\n /// [`unwrap_or_default`].\n ///\n /// [`unwrap_or`]: Option::unwrap_or\n /// [`unwrap_or_else`]: Option::unwrap_or_else\n /// [`unwrap_or_default`]: Option::unwrap_or_default\n ///\n /// # Panics\n ///\n /// Panics if the self value equals [`None`].\n ///\n /// # Examples\n ///\n /// ```\n /// let x = Some(\"air\");\n /// assert_eq!(x.unwrap(), \"air\");\n /// ```\n ///\n /// ```should_panic\n /// let x: Option<&str> = None;\n /// assert_eq!(x.unwrap(), \"air\"); // fails\n /// ```\n #[inline]\n #[track_caller]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]\n pub const fn unwrap(self) -> T {\n match self {\n Some(val) => val,\n None => panic(\"called `Option::unwrap()` on a `None` value\"),\n }\n }\n\n /// Returns the contained [`Some`] value or a provided default.\n ///\n /// Arguments passed to `unwrap_or` are eagerly evaluated; if you are passing\n /// the result of a function call, it is recommended to use [`unwrap_or_else`],\n /// which is lazily evaluated.\n ///\n /// [`unwrap_or_else`]: Option::unwrap_or_else\n ///\n /// # Examples\n ///\n /// ```\n /// assert_eq!(Some(\"car\").unwrap_or(\"bike\"), \"car\");\n /// assert_eq!(None.unwrap_or(\"bike\"), \"bike\");\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn unwrap_or(self, default: T) -> T\n where\n T: ~const Destruct,\n {\n match self {\n Some(x) => x,\n None => default,\n }\n }\n\n /// Returns the contained [`Some`] value or computes it from a closure.\n ///\n /// # Examples\n ///\n /// ```\n /// let k = 10;\n /// assert_eq!(Some(4).unwrap_or_else(|| 2 * k), 4);\n /// assert_eq!(None.unwrap_or_else(|| 2 * k), 20);\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn unwrap_or_else(self, f: F) -> T\n where\n F: ~const FnOnce() -> T,\n F: ~const Destruct,\n {\n match self {\n Some(x) => x,\n None => f(),\n }\n }\n\n /// Returns the contained [`Some`] value or a default.\n ///\n /// Consumes the `self` argument then, if [`Some`], returns the contained\n /// value, otherwise if [`None`], returns the [default value] for that\n /// type.\n ///\n /// # Examples\n ///\n /// Converts a string to an integer, turning poorly-formed strings\n /// into 0 (the default value for integers). [`parse`] converts\n /// a string to any other type that implements [`FromStr`], returning\n /// [`None`] on error.\n ///\n /// ```\n /// let good_year_from_input = \"1909\";\n /// let bad_year_from_input = \"190blarg\";\n /// let good_year = good_year_from_input.parse().ok().unwrap_or_default();\n /// let bad_year = bad_year_from_input.parse().ok().unwrap_or_default();\n ///\n /// assert_eq!(1909, good_year);\n /// assert_eq!(0, bad_year);\n /// ```\n ///\n /// [default value]: Default::default\n /// [`parse`]: str::parse\n /// [`FromStr`]: crate::str::FromStr\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn unwrap_or_default(self) -> T\n where\n T: ~const Default,\n {\n match self {\n Some(x) => x,\n None => Default::default(),\n }\n }\n\n /// Returns the contained [`Some`] value, consuming the `self` value,\n /// without checking that the value is not [`None`].\n ///\n /// # Safety\n ///\n /// Calling this method on [`None`] is *[undefined behavior]*.\n ///\n /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html\n ///\n /// # Examples\n ///\n /// ```\n /// let x = Some(\"air\");\n /// assert_eq!(unsafe { x.unwrap_unchecked() }, \"air\");\n /// ```\n ///\n /// ```no_run\n /// let x: Option<&str> = None;\n /// assert_eq!(unsafe { x.unwrap_unchecked() }, \"air\"); // Undefined behavior!\n /// ```\n #[inline]\n #[track_caller]\n #[stable(feature = \"option_result_unwrap_unchecked\", since = \"1.58.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const unsafe fn unwrap_unchecked(self) -> T {\n debug_assert!(self.is_some());\n match self {\n Some(val) => val,\n // SAFETY: the safety contract must be upheld by the caller.\n None => unsafe { hint::unreachable_unchecked() },\n }\n }\n\n /////////////////////////////////////////////////////////////////////////\n // Transforming contained values\n /////////////////////////////////////////////////////////////////////////\n\n /// Maps an `Option` to `Option` by applying a function to a contained value.\n ///\n /// # Examples\n ///\n /// Converts an Option<[String]> into an Option<[usize]>, consuming\n /// the original:\n ///\n /// [String]: ../../std/string/struct.String.html \"String\"\n /// ```\n /// let maybe_some_string = Some(String::from(\"Hello, World!\"));\n /// // `Option::map` takes self *by value*, consuming `maybe_some_string`\n /// let maybe_some_len = maybe_some_string.map(|s| s.len());\n ///\n /// assert_eq!(maybe_some_len, Some(13));\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn map(self, f: F) -> Option\n where\n F: ~const FnOnce(T) -> U,\n F: ~const Destruct,\n {\n match self {\n Some(x) => Some(f(x)),\n None => None,\n }\n }\n\n /// Calls the provided closure with a reference to the contained value (if [`Some`]).\n ///\n /// # Examples\n ///\n /// ```\n /// #![feature(result_option_inspect)]\n ///\n /// let v = vec![1, 2, 3, 4, 5];\n ///\n /// // prints \"got: 4\"\n /// let x: Option<&usize> = v.get(3).inspect(|x| println!(\"got: {x}\"));\n ///\n /// // prints nothing\n /// let x: Option<&usize> = v.get(5).inspect(|x| println!(\"got: {x}\"));\n /// ```\n #[inline]\n #[unstable(feature = \"result_option_inspect\", issue = \"91345\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn inspect(self, f: F) -> Self\n where\n F: ~const FnOnce(&T),\n F: ~const Destruct,\n {\n if let Some(ref x) = self {\n f(x);\n }\n\n self\n }\n\n /// Returns the provided default result (if none),\n /// or applies a function to the contained value (if any).\n ///\n /// Arguments passed to `map_or` are eagerly evaluated; if you are passing\n /// the result of a function call, it is recommended to use [`map_or_else`],\n /// which is lazily evaluated.\n ///\n /// [`map_or_else`]: Option::map_or_else\n ///\n /// # Examples\n ///\n /// ```\n /// let x = Some(\"foo\");\n /// assert_eq!(x.map_or(42, |v| v.len()), 3);\n ///\n /// let x: Option<&str> = None;\n /// assert_eq!(x.map_or(42, |v| v.len()), 42);\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn map_or(self, default: U, f: F) -> U\n where\n F: ~const FnOnce(T) -> U,\n F: ~const Destruct,\n U: ~const Destruct,\n {\n match self {\n Some(t) => f(t),\n None => default,\n }\n }\n\n /// Computes a default function result (if none), or\n /// applies a different function to the contained value (if any).\n ///\n /// # Examples\n ///\n /// ```\n /// let k = 21;\n ///\n /// let x = Some(\"foo\");\n /// assert_eq!(x.map_or_else(|| 2 * k, |v| v.len()), 3);\n ///\n /// let x: Option<&str> = None;\n /// assert_eq!(x.map_or_else(|| 2 * k, |v| v.len()), 42);\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn map_or_else(self, default: D, f: F) -> U\n where\n D: ~const FnOnce() -> U,\n D: ~const Destruct,\n F: ~const FnOnce(T) -> U,\n F: ~const Destruct,\n {\n match self {\n Some(t) => f(t),\n None => default(),\n }\n }\n\n /// Transforms the `Option` into a [`Result`], mapping [`Some(v)`] to\n /// [`Ok(v)`] and [`None`] to [`Err(err)`].\n ///\n /// Arguments passed to `ok_or` are eagerly evaluated; if you are passing the\n /// result of a function call, it is recommended to use [`ok_or_else`], which is\n /// lazily evaluated.\n ///\n /// [`Ok(v)`]: Ok\n /// [`Err(err)`]: Err\n /// [`Some(v)`]: Some\n /// [`ok_or_else`]: Option::ok_or_else\n ///\n /// # Examples\n ///\n /// ```\n /// let x = Some(\"foo\");\n /// assert_eq!(x.ok_or(0), Ok(\"foo\"));\n ///\n /// let x: Option<&str> = None;\n /// assert_eq!(x.ok_or(0), Err(0));\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn ok_or(self, err: E) -> Result\n where\n E: ~const Destruct,\n {\n match self {\n Some(v) => Ok(v),\n None => Err(err),\n }\n }\n\n /// Transforms the `Option` into a [`Result`], mapping [`Some(v)`] to\n /// [`Ok(v)`] and [`None`] to [`Err(err())`].\n ///\n /// [`Ok(v)`]: Ok\n /// [`Err(err())`]: Err\n /// [`Some(v)`]: Some\n ///\n /// # Examples\n ///\n /// ```\n /// let x = Some(\"foo\");\n /// assert_eq!(x.ok_or_else(|| 0), Ok(\"foo\"));\n ///\n /// let x: Option<&str> = None;\n /// assert_eq!(x.ok_or_else(|| 0), Err(0));\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn ok_or_else(self, err: F) -> Result\n where\n F: ~const FnOnce() -> E,\n F: ~const Destruct,\n {\n match self {\n Some(v) => Ok(v),\n None => Err(err()),\n }\n }\n\n /// Converts from `Option` (or `&Option`) to `Option<&T::Target>`.\n ///\n /// Leaves the original Option in-place, creating a new one with a reference\n /// to the original one, additionally coercing the contents via [`Deref`].\n ///\n /// # Examples\n ///\n /// ```\n /// let x: Option = Some(\"hey\".to_owned());\n /// assert_eq!(x.as_deref(), Some(\"hey\"));\n ///\n /// let x: Option = None;\n /// assert_eq!(x.as_deref(), None);\n /// ```\n #[stable(feature = \"option_deref\", since = \"1.40.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn as_deref(&self) -> Option<&T::Target>\n where\n T: ~const Deref,\n {\n match self.as_ref() {\n Some(t) => Some(t.deref()),\n None => None,\n }\n }\n\n /// Converts from `Option` (or `&mut Option`) to `Option<&mut T::Target>`.\n ///\n /// Leaves the original `Option` in-place, creating a new one containing a mutable reference to\n /// the inner type's [`Deref::Target`] type.\n ///\n /// # Examples\n ///\n /// ```\n /// let mut x: Option = Some(\"hey\".to_owned());\n /// assert_eq!(x.as_deref_mut().map(|x| {\n /// x.make_ascii_uppercase();\n /// x\n /// }), Some(\"HEY\".to_owned().as_mut_str()));\n /// ```\n #[stable(feature = \"option_deref\", since = \"1.40.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn as_deref_mut(&mut self) -> Option<&mut T::Target>\n where\n T: ~const DerefMut,\n {\n match self.as_mut() {\n Some(t) => Some(t.deref_mut()),\n None => None,\n }\n }\n\n /////////////////////////////////////////////////////////////////////////\n // Iterator constructors\n /////////////////////////////////////////////////////////////////////////\n\n /// Returns an iterator over the possibly contained value.\n ///\n /// # Examples\n ///\n /// ```\n /// let x = Some(4);\n /// assert_eq!(x.iter().next(), Some(&4));\n ///\n /// let x: Option = None;\n /// assert_eq!(x.iter().next(), None);\n /// ```\n #[inline]\n #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n pub const fn iter(&self) -> Iter<'_, T> {\n Iter { inner: Item { opt: self.as_ref() } }\n }\n\n /// Returns a mutable iterator over the possibly contained value.\n ///\n /// # Examples\n ///\n /// ```\n /// let mut x = Some(4);\n /// match x.iter_mut().next() {\n /// Some(v) => *v = 42,\n /// None => {},\n /// }\n /// assert_eq!(x, Some(42));\n ///\n /// let mut x: Option = None;\n /// assert_eq!(x.iter_mut().next(), None);\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n pub fn iter_mut(&mut self) -> IterMut<'_, T> {\n IterMut { inner: Item { opt: self.as_mut() } }\n }\n\n /////////////////////////////////////////////////////////////////////////\n // Boolean operations on the values, eager and lazy\n /////////////////////////////////////////////////////////////////////////\n\n /// Returns [`None`] if the option is [`None`], otherwise returns `optb`.\n ///\n /// # Examples\n ///\n /// ```\n /// let x = Some(2);\n /// let y: Option<&str> = None;\n /// assert_eq!(x.and(y), None);\n ///\n /// let x: Option = None;\n /// let y = Some(\"foo\");\n /// assert_eq!(x.and(y), None);\n ///\n /// let x = Some(2);\n /// let y = Some(\"foo\");\n /// assert_eq!(x.and(y), Some(\"foo\"));\n ///\n /// let x: Option = None;\n /// let y: Option<&str> = None;\n /// assert_eq!(x.and(y), None);\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn and(self, optb: Option) -> Option\n where\n T: ~const Destruct,\n U: ~const Destruct,\n {\n match self {\n Some(_) => optb,\n None => None,\n }\n }\n\n /// Returns [`None`] if the option is [`None`], otherwise calls `f` with the\n /// wrapped value and returns the result.\n ///\n /// Some languages call this operation flatmap.\n ///\n /// # Examples\n ///\n /// ```\n /// fn sq_then_to_string(x: u32) -> Option {\n /// x.checked_mul(x).map(|sq| sq.to_string())\n /// }\n ///\n /// assert_eq!(Some(2).and_then(sq_then_to_string), Some(4.to_string()));\n /// assert_eq!(Some(1_000_000).and_then(sq_then_to_string), None); // overflowed!\n /// assert_eq!(None.and_then(sq_then_to_string), None);\n /// ```\n ///\n /// Often used to chain fallible operations that may return [`None`].\n ///\n /// ```\n /// let arr_2d = [[\"A0\", \"A1\"], [\"B0\", \"B1\"]];\n ///\n /// let item_0_1 = arr_2d.get(0).and_then(|row| row.get(1));\n /// assert_eq!(item_0_1, Some(&\"A1\"));\n ///\n /// let item_2_0 = arr_2d.get(2).and_then(|row| row.get(0));\n /// assert_eq!(item_2_0, None);\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn and_then(self, f: F) -> Option\n where\n F: ~const FnOnce(T) -> Option,\n F: ~const Destruct,\n {\n match self {\n Some(x) => f(x),\n None => None,\n }\n }\n\n /// Returns [`None`] if the option is [`None`], otherwise calls `predicate`\n /// with the wrapped value and returns:\n ///\n /// - [`Some(t)`] if `predicate` returns `true` (where `t` is the wrapped\n /// value), and\n /// - [`None`] if `predicate` returns `false`.\n ///\n /// This function works similar to [`Iterator::filter()`]. You can imagine\n /// the `Option` being an iterator over one or zero elements. `filter()`\n /// lets you decide which elements to keep.\n ///\n /// # Examples\n ///\n /// ```rust\n /// fn is_even(n: &i32) -> bool {\n /// n % 2 == 0\n /// }\n ///\n /// assert_eq!(None.filter(is_even), None);\n /// assert_eq!(Some(3).filter(is_even), None);\n /// assert_eq!(Some(4).filter(is_even), Some(4));\n /// ```\n ///\n /// [`Some(t)`]: Some\n #[inline]\n #[stable(feature = \"option_filter\", since = \"1.27.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn filter

(self, predicate: P) -> Self\n where\n T: ~const Destruct,\n P: ~const FnOnce(&T) -> bool,\n P: ~const Destruct,\n {\n if let Some(x) = self {\n if predicate(&x) {\n return Some(x);\n }\n }\n None\n }\n\n /// Returns the option if it contains a value, otherwise returns `optb`.\n ///\n /// Arguments passed to `or` are eagerly evaluated; if you are passing the\n /// result of a function call, it is recommended to use [`or_else`], which is\n /// lazily evaluated.\n ///\n /// [`or_else`]: Option::or_else\n ///\n /// # Examples\n ///\n /// ```\n /// let x = Some(2);\n /// let y = None;\n /// assert_eq!(x.or(y), Some(2));\n ///\n /// let x = None;\n /// let y = Some(100);\n /// assert_eq!(x.or(y), Some(100));\n ///\n /// let x = Some(2);\n /// let y = Some(100);\n /// assert_eq!(x.or(y), Some(2));\n ///\n /// let x: Option = None;\n /// let y = None;\n /// assert_eq!(x.or(y), None);\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn or(self, optb: Option) -> Option\n where\n T: ~const Destruct,\n {\n match self {\n Some(x) => Some(x),\n None => optb,\n }\n }\n\n /// Returns the option if it contains a value, otherwise calls `f` and\n /// returns the result.\n ///\n /// # Examples\n ///\n /// ```\n /// fn nobody() -> Option<&'static str> { None }\n /// fn vikings() -> Option<&'static str> { Some(\"vikings\") }\n ///\n /// assert_eq!(Some(\"barbarians\").or_else(vikings), Some(\"barbarians\"));\n /// assert_eq!(None.or_else(vikings), Some(\"vikings\"));\n /// assert_eq!(None.or_else(nobody), None);\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn or_else(self, f: F) -> Option\n where\n F: ~const FnOnce() -> Option,\n F: ~const Destruct,\n {\n match self {\n Some(x) => Some(x),\n None => f(),\n }\n }\n\n /// Returns [`Some`] if exactly one of `self`, `optb` is [`Some`], otherwise returns [`None`].\n ///\n /// # Examples\n ///\n /// ```\n /// let x = Some(2);\n /// let y: Option = None;\n /// assert_eq!(x.xor(y), Some(2));\n ///\n /// let x: Option = None;\n /// let y = Some(2);\n /// assert_eq!(x.xor(y), Some(2));\n ///\n /// let x = Some(2);\n /// let y = Some(2);\n /// assert_eq!(x.xor(y), None);\n ///\n /// let x: Option = None;\n /// let y: Option = None;\n /// assert_eq!(x.xor(y), None);\n /// ```\n #[inline]\n #[stable(feature = \"option_xor\", since = \"1.37.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn xor(self, optb: Option) -> Option\n where\n T: ~const Destruct,\n {\n match (self, optb) {\n (Some(a), None) => Some(a),\n (None, Some(b)) => Some(b),\n _ => None,\n }\n }\n\n /////////////////////////////////////////////////////////////////////////\n // Entry-like operations to insert a value and return a reference\n /////////////////////////////////////////////////////////////////////////\n\n /// Inserts `value` into the option, then returns a mutable reference to it.\n ///\n /// If the option already contains a value, the old value is dropped.\n ///\n /// See also [`Option::get_or_insert`], which doesn't update the value if\n /// the option already contains [`Some`].\n ///\n /// # Example\n ///\n /// ```\n /// let mut opt = None;\n /// let val = opt.insert(1);\n /// assert_eq!(*val, 1);\n /// assert_eq!(opt.unwrap(), 1);\n /// let val = opt.insert(2);\n /// assert_eq!(*val, 2);\n /// *val = 3;\n /// assert_eq!(opt.unwrap(), 3);\n /// ```\n #[must_use = \"if you intended to set a value, consider assignment instead\"]\n #[inline]\n #[stable(feature = \"option_insert\", since = \"1.53.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn insert(&mut self, value: T) -> &mut T\n where\n T: ~const Destruct,\n {\n *self = Some(value);\n\n // SAFETY: the code above just filled the option\n unsafe { self.as_mut().unwrap_unchecked() }\n }\n\n /// Inserts `value` into the option if it is [`None`], then\n /// returns a mutable reference to the contained value.\n ///\n /// See also [`Option::insert`], which updates the value even if\n /// the option already contains [`Some`].\n ///\n /// # Examples\n ///\n /// ```\n /// let mut x = None;\n ///\n /// {\n /// let y: &mut u32 = x.get_or_insert(5);\n /// assert_eq!(y, &5);\n ///\n /// *y = 7;\n /// }\n ///\n /// assert_eq!(x, Some(7));\n /// ```\n #[inline]\n #[stable(feature = \"option_entry\", since = \"1.20.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn get_or_insert(&mut self, value: T) -> &mut T\n where\n T: ~const Destruct,\n {\n if let None = *self {\n *self = Some(value);\n }\n\n // SAFETY: a `None` variant for `self` would have been replaced by a `Some`\n // variant in the code above.\n unsafe { self.as_mut().unwrap_unchecked() }\n }\n\n /// Inserts the default value into the option if it is [`None`], then\n /// returns a mutable reference to the contained value.\n ///\n /// # Examples\n ///\n /// ```\n /// #![feature(option_get_or_insert_default)]\n ///\n /// let mut x = None;\n ///\n /// {\n /// let y: &mut u32 = x.get_or_insert_default();\n /// assert_eq!(y, &0);\n ///\n /// *y = 7;\n /// }\n ///\n /// assert_eq!(x, Some(7));\n /// ```\n #[inline]\n #[unstable(feature = \"option_get_or_insert_default\", issue = \"82901\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn get_or_insert_default(&mut self) -> &mut T\n where\n T: ~const Default,\n {\n const fn default() -> T {\n T::default()\n }\n\n self.get_or_insert_with(default)\n }\n\n /// Inserts a value computed from `f` into the option if it is [`None`],\n /// then returns a mutable reference to the contained value.\n ///\n /// # Examples\n ///\n /// ```\n /// let mut x = None;\n ///\n /// {\n /// let y: &mut u32 = x.get_or_insert_with(|| 5);\n /// assert_eq!(y, &5);\n ///\n /// *y = 7;\n /// }\n ///\n /// assert_eq!(x, Some(7));\n /// ```\n #[inline]\n #[stable(feature = \"option_entry\", since = \"1.20.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn get_or_insert_with(&mut self, f: F) -> &mut T\n where\n F: ~const FnOnce() -> T,\n F: ~const Destruct,\n {\n if let None = *self {\n // the compiler isn't smart enough to know that we are not dropping a `T`\n // here and wants us to ensure `T` can be dropped at compile time.\n mem::forget(mem::replace(self, Some(f())))\n }\n\n // SAFETY: a `None` variant for `self` would have been replaced by a `Some`\n // variant in the code above.\n unsafe { self.as_mut().unwrap_unchecked() }\n }\n\n /////////////////////////////////////////////////////////////////////////\n // Misc\n /////////////////////////////////////////////////////////////////////////\n\n /// Takes the value out of the option, leaving a [`None`] in its place.\n ///\n /// # Examples\n ///\n /// ```\n /// let mut x = Some(2);\n /// let y = x.take();\n /// assert_eq!(x, None);\n /// assert_eq!(y, Some(2));\n ///\n /// let mut x: Option = None;\n /// let y = x.take();\n /// assert_eq!(x, None);\n /// assert_eq!(y, None);\n /// ```\n #[inline]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]\n pub const fn take(&mut self) -> Option {\n // FIXME replace `mem::replace` by `mem::take` when the latter is const ready\n mem::replace(self, None)\n }\n\n /// Replaces the actual value in the option by the value given in parameter,\n /// returning the old value if present,\n /// leaving a [`Some`] in its place without deinitializing either one.\n ///\n /// # Examples\n ///\n /// ```\n /// let mut x = Some(2);\n /// let old = x.replace(5);\n /// assert_eq!(x, Some(5));\n /// assert_eq!(old, Some(2));\n ///\n /// let mut x = None;\n /// let old = x.replace(3);\n /// assert_eq!(x, Some(3));\n /// assert_eq!(old, None);\n /// ```\n #[inline]\n #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]\n #[stable(feature = \"option_replace\", since = \"1.31.0\")]\n pub const fn replace(&mut self, value: T) -> Option {\n mem::replace(self, Some(value))\n }\n\n /// Returns `true` if the option is a [`Some`] value containing the given value.\n ///\n /// # Examples\n ///\n /// ```\n /// #![feature(option_result_contains)]\n ///\n /// let x: Option = Some(2);\n /// assert_eq!(x.contains(&2), true);\n ///\n /// let x: Option = Some(3);\n /// assert_eq!(x.contains(&2), false);\n ///\n /// let x: Option = None;\n /// assert_eq!(x.contains(&2), false);\n /// ```\n #[must_use]\n #[inline]\n #[unstable(feature = \"option_result_contains\", issue = \"62358\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn contains(&self, x: &U) -> bool\n where\n U: ~const PartialEq,\n {\n match self {\n Some(y) => x.eq(y),\n None => false,\n }\n }\n\n /// Zips `self` with another `Option`.\n ///\n /// If `self` is `Some(s)` and `other` is `Some(o)`, this method returns `Some((s, o))`.\n /// Otherwise, `None` is returned.\n ///\n /// # Examples\n ///\n /// ```\n /// let x = Some(1);\n /// let y = Some(\"hi\");\n /// let z = None::;\n ///\n /// assert_eq!(x.zip(y), Some((1, \"hi\")));\n /// assert_eq!(x.zip(z), None);\n /// ```\n #[stable(feature = \"option_zip_option\", since = \"1.46.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn zip(self, other: Option) -> Option<(T, U)>\n where\n T: ~const Destruct,\n U: ~const Destruct,\n {\n match (self, other) {\n (Some(a), Some(b)) => Some((a, b)),\n _ => None,\n }\n }\n\n /// Zips `self` and another `Option` with function `f`.\n ///\n /// If `self` is `Some(s)` and `other` is `Some(o)`, this method returns `Some(f(s, o))`.\n /// Otherwise, `None` is returned.\n ///\n /// # Examples\n ///\n /// ```\n /// #![feature(option_zip)]\n ///\n /// #[derive(Debug, PartialEq)]\n /// struct Point {\n /// x: f64,\n /// y: f64,\n /// }\n ///\n /// impl Point {\n /// fn new(x: f64, y: f64) -> Self {\n /// Self { x, y }\n /// }\n /// }\n ///\n /// let x = Some(17.5);\n /// let y = Some(42.7);\n ///\n /// assert_eq!(x.zip_with(y, Point::new), Some(Point { x: 17.5, y: 42.7 }));\n /// assert_eq!(x.zip_with(None, Point::new), None);\n /// ```\n #[unstable(feature = \"option_zip\", issue = \"70086\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn zip_with(self, other: Option, f: F) -> Option\n where\n F: ~const FnOnce(T, U) -> R,\n F: ~const Destruct,\n T: ~const Destruct,\n U: ~const Destruct,\n {\n match (self, other) {\n (Some(a), Some(b)) => Some(f(a, b)),\n _ => None,\n }\n }\n}\n\nimpl Option<(T, U)> {\n /// Unzips an option containing a tuple of two options.\n ///\n /// If `self` is `Some((a, b))` this method returns `(Some(a), Some(b))`.\n /// Otherwise, `(None, None)` is returned.\n ///\n /// # Examples\n ///\n /// ```\n /// #![feature(unzip_option)]\n ///\n /// let x = Some((1, \"hi\"));\n /// let y = None::<(u8, u32)>;\n ///\n /// assert_eq!(x.unzip(), (Some(1), Some(\"hi\")));\n /// assert_eq!(y.unzip(), (None, None));\n /// ```\n #[inline]\n #[unstable(feature = \"unzip_option\", issue = \"87800\", reason = \"recently added\")]\n pub const fn unzip(self) -> (Option, Option) {\n match self {\n Some((a, b)) => (Some(a), Some(b)),\n None => (None, None),\n }\n }\n}\n\nimpl Option<&T> {\n /// Maps an `Option<&T>` to an `Option` by copying the contents of the\n /// option.\n ///\n /// # Examples\n ///\n /// ```\n /// let x = 12;\n /// let opt_x = Some(&x);\n /// assert_eq!(opt_x, Some(&12));\n /// let copied = opt_x.copied();\n /// assert_eq!(copied, Some(12));\n /// ```\n #[must_use = \"`self` will be dropped if the result is not used\"]\n #[stable(feature = \"copied\", since = \"1.35.0\")]\n #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]\n pub const fn copied(self) -> Option\n where\n T: Copy,\n {\n // FIXME: this implementation, which sidesteps using `Option::map` since it's not const\n // ready yet, should be reverted when possible to avoid code repetition\n match self {\n Some(&v) => Some(v),\n None => None,\n }\n }\n\n /// Maps an `Option<&T>` to an `Option` by cloning the contents of the\n /// option.\n ///\n /// # Examples\n ///\n /// ```\n /// let x = 12;\n /// let opt_x = Some(&x);\n /// assert_eq!(opt_x, Some(&12));\n /// let cloned = opt_x.cloned();\n /// assert_eq!(cloned, Some(12));\n /// ```\n #[must_use = \"`self` will be dropped if the result is not used\"]\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n #[rustc_const_unstable(feature = \"const_option_cloned\", issue = \"91582\")]\n pub const fn cloned(self) -> Option\n where\n T: ~const Clone,\n {\n match self {\n Some(t) => Some(t.clone()),\n None => None,\n }\n }\n}\n\nimpl Option<&mut T> {\n /// Maps an `Option<&mut T>` to an `Option` by copying the contents of the\n /// option.\n ///\n /// # Examples\n ///\n /// ```\n /// let mut x = 12;\n /// let opt_x = Some(&mut x);\n /// assert_eq!(opt_x, Some(&mut 12));\n /// let copied = opt_x.copied();\n /// assert_eq!(copied, Some(12));\n /// ```\n #[must_use = \"`self` will be dropped if the result is not used\"]\n #[stable(feature = \"copied\", since = \"1.35.0\")]\n #[rustc_const_unstable(feature = \"const_option_ext\", issue = \"91930\")]\n pub const fn copied(self) -> Option\n where\n T: Copy,\n {\n match self {\n Some(&mut t) => Some(t),\n None => None,\n }\n }\n\n /// Maps an `Option<&mut T>` to an `Option` by cloning the contents of the\n /// option.\n ///\n /// # Examples\n ///\n /// ```\n /// let mut x = 12;\n /// let opt_x = Some(&mut x);\n /// assert_eq!(opt_x, Some(&mut 12));\n /// let cloned = opt_x.cloned();\n /// assert_eq!(cloned, Some(12));\n /// ```\n #[must_use = \"`self` will be dropped if the result is not used\"]\n #[stable(since = \"1.26.0\", feature = \"option_ref_mut_cloned\")]\n #[rustc_const_unstable(feature = \"const_option_cloned\", issue = \"91582\")]\n pub const fn cloned(self) -> Option\n where\n T: ~const Clone,\n {\n match self {\n Some(t) => Some(t.clone()),\n None => None,\n }\n }\n}\n\nimpl Option> {\n /// Transposes an `Option` of a [`Result`] into a [`Result`] of an `Option`.\n ///\n /// [`None`] will be mapped to [Ok]\\([None]).\n /// [Some]\\([Ok]\\(\\_)) and [Some]\\([Err]\\(\\_)) will be mapped to\n /// [Ok]\\([Some]\\(\\_)) and [Err]\\(\\_).\n ///\n /// # Examples\n ///\n /// ```\n /// #[derive(Debug, Eq, PartialEq)]\n /// struct SomeErr;\n ///\n /// let x: Result, SomeErr> = Ok(Some(5));\n /// let y: Option> = Some(Ok(5));\n /// assert_eq!(x, y.transpose());\n /// ```\n #[inline]\n #[stable(feature = \"transpose_result\", since = \"1.33.0\")]\n #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]\n pub const fn transpose(self) -> Result, E> {\n match self {\n Some(Ok(x)) => Ok(Some(x)),\n Some(Err(e)) => Err(e),\n None => Ok(None),\n }\n }\n}\n\n// This is a separate function to reduce the code size of .expect() itself.\n#[cfg_attr(not(feature = \"panic_immediate_abort\"), inline(never))]\n#[cfg_attr(feature = \"panic_immediate_abort\", inline)]\n#[cold]\n#[track_caller]\n#[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]\nconst fn expect_failed(msg: &str) -> ! {\n panic_str(msg)\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// Trait implementations\n/////////////////////////////////////////////////////////////////////////////\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\n#[rustc_const_unstable(feature = \"const_clone\", issue = \"91805\")]\nimpl const Clone for Option\nwhere\n T: ~const Clone + ~const Destruct,\n{\n #[inline]\n fn clone(&self) -> Self {\n match self {\n Some(x) => Some(x.clone()),\n None => None,\n }\n }\n\n #[inline]\n fn clone_from(&mut self, source: &Self) {\n match (self, source) {\n (Some(to), Some(from)) => to.clone_from(from),\n (to, from) => *to = from.clone(),\n }\n }\n}\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\n#[rustc_const_unstable(feature = \"const_default_impls\", issue = \"87864\")]\nimpl const Default for Option {\n /// Returns [`None`][Option::None].\n ///\n /// # Examples\n ///\n /// ```\n /// let opt: Option = Option::default();\n /// assert!(opt.is_none());\n /// ```\n #[inline]\n fn default() -> Option {\n None\n }\n}\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\nimpl IntoIterator for Option {\n type Item = T;\n type IntoIter = IntoIter;\n\n /// Returns a consuming iterator over the possibly contained value.\n ///\n /// # Examples\n ///\n /// ```\n /// let x = Some(\"string\");\n /// let v: Vec<&str> = x.into_iter().collect();\n /// assert_eq!(v, [\"string\"]);\n ///\n /// let x = None;\n /// let v: Vec<&str> = x.into_iter().collect();\n /// assert!(v.is_empty());\n /// ```\n #[inline]\n fn into_iter(self) -> IntoIter {\n IntoIter { inner: Item { opt: self } }\n }\n}\n\n#[stable(since = \"1.4.0\", feature = \"option_iter\")]\nimpl<'a, T> IntoIterator for &'a Option {\n type Item = &'a T;\n type IntoIter = Iter<'a, T>;\n\n fn into_iter(self) -> Iter<'a, T> {\n self.iter()\n }\n}\n\n#[stable(since = \"1.4.0\", feature = \"option_iter\")]\nimpl<'a, T> IntoIterator for &'a mut Option {\n type Item = &'a mut T;\n type IntoIter = IterMut<'a, T>;\n\n fn into_iter(self) -> IterMut<'a, T> {\n self.iter_mut()\n }\n}\n\n#[stable(since = \"1.12.0\", feature = \"option_from\")]\n#[rustc_const_unstable(feature = \"const_convert\", issue = \"88674\")]\nimpl const From for Option {\n /// Moves `val` into a new [`Some`].\n ///\n /// # Examples\n ///\n /// ```\n /// let o: Option = Option::from(67);\n ///\n /// assert_eq!(Some(67), o);\n /// ```\n fn from(val: T) -> Option {\n Some(val)\n }\n}\n\n#[stable(feature = \"option_ref_from_ref_option\", since = \"1.30.0\")]\n#[rustc_const_unstable(feature = \"const_convert\", issue = \"88674\")]\nimpl<'a, T> const From<&'a Option> for Option<&'a T> {\n /// Converts from `&Option` to `Option<&T>`.\n ///\n /// # Examples\n ///\n /// Converts an [Option]<[String]> into an [Option]<[usize]>, preserving\n /// the original. The [`map`] method takes the `self` argument by value, consuming the original,\n /// so this technique uses `from` to first take an [`Option`] to a reference\n /// to the value inside the original.\n ///\n /// [`map`]: Option::map\n /// [String]: ../../std/string/struct.String.html \"String\"\n ///\n /// ```\n /// let s: Option = Some(String::from(\"Hello, Rustaceans!\"));\n /// let o: Option = Option::from(&s).map(|ss: &String| ss.len());\n ///\n /// println!(\"Can still print s: {s:?}\");\n ///\n /// assert_eq!(o, Some(18));\n /// ```\n fn from(o: &'a Option) -> Option<&'a T> {\n o.as_ref()\n }\n}\n\n#[stable(feature = \"option_ref_from_ref_option\", since = \"1.30.0\")]\n#[rustc_const_unstable(feature = \"const_convert\", issue = \"88674\")]\nimpl<'a, T> const From<&'a mut Option> for Option<&'a mut T> {\n /// Converts from `&mut Option` to `Option<&mut T>`\n ///\n /// # Examples\n ///\n /// ```\n /// let mut s = Some(String::from(\"Hello\"));\n /// let o: Option<&mut String> = Option::from(&mut s);\n ///\n /// match o {\n /// Some(t) => *t = String::from(\"Hello, Rustaceans!\"),\n /// None => (),\n /// }\n ///\n /// assert_eq!(s, Some(String::from(\"Hello, Rustaceans!\")));\n /// ```\n fn from(o: &'a mut Option) -> Option<&'a mut T> {\n o.as_mut()\n }\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// The Option Iterators\n/////////////////////////////////////////////////////////////////////////////\n\n#[derive(Clone, Debug)]\nstruct Item {\n opt: Option,\n}\n\nimpl Iterator for Item {\n type Item = A;\n\n #[inline]\n fn next(&mut self) -> Option {\n self.opt.take()\n }\n\n #[inline]\n fn size_hint(&self) -> (usize, Option) {\n match self.opt {\n Some(_) => (1, Some(1)),\n None => (0, Some(0)),\n }\n }\n}\n\nimpl DoubleEndedIterator for Item {\n #[inline]\n fn next_back(&mut self) -> Option {\n self.opt.take()\n }\n}\n\nimpl ExactSizeIterator for Item {}\nimpl FusedIterator for Item {}\nunsafe impl TrustedLen for Item {}\n\n/// An iterator over a reference to the [`Some`] variant of an [`Option`].\n///\n/// The iterator yields one value if the [`Option`] is a [`Some`], otherwise none.\n///\n/// This `struct` is created by the [`Option::iter`] function.\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\n#[derive(Debug)]\npub struct Iter<'a, A: 'a> {\n inner: Item<&'a A>,\n}\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\nimpl<'a, A> Iterator for Iter<'a, A> {\n type Item = &'a A;\n\n #[inline]\n fn next(&mut self) -> Option<&'a A> {\n self.inner.next()\n }\n #[inline]\n fn size_hint(&self) -> (usize, Option) {\n self.inner.size_hint()\n }\n}\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\nimpl<'a, A> DoubleEndedIterator for Iter<'a, A> {\n #[inline]\n fn next_back(&mut self) -> Option<&'a A> {\n self.inner.next_back()\n }\n}\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\nimpl ExactSizeIterator for Iter<'_, A> {}\n\n#[stable(feature = \"fused\", since = \"1.26.0\")]\nimpl FusedIterator for Iter<'_, A> {}\n\n#[unstable(feature = \"trusted_len\", issue = \"37572\")]\nunsafe impl TrustedLen for Iter<'_, A> {}\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\nimpl Clone for Iter<'_, A> {\n #[inline]\n fn clone(&self) -> Self {\n Iter { inner: self.inner.clone() }\n }\n}\n\n/// An iterator over a mutable reference to the [`Some`] variant of an [`Option`].\n///\n/// The iterator yields one value if the [`Option`] is a [`Some`], otherwise none.\n///\n/// This `struct` is created by the [`Option::iter_mut`] function.\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\n#[derive(Debug)]\npub struct IterMut<'a, A: 'a> {\n inner: Item<&'a mut A>,\n}\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\nimpl<'a, A> Iterator for IterMut<'a, A> {\n type Item = &'a mut A;\n\n #[inline]\n fn next(&mut self) -> Option<&'a mut A> {\n self.inner.next()\n }\n #[inline]\n fn size_hint(&self) -> (usize, Option) {\n self.inner.size_hint()\n }\n}\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\nimpl<'a, A> DoubleEndedIterator for IterMut<'a, A> {\n #[inline]\n fn next_back(&mut self) -> Option<&'a mut A> {\n self.inner.next_back()\n }\n}\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\nimpl ExactSizeIterator for IterMut<'_, A> {}\n\n#[stable(feature = \"fused\", since = \"1.26.0\")]\nimpl FusedIterator for IterMut<'_, A> {}\n#[unstable(feature = \"trusted_len\", issue = \"37572\")]\nunsafe impl TrustedLen for IterMut<'_, A> {}\n\n/// An iterator over the value in [`Some`] variant of an [`Option`].\n///\n/// The iterator yields one value if the [`Option`] is a [`Some`], otherwise none.\n///\n/// This `struct` is created by the [`Option::into_iter`] function.\n#[derive(Clone, Debug)]\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\npub struct IntoIter {\n inner: Item,\n}\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\nimpl Iterator for IntoIter {\n type Item = A;\n\n #[inline]\n fn next(&mut self) -> Option {\n self.inner.next()\n }\n #[inline]\n fn size_hint(&self) -> (usize, Option) {\n self.inner.size_hint()\n }\n}\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\nimpl DoubleEndedIterator for IntoIter {\n #[inline]\n fn next_back(&mut self) -> Option {\n self.inner.next_back()\n }\n}\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\nimpl ExactSizeIterator for IntoIter {}\n\n#[stable(feature = \"fused\", since = \"1.26.0\")]\nimpl FusedIterator for IntoIter {}\n\n#[unstable(feature = \"trusted_len\", issue = \"37572\")]\nunsafe impl TrustedLen for IntoIter {}\n\n/////////////////////////////////////////////////////////////////////////////\n// FromIterator\n/////////////////////////////////////////////////////////////////////////////\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\nimpl> FromIterator> for Option {\n /// Takes each element in the [`Iterator`]: if it is [`None`][Option::None],\n /// no further elements are taken, and the [`None`][Option::None] is\n /// returned. Should no [`None`][Option::None] occur, a container of type\n /// `V` containing the values of each [`Option`] is returned.\n ///\n /// # Examples\n ///\n /// Here is an example which increments every integer in a vector.\n /// We use the checked variant of `add` that returns `None` when the\n /// calculation would result in an overflow.\n ///\n /// ```\n /// let items = vec![0_u16, 1, 2];\n ///\n /// let res: Option> = items\n /// .iter()\n /// .map(|x| x.checked_add(1))\n /// .collect();\n ///\n /// assert_eq!(res, Some(vec![1, 2, 3]));\n /// ```\n ///\n /// As you can see, this will return the expected, valid items.\n ///\n /// Here is another example that tries to subtract one from another list\n /// of integers, this time checking for underflow:\n ///\n /// ```\n /// let items = vec![2_u16, 1, 0];\n ///\n /// let res: Option> = items\n /// .iter()\n /// .map(|x| x.checked_sub(1))\n /// .collect();\n ///\n /// assert_eq!(res, None);\n /// ```\n ///\n /// Since the last element is zero, it would underflow. Thus, the resulting\n /// value is `None`.\n ///\n /// Here is a variation on the previous example, showing that no\n /// further elements are taken from `iter` after the first `None`.\n ///\n /// ```\n /// let items = vec![3_u16, 2, 1, 10];\n ///\n /// let mut shared = 0;\n ///\n /// let res: Option> = items\n /// .iter()\n /// .map(|x| { shared += x; x.checked_sub(2) })\n /// .collect();\n ///\n /// assert_eq!(res, None);\n /// assert_eq!(shared, 6);\n /// ```\n ///\n /// Since the third element caused an underflow, no further elements were taken,\n /// so the final value of `shared` is 6 (= `3 + 2 + 1`), not 16.\n #[inline]\n fn from_iter>>(iter: I) -> Option {\n // FIXME(#11084): This could be replaced with Iterator::scan when this\n // performance bug is closed.\n\n iter::try_process(iter.into_iter(), |i| i.collect())\n }\n}\n\n#[unstable(feature = \"try_trait_v2\", issue = \"84277\")]\n#[rustc_const_unstable(feature = \"const_convert\", issue = \"88674\")]\nimpl const ops::Try for Option {\n type Output = T;\n type Residual = Option;\n\n #[inline]\n fn from_output(output: Self::Output) -> Self {\n Some(output)\n }\n\n #[inline]\n fn branch(self) -> ControlFlow {\n match self {\n Some(v) => ControlFlow::Continue(v),\n None => ControlFlow::Break(None),\n }\n }\n}\n\n#[unstable(feature = \"try_trait_v2\", issue = \"84277\")]\n#[rustc_const_unstable(feature = \"const_convert\", issue = \"88674\")]\nimpl const ops::FromResidual for Option {\n #[inline]\n fn from_residual(residual: Option) -> Self {\n match residual {\n None => None,\n }\n }\n}\n\n#[unstable(feature = \"try_trait_v2_yeet\", issue = \"96374\")]\nimpl ops::FromResidual> for Option {\n #[inline]\n fn from_residual(ops::Yeet(()): ops::Yeet<()>) -> Self {\n None\n }\n}\n\n#[unstable(feature = \"try_trait_v2_residual\", issue = \"91285\")]\nimpl ops::Residual for Option {\n type TryType = Option;\n}\n\nimpl Option> {\n /// Converts from `Option>` to `Option`.\n ///\n /// # Examples\n ///\n /// Basic usage:\n ///\n /// ```\n /// let x: Option> = Some(Some(6));\n /// assert_eq!(Some(6), x.flatten());\n ///\n /// let x: Option> = Some(None);\n /// assert_eq!(None, x.flatten());\n ///\n /// let x: Option> = None;\n /// assert_eq!(None, x.flatten());\n /// ```\n ///\n /// Flattening only removes one level of nesting at a time:\n ///\n /// ```\n /// let x: Option>> = Some(Some(Some(6)));\n /// assert_eq!(Some(Some(6)), x.flatten());\n /// assert_eq!(Some(6), x.flatten().flatten());\n /// ```\n #[inline]\n #[stable(feature = \"option_flattening\", since = \"1.40.0\")]\n #[rustc_const_unstable(feature = \"const_option\", issue = \"67441\")]\n pub const fn flatten(self) -> Option {\n match self {\n Some(inner) => inner,\n None => None,\n }\n }\n}\n","uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","version":0}}} 17:00:16 DEBUG writer-Some("rust") src/rpcclient.rs:254 => Some("rust") {"jsonrpc":"2.0","method":"textDocument/codeLens","params":{"textDocument":{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}},"id":3} 17:00:16 DEBUG reader-Some("rust") src/rpcclient.rs:207 <= Some("rust") {"jsonrpc":"2.0","id":3,"result":[{"range":{"start":{"line":537,"character":4},"end":{"line":554,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::is_some","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":537,"character":4},"end":{"line":554,"character":5}},"targetSelectionRange":{"start":{"line":537,"character":4},"end":{"line":554,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::is_some","--nocapture"]}}]}},{"range":{"start":{"line":556,"character":4},"end":{"line":577,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::is_some_and","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":556,"character":4},"end":{"line":577,"character":5}},"targetSelectionRange":{"start":{"line":556,"character":4},"end":{"line":577,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::is_some_and","--nocapture"]}}]}},{"range":{"start":{"line":579,"character":4},"end":{"line":597,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::is_none","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":579,"character":4},"end":{"line":597,"character":5}},"targetSelectionRange":{"start":{"line":579,"character":4},"end":{"line":597,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::is_none","--nocapture"]}}]}},{"range":{"start":{"line":603,"character":4},"end":{"line":630,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::as_ref","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":603,"character":4},"end":{"line":630,"character":5}},"targetSelectionRange":{"start":{"line":603,"character":4},"end":{"line":630,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::as_ref","--nocapture"]}}]}},{"range":{"start":{"line":632,"character":4},"end":{"line":652,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::as_mut","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":632,"character":4},"end":{"line":652,"character":5}},"targetSelectionRange":{"start":{"line":632,"character":4},"end":{"line":652,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::as_mut","--nocapture"]}}]}},{"range":{"start":{"line":692,"character":4},"end":{"line":739,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::expect","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":692,"character":4},"end":{"line":739,"character":5}},"targetSelectionRange":{"start":{"line":692,"character":4},"end":{"line":739,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::expect","--nocapture"]}}]}},{"range":{"start":{"line":741,"character":4},"end":{"line":776,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::unwrap","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":741,"character":4},"end":{"line":776,"character":5}},"targetSelectionRange":{"start":{"line":741,"character":4},"end":{"line":776,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::unwrap","--nocapture"]}}]}},{"range":{"start":{"line":778,"character":4},"end":{"line":803,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::unwrap_or","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":778,"character":4},"end":{"line":803,"character":5}},"targetSelectionRange":{"start":{"line":778,"character":4},"end":{"line":803,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::unwrap_or","--nocapture"]}}]}},{"range":{"start":{"line":805,"character":4},"end":{"line":826,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::unwrap_or_else","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":805,"character":4},"end":{"line":826,"character":5}},"targetSelectionRange":{"start":{"line":805,"character":4},"end":{"line":826,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::unwrap_or_else","--nocapture"]}}]}},{"range":{"start":{"line":828,"character":4},"end":{"line":865,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::unwrap_or_default","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":828,"character":4},"end":{"line":865,"character":5}},"targetSelectionRange":{"start":{"line":828,"character":4},"end":{"line":865,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::unwrap_or_default","--nocapture"]}}]}},{"range":{"start":{"line":867,"character":4},"end":{"line":898,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::unwrap_unchecked","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":867,"character":4},"end":{"line":898,"character":5}},"targetSelectionRange":{"start":{"line":867,"character":4},"end":{"line":898,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::unwrap_unchecked","--nocapture"]}}]}},{"range":{"start":{"line":904,"character":4},"end":{"line":931,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::map","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":904,"character":4},"end":{"line":931,"character":5}},"targetSelectionRange":{"start":{"line":904,"character":4},"end":{"line":931,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::map","--nocapture"]}}]}},{"range":{"start":{"line":933,"character":4},"end":{"line":961,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::inspect","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":933,"character":4},"end":{"line":961,"character":5}},"targetSelectionRange":{"start":{"line":933,"character":4},"end":{"line":961,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::inspect","--nocapture"]}}]}},{"range":{"start":{"line":963,"character":4},"end":{"line":994,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::map_or","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":963,"character":4},"end":{"line":994,"character":5}},"targetSelectionRange":{"start":{"line":963,"character":4},"end":{"line":994,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::map_or","--nocapture"]}}]}},{"range":{"start":{"line":996,"character":4},"end":{"line":1024,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::map_or_else","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":996,"character":4},"end":{"line":1024,"character":5}},"targetSelectionRange":{"start":{"line":996,"character":4},"end":{"line":1024,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::map_or_else","--nocapture"]}}]}},{"range":{"start":{"line":1026,"character":4},"end":{"line":1058,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::ok_or","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1026,"character":4},"end":{"line":1058,"character":5}},"targetSelectionRange":{"start":{"line":1026,"character":4},"end":{"line":1058,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::ok_or","--nocapture"]}}]}},{"range":{"start":{"line":1060,"character":4},"end":{"line":1088,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::ok_or_else","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1060,"character":4},"end":{"line":1088,"character":5}},"targetSelectionRange":{"start":{"line":1060,"character":4},"end":{"line":1088,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::ok_or_else","--nocapture"]}}]}},{"range":{"start":{"line":1090,"character":4},"end":{"line":1114,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::as_deref","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1090,"character":4},"end":{"line":1114,"character":5}},"targetSelectionRange":{"start":{"line":1090,"character":4},"end":{"line":1114,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::as_deref","--nocapture"]}}]}},{"range":{"start":{"line":1116,"character":4},"end":{"line":1140,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::as_deref_mut","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1116,"character":4},"end":{"line":1140,"character":5}},"targetSelectionRange":{"start":{"line":1116,"character":4},"end":{"line":1140,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::as_deref_mut","--nocapture"]}}]}},{"range":{"start":{"line":1146,"character":4},"end":{"line":1162,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::iter","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1146,"character":4},"end":{"line":1162,"character":5}},"targetSelectionRange":{"start":{"line":1146,"character":4},"end":{"line":1162,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::iter","--nocapture"]}}]}},{"range":{"start":{"line":1164,"character":4},"end":{"line":1183,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::iter_mut","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1164,"character":4},"end":{"line":1183,"character":5}},"targetSelectionRange":{"start":{"line":1164,"character":4},"end":{"line":1183,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::iter_mut","--nocapture"]}}]}},{"range":{"start":{"line":1189,"character":4},"end":{"line":1222,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::and","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1189,"character":4},"end":{"line":1222,"character":5}},"targetSelectionRange":{"start":{"line":1189,"character":4},"end":{"line":1222,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::and","--nocapture"]}}]}},{"range":{"start":{"line":1224,"character":4},"end":{"line":1264,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::and_then","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1224,"character":4},"end":{"line":1264,"character":5}},"targetSelectionRange":{"start":{"line":1224,"character":4},"end":{"line":1264,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::and_then","--nocapture"]}}]}},{"range":{"start":{"line":1266,"character":4},"end":{"line":1305,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::filter","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1266,"character":4},"end":{"line":1305,"character":5}},"targetSelectionRange":{"start":{"line":1266,"character":4},"end":{"line":1305,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::filter","--nocapture"]}}]}},{"range":{"start":{"line":1307,"character":4},"end":{"line":1345,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::or","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1307,"character":4},"end":{"line":1345,"character":5}},"targetSelectionRange":{"start":{"line":1307,"character":4},"end":{"line":1345,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::or","--nocapture"]}}]}},{"range":{"start":{"line":1347,"character":4},"end":{"line":1372,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::or_else","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1347,"character":4},"end":{"line":1372,"character":5}},"targetSelectionRange":{"start":{"line":1347,"character":4},"end":{"line":1372,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::or_else","--nocapture"]}}]}},{"range":{"start":{"line":1374,"character":4},"end":{"line":1407,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::xor","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1374,"character":4},"end":{"line":1407,"character":5}},"targetSelectionRange":{"start":{"line":1374,"character":4},"end":{"line":1407,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::xor","--nocapture"]}}]}},{"range":{"start":{"line":1413,"character":4},"end":{"line":1444,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::insert","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1413,"character":4},"end":{"line":1444,"character":5}},"targetSelectionRange":{"start":{"line":1413,"character":4},"end":{"line":1444,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::insert","--nocapture"]}}]}},{"range":{"start":{"line":1446,"character":4},"end":{"line":1480,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::get_or_insert","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1446,"character":4},"end":{"line":1480,"character":5}},"targetSelectionRange":{"start":{"line":1446,"character":4},"end":{"line":1480,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::get_or_insert","--nocapture"]}}]}},{"range":{"start":{"line":1482,"character":4},"end":{"line":1513,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::get_or_insert_default","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1482,"character":4},"end":{"line":1513,"character":5}},"targetSelectionRange":{"start":{"line":1482,"character":4},"end":{"line":1513,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::get_or_insert_default","--nocapture"]}}]}},{"range":{"start":{"line":1515,"character":4},"end":{"line":1549,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::get_or_insert_with","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1515,"character":4},"end":{"line":1549,"character":5}},"targetSelectionRange":{"start":{"line":1515,"character":4},"end":{"line":1549,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::get_or_insert_with","--nocapture"]}}]}},{"range":{"start":{"line":1555,"character":4},"end":{"line":1576,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::take","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1555,"character":4},"end":{"line":1576,"character":5}},"targetSelectionRange":{"start":{"line":1555,"character":4},"end":{"line":1576,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::take","--nocapture"]}}]}},{"range":{"start":{"line":1578,"character":4},"end":{"line":1600,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::replace","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1578,"character":4},"end":{"line":1600,"character":5}},"targetSelectionRange":{"start":{"line":1578,"character":4},"end":{"line":1600,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::replace","--nocapture"]}}]}},{"range":{"start":{"line":1602,"character":4},"end":{"line":1630,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::contains","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1602,"character":4},"end":{"line":1630,"character":5}},"targetSelectionRange":{"start":{"line":1602,"character":4},"end":{"line":1630,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::contains","--nocapture"]}}]}},{"range":{"start":{"line":1632,"character":4},"end":{"line":1658,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::zip","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1632,"character":4},"end":{"line":1658,"character":5}},"targetSelectionRange":{"start":{"line":1632,"character":4},"end":{"line":1658,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::zip","--nocapture"]}}]}},{"range":{"start":{"line":1660,"character":4},"end":{"line":1701,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::zip_with","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1660,"character":4},"end":{"line":1701,"character":5}},"targetSelectionRange":{"start":{"line":1660,"character":4},"end":{"line":1701,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::zip_with","--nocapture"]}}]}},{"range":{"start":{"line":1705,"character":4},"end":{"line":1728,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option<(T,U)>::unzip","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1705,"character":4},"end":{"line":1728,"character":5}},"targetSelectionRange":{"start":{"line":1705,"character":4},"end":{"line":1728,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option<(T,U)>::unzip","--nocapture"]}}]}},{"range":{"start":{"line":1732,"character":4},"end":{"line":1757,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option<&T>::copied","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1732,"character":4},"end":{"line":1757,"character":5}},"targetSelectionRange":{"start":{"line":1732,"character":4},"end":{"line":1757,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option<&T>::copied","--nocapture"]}}]}},{"range":{"start":{"line":1759,"character":4},"end":{"line":1782,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option<&T>::cloned","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1759,"character":4},"end":{"line":1782,"character":5}},"targetSelectionRange":{"start":{"line":1759,"character":4},"end":{"line":1782,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option<&T>::cloned","--nocapture"]}}]}},{"range":{"start":{"line":1786,"character":4},"end":{"line":1809,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option<&mutT>::copied","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1786,"character":4},"end":{"line":1809,"character":5}},"targetSelectionRange":{"start":{"line":1786,"character":4},"end":{"line":1809,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option<&mutT>::copied","--nocapture"]}}]}},{"range":{"start":{"line":1811,"character":4},"end":{"line":1834,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option<&mutT>::cloned","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1811,"character":4},"end":{"line":1834,"character":5}},"targetSelectionRange":{"start":{"line":1811,"character":4},"end":{"line":1834,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option<&mutT>::cloned","--nocapture"]}}]}},{"range":{"start":{"line":1838,"character":4},"end":{"line":1863,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option>::transpose","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1838,"character":4},"end":{"line":1863,"character":5}},"targetSelectionRange":{"start":{"line":1838,"character":4},"end":{"line":1863,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option>::transpose","--nocapture"]}}]}},{"range":{"start":{"line":1906,"character":4},"end":{"line":1917,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::default","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1906,"character":4},"end":{"line":1917,"character":5}},"targetSelectionRange":{"start":{"line":1906,"character":4},"end":{"line":1917,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::default","--nocapture"]}}]}},{"range":{"start":{"line":1925,"character":4},"end":{"line":1941,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::into_iter","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1925,"character":4},"end":{"line":1941,"character":5}},"targetSelectionRange":{"start":{"line":1925,"character":4},"end":{"line":1941,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::into_iter","--nocapture"]}}]}},{"range":{"start":{"line":1967,"character":4},"end":{"line":1978,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::from","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1967,"character":4},"end":{"line":1978,"character":5}},"targetSelectionRange":{"start":{"line":1967,"character":4},"end":{"line":1978,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::from","--nocapture"]}}]}},{"range":{"start":{"line":1984,"character":4},"end":{"line":2006,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option<&T>::from","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":1984,"character":4},"end":{"line":2006,"character":5}},"targetSelectionRange":{"start":{"line":1984,"character":4},"end":{"line":2006,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option<&T>::from","--nocapture"]}}]}},{"range":{"start":{"line":2012,"character":4},"end":{"line":2029,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option<&mutT>::from","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":2012,"character":4},"end":{"line":2029,"character":5}},"targetSelectionRange":{"start":{"line":2012,"character":4},"end":{"line":2029,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option<&mutT>::from","--nocapture"]}}]}},{"range":{"start":{"line":2208,"character":4},"end":{"line":2274,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option::from_iter","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":2208,"character":4},"end":{"line":2274,"character":5}},"targetSelectionRange":{"start":{"line":2208,"character":4},"end":{"line":2274,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::from_iter","--nocapture"]}}]}},{"range":{"start":{"line":2322,"character":4},"end":{"line":2354,"character":5}},"command":{"title":"▶︎ Run Doctest","command":"rust-analyzer.runSingle","arguments":[{"label":"doctest option::Option>::flatten","location":{"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","targetRange":{"start":{"line":2322,"character":4},"end":{"line":2354,"character":5}},"targetSelectionRange":{"start":{"line":2322,"character":4},"end":{"line":2354,"character":5}}},"kind":"cargo","args":{"overrideCargo":null,"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option>::flatten","--nocapture"]}}]}},{"range":{"start":{"line":517,"character":9},"end":{"line":517,"character":15}},"data":{"impls":{"textDocument":{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},"position":{"line":517,"character":9}}}},{"range":{"start":{"line":2037,"character":7},"end":{"line":2037,"character":11}},"data":{"impls":{"textDocument":{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},"position":{"line":2037,"character":7}}}},{"range":{"start":{"line":2076,"character":11},"end":{"line":2076,"character":15}},"data":{"impls":{"textDocument":{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},"position":{"line":2076,"character":11}}}},{"range":{"start":{"line":2126,"character":11},"end":{"line":2126,"character":18}},"data":{"impls":{"textDocument":{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},"position":{"line":2126,"character":11}}}},{"range":{"start":{"line":2167,"character":11},"end":{"line":2167,"character":19}},"data":{"impls":{"textDocument":{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},"position":{"line":2167,"character":11}}}}]} 17:00:16 DEBUG writer-Some("rust") src/rpcclient.rs:254 => Some("rust") {"jsonrpc":"2.0","method":"codeLens/resolve","params":{"data":{"impls":{"position":{"character":9,"line":517},"textDocument":{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}},"range":{"end":{"character":15,"line":517},"start":{"character":9,"line":517}}},"id":4} 17:00:16 DEBUG reader-Some("rust") src/rpcclient.rs:207 <= Some("rust") {"jsonrpc":"2.0","id":4,"result":{"range":{"start":{"line":517,"character":9},"end":{"line":517,"character":15}},"command":{"title":"75 implementations","command":"rust-analyzer.showReferences","arguments":["file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs",{"line":517,"character":9},[{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":532,"character":0},"end":{"line":1702,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":1704,"character":0},"end":{"line":1729,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":1731,"character":0},"end":{"line":1783,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":1785,"character":0},"end":{"line":1835,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":1837,"character":0},"end":{"line":1864,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2321,"character":0},"end":{"line":2355,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs","range":{"start":{"line":72,"character":0},"end":{"line":77,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs","range":{"start":{"line":79,"character":0},"end":{"line":84,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs","range":{"start":{"line":104,"character":0},"end":{"line":117,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs","range":{"start":{"line":104,"character":0},"end":{"line":117,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs","range":{"start":{"line":104,"character":0},"end":{"line":117,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs","range":{"start":{"line":104,"character":0},"end":{"line":117,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs","range":{"start":{"line":104,"character":0},"end":{"line":117,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs","range":{"start":{"line":104,"character":0},"end":{"line":117,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs","range":{"start":{"line":104,"character":0},"end":{"line":117,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs","range":{"start":{"line":104,"character":0},"end":{"line":117,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs","range":{"start":{"line":104,"character":0},"end":{"line":117,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs","range":{"start":{"line":104,"character":0},"end":{"line":117,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs","range":{"start":{"line":104,"character":0},"end":{"line":117,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs","range":{"start":{"line":104,"character":0},"end":{"line":117,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":514,"character":0},"end":{"line":514,"character":60}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2297,"character":0},"end":{"line":2306,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2308,"character":0},"end":{"line":2314,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2206,"character":0},"end":{"line":2275,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":514,"character":0},"end":{"line":514,"character":60}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":1964,"character":0},"end":{"line":1979,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":1981,"character":0},"end":{"line":2007,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2009,"character":0},"end":{"line":2030,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":1880,"character":0},"end":{"line":1901,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":514,"character":0},"end":{"line":514,"character":60}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2277,"character":0},"end":{"line":2295,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/accum.rs","range":{"start":{"line":216,"character":0},"end":{"line":230,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":514,"character":0},"end":{"line":514,"character":60}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2316,"character":0},"end":{"line":2319,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":1920,"character":0},"end":{"line":1942,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":1944,"character":0},"end":{"line":1952,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":1954,"character":0},"end":{"line":1962,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":514,"character":0},"end":{"line":514,"character":60}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/cmp.rs","range":{"start":{"line":149,"character":0},"end":{"line":157,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":514,"character":0},"end":{"line":514,"character":60}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/equality.rs","range":{"start":{"line":198,"character":0},"end":{"line":215,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/equality.rs","range":{"start":{"line":198,"character":0},"end":{"line":215,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/equality.rs","range":{"start":{"line":198,"character":0},"end":{"line":215,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/equality.rs","range":{"start":{"line":198,"character":0},"end":{"line":215,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/equality.rs","range":{"start":{"line":198,"character":0},"end":{"line":215,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/equality.rs","range":{"start":{"line":198,"character":0},"end":{"line":215,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/equality.rs","range":{"start":{"line":198,"character":0},"end":{"line":215,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/equality.rs","range":{"start":{"line":198,"character":0},"end":{"line":215,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/equality.rs","range":{"start":{"line":198,"character":0},"end":{"line":215,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/equality.rs","range":{"start":{"line":198,"character":0},"end":{"line":215,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/equality.rs","range":{"start":{"line":198,"character":0},"end":{"line":215,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/equality.rs","range":{"start":{"line":198,"character":0},"end":{"line":215,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/accum.rs","range":{"start":{"line":189,"character":0},"end":{"line":214,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":1903,"character":0},"end":{"line":1918,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":514,"character":0},"end":{"line":514,"character":60}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/mod.rs","range":{"start":{"line":421,"character":0},"end":{"line":426,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/mod.rs","range":{"start":{"line":421,"character":0},"end":{"line":426,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/mod.rs","range":{"start":{"line":421,"character":0},"end":{"line":426,"character":2}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/mod.rs","range":{"start":{"line":421,"character":0},"end":{"line":426,"character":2}}},{"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.32/src/context.rs","range":{"start":{"line":175,"character":4},"end":{"line":175,"character":35}}},{"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.32/src/context.rs","range":{"start":{"line":61,"character":0},"end":{"line":96,"character":1}}},{"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/arc-swap-0.4.7/src/ref_cnt.rs","range":{"start":{"line":112,"character":0},"end":{"line":127,"character":1}}},{"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/future/option.rs","range":{"start":{"line":4,"character":0},"end":{"line":14,"character":1}}},{"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/jsonrpc-core-15.1.0/src/calls.rs","range":{"start":{"line":9,"character":0},"end":{"line":9,"character":43}}},{"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/jsonrpc-core-15.1.0/src/io.rs","range":{"start":{"line":380,"character":0},"end":{"line":386,"character":1}}},{"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/parking_lot-0.10.2/src/util.rs","range":{"start":{"line":14,"character":0},"end":{"line":22,"character":1}}},{"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/parking_lot_core-0.7.2/src/util.rs","range":{"start":{"line":12,"character":0},"end":{"line":20,"character":1}}},{"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/quote-1.0.7/src/to_tokens.rs","range":{"start":{"line":108,"character":0},"end":{"line":114,"character":1}}},{"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.114/src/de/impls.rs","range":{"start":{"line":635,"character":0},"end":{"line":653,"character":1}}},{"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.114/src/ser/impls.rs","range":{"start":{"line":98,"character":0},"end":{"line":112,"character":1}}},{"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/syn-1.0.35/src/expr.rs","range":{"start":{"line":2463,"character":4},"end":{"line":2472,"character":5}}},{"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/syn-1.0.35/src/generics.rs","range":{"start":{"line":647,"character":4},"end":{"line":655,"character":5}}},{"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/syn-1.0.35/src/generics.rs","range":{"start":{"line":811,"character":4},"end":{"line":819,"character":5}}},{"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/syn-1.0.35/src/ty.rs","range":{"start":{"line":1057,"character":4},"end":{"line":1065,"character":5}}},{"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/syn-1.0.35/src/parse.rs","range":{"start":{"line":1037,"character":0},"end":{"line":1045,"character":1}}}]]},"data":{"impls":{"textDocument":{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},"position":{"line":517,"character":9}}}}} 17:00:16 DEBUG writer-Some("rust") src/rpcclient.rs:254 => Some("rust") {"jsonrpc":"2.0","method":"codeLens/resolve","params":{"data":{"impls":{"position":{"character":7,"line":2037},"textDocument":{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}},"range":{"end":{"character":11,"line":2037},"start":{"character":7,"line":2037}}},"id":5} 17:00:16 DEBUG reader-Some("rust") src/rpcclient.rs:207 <= Some("rust") {"jsonrpc":"2.0","id":5,"result":{"range":{"start":{"line":2037,"character":7},"end":{"line":2037,"character":11}},"command":{"title":"7 implementations","command":"rust-analyzer.showReferences","arguments":["file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs",{"line":2037,"character":7},[{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2036,"character":0},"end":{"line":2036,"character":23}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2041,"character":0},"end":{"line":2056,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2067,"character":0},"end":{"line":2067,"character":40}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2036,"character":0},"end":{"line":2036,"character":23}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2065,"character":0},"end":{"line":2065,"character":40}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2066,"character":0},"end":{"line":2066,"character":36}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2058,"character":0},"end":{"line":2063,"character":1}}}]]},"data":{"impls":{"textDocument":{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},"position":{"line":2037,"character":7}}}}} 17:00:16 DEBUG writer-Some("rust") src/rpcclient.rs:254 => Some("rust") {"jsonrpc":"2.0","method":"codeLens/resolve","params":{"data":{"impls":{"position":{"character":11,"line":2076},"textDocument":{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}},"range":{"end":{"character":15,"line":2076},"start":{"character":11,"line":2076}}},"id":6} 17:00:16 DEBUG reader-Some("rust") src/rpcclient.rs:207 <= Some("rust") {"jsonrpc":"2.0","id":6,"result":{"range":{"start":{"line":2076,"character":11},"end":{"line":2076,"character":15}},"command":{"title":"8 implementations","command":"rust-analyzer.showReferences","arguments":["file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs",{"line":2076,"character":11},[{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2075,"character":0},"end":{"line":2075,"character":16}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2080,"character":0},"end":{"line":2092,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2108,"character":0},"end":{"line":2109,"character":44}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2111,"character":0},"end":{"line":2117,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2102,"character":0},"end":{"line":2103,"character":44}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2105,"character":0},"end":{"line":2106,"character":40}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2094,"character":0},"end":{"line":2100,"character":1}}},{"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/itertools-0.9.0/src/peeking_take_while.rs","range":{"start":{"line":137,"character":0},"end":{"line":137,"character":61}}}]]},"data":{"impls":{"textDocument":{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},"position":{"line":2076,"character":11}}}}} 17:00:16 DEBUG writer-Some("rust") src/rpcclient.rs:254 => Some("rust") {"jsonrpc":"2.0","method":"codeLens/resolve","params":{"data":{"impls":{"position":{"character":11,"line":2126},"textDocument":{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}},"range":{"end":{"character":18,"line":2126},"start":{"character":11,"line":2126}}},"id":7} 17:00:16 DEBUG reader-Some("rust") src/rpcclient.rs:207 <= Some("rust") {"jsonrpc":"2.0","id":7,"result":{"range":{"start":{"line":2126,"character":11},"end":{"line":2126,"character":18}},"command":{"title":"6 implementations","command":"rust-analyzer.showReferences","arguments":["file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs",{"line":2126,"character":11},[{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2125,"character":0},"end":{"line":2125,"character":16}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2130,"character":0},"end":{"line":2142,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2157,"character":0},"end":{"line":2158,"character":47}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2152,"character":0},"end":{"line":2153,"character":47}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2155,"character":0},"end":{"line":2156,"character":43}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2144,"character":0},"end":{"line":2150,"character":1}}}]]},"data":{"impls":{"textDocument":{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},"position":{"line":2126,"character":11}}}}} 17:00:16 DEBUG writer-Some("rust") src/rpcclient.rs:254 => Some("rust") {"jsonrpc":"2.0","method":"codeLens/resolve","params":{"data":{"impls":{"position":{"character":11,"line":2167},"textDocument":{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}},"range":{"end":{"character":19,"line":2167},"start":{"character":11,"line":2167}}},"id":8} 17:00:16 DEBUG reader-Some("rust") src/rpcclient.rs:207 <= Some("rust") {"jsonrpc":"2.0","id":8,"result":{"range":{"start":{"line":2167,"character":11},"end":{"line":2167,"character":19}},"command":{"title":"7 implementations","command":"rust-analyzer.showReferences","arguments":["file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs",{"line":2167,"character":11},[{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2165,"character":0},"end":{"line":2165,"character":23}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2171,"character":0},"end":{"line":2183,"character":1}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2199,"character":0},"end":{"line":2200,"character":44}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2165,"character":0},"end":{"line":2165,"character":23}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2193,"character":0},"end":{"line":2194,"character":44}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2196,"character":0},"end":{"line":2197,"character":40}}},{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs","range":{"start":{"line":2185,"character":0},"end":{"line":2191,"character":1}}}]]},"data":{"impls":{"textDocument":{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},"position":{"line":2167,"character":11}}}}} 17:00:16 DEBUG unnamed src/language_client.rs:108 state.code_lens./home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs: null ==> [{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::is_some","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::is_some","location":{"targetRange":{"end":{"character":5,"line":554},"start":{"character":4,"line":537}},"targetSelectionRange":{"end":{"character":5,"line":554},"start":{"character":4,"line":537}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":554},"start":{"character":4,"line":537}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::is_some_and","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::is_some_and","location":{"targetRange":{"end":{"character":5,"line":577},"start":{"character":4,"line":556}},"targetSelectionRange":{"end":{"character":5,"line":577},"start":{"character":4,"line":556}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":577},"start":{"character":4,"line":556}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::is_none","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::is_none","location":{"targetRange":{"end":{"character":5,"line":597},"start":{"character":4,"line":579}},"targetSelectionRange":{"end":{"character":5,"line":597},"start":{"character":4,"line":579}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":597},"start":{"character":4,"line":579}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::as_ref","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::as_ref","location":{"targetRange":{"end":{"character":5,"line":630},"start":{"character":4,"line":603}},"targetSelectionRange":{"end":{"character":5,"line":630},"start":{"character":4,"line":603}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":630},"start":{"character":4,"line":603}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::as_mut","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::as_mut","location":{"targetRange":{"end":{"character":5,"line":652},"start":{"character":4,"line":632}},"targetSelectionRange":{"end":{"character":5,"line":652},"start":{"character":4,"line":632}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":652},"start":{"character":4,"line":632}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::expect","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::expect","location":{"targetRange":{"end":{"character":5,"line":739},"start":{"character":4,"line":692}},"targetSelectionRange":{"end":{"character":5,"line":739},"start":{"character":4,"line":692}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":739},"start":{"character":4,"line":692}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::unwrap","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::unwrap","location":{"targetRange":{"end":{"character":5,"line":776},"start":{"character":4,"line":741}},"targetSelectionRange":{"end":{"character":5,"line":776},"start":{"character":4,"line":741}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":776},"start":{"character":4,"line":741}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::unwrap_or","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::unwrap_or","location":{"targetRange":{"end":{"character":5,"line":803},"start":{"character":4,"line":778}},"targetSelectionRange":{"end":{"character":5,"line":803},"start":{"character":4,"line":778}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":803},"start":{"character":4,"line":778}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::unwrap_or_else","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::unwrap_or_else","location":{"targetRange":{"end":{"character":5,"line":826},"start":{"character":4,"line":805}},"targetSelectionRange":{"end":{"character":5,"line":826},"start":{"character":4,"line":805}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":826},"start":{"character":4,"line":805}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::unwrap_or_default","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::unwrap_or_default","location":{"targetRange":{"end":{"character":5,"line":865},"start":{"character":4,"line":828}},"targetSelectionRange":{"end":{"character":5,"line":865},"start":{"character":4,"line":828}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":865},"start":{"character":4,"line":828}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::unwrap_unchecked","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::unwrap_unchecked","location":{"targetRange":{"end":{"character":5,"line":898},"start":{"character":4,"line":867}},"targetSelectionRange":{"end":{"character":5,"line":898},"start":{"character":4,"line":867}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":898},"start":{"character":4,"line":867}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::map","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::map","location":{"targetRange":{"end":{"character":5,"line":931},"start":{"character":4,"line":904}},"targetSelectionRange":{"end":{"character":5,"line":931},"start":{"character":4,"line":904}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":931},"start":{"character":4,"line":904}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::inspect","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::inspect","location":{"targetRange":{"end":{"character":5,"line":961},"start":{"character":4,"line":933}},"targetSelectionRange":{"end":{"character":5,"line":961},"start":{"character":4,"line":933}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":961},"start":{"character":4,"line":933}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::map_or","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::map_or","location":{"targetRange":{"end":{"character":5,"line":994},"start":{"character":4,"line":963}},"targetSelectionRange":{"end":{"character":5,"line":994},"start":{"character":4,"line":963}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":994},"start":{"character":4,"line":963}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::map_or_else","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::map_or_else","location":{"targetRange":{"end":{"character":5,"line":1024},"start":{"character":4,"line":996}},"targetSelectionRange":{"end":{"character":5,"line":1024},"start":{"character":4,"line":996}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1024},"start":{"character":4,"line":996}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::ok_or","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::ok_or","location":{"targetRange":{"end":{"character":5,"line":1058},"start":{"character":4,"line":1026}},"targetSelectionRange":{"end":{"character":5,"line":1058},"start":{"character":4,"line":1026}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1058},"start":{"character":4,"line":1026}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::ok_or_else","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::ok_or_else","location":{"targetRange":{"end":{"character":5,"line":1088},"start":{"character":4,"line":1060}},"targetSelectionRange":{"end":{"character":5,"line":1088},"start":{"character":4,"line":1060}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1088},"start":{"character":4,"line":1060}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::as_deref","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::as_deref","location":{"targetRange":{"end":{"character":5,"line":1114},"start":{"character":4,"line":1090}},"targetSelectionRange":{"end":{"character":5,"line":1114},"start":{"character":4,"line":1090}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1114},"start":{"character":4,"line":1090}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::as_deref_mut","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::as_deref_mut","location":{"targetRange":{"end":{"character":5,"line":1140},"start":{"character":4,"line":1116}},"targetSelectionRange":{"end":{"character":5,"line":1140},"start":{"character":4,"line":1116}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1140},"start":{"character":4,"line":1116}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::iter","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::iter","location":{"targetRange":{"end":{"character":5,"line":1162},"start":{"character":4,"line":1146}},"targetSelectionRange":{"end":{"character":5,"line":1162},"start":{"character":4,"line":1146}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1162},"start":{"character":4,"line":1146}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::iter_mut","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::iter_mut","location":{"targetRange":{"end":{"character":5,"line":1183},"start":{"character":4,"line":1164}},"targetSelectionRange":{"end":{"character":5,"line":1183},"start":{"character":4,"line":1164}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1183},"start":{"character":4,"line":1164}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::and","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::and","location":{"targetRange":{"end":{"character":5,"line":1222},"start":{"character":4,"line":1189}},"targetSelectionRange":{"end":{"character":5,"line":1222},"start":{"character":4,"line":1189}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1222},"start":{"character":4,"line":1189}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::and_then","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::and_then","location":{"targetRange":{"end":{"character":5,"line":1264},"start":{"character":4,"line":1224}},"targetSelectionRange":{"end":{"character":5,"line":1264},"start":{"character":4,"line":1224}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1264},"start":{"character":4,"line":1224}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::filter","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::filter","location":{"targetRange":{"end":{"character":5,"line":1305},"start":{"character":4,"line":1266}},"targetSelectionRange":{"end":{"character":5,"line":1305},"start":{"character":4,"line":1266}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1305},"start":{"character":4,"line":1266}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::or","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::or","location":{"targetRange":{"end":{"character":5,"line":1345},"start":{"character":4,"line":1307}},"targetSelectionRange":{"end":{"character":5,"line":1345},"start":{"character":4,"line":1307}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1345},"start":{"character":4,"line":1307}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::or_else","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::or_else","location":{"targetRange":{"end":{"character":5,"line":1372},"start":{"character":4,"line":1347}},"targetSelectionRange":{"end":{"character":5,"line":1372},"start":{"character":4,"line":1347}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1372},"start":{"character":4,"line":1347}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::xor","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::xor","location":{"targetRange":{"end":{"character":5,"line":1407},"start":{"character":4,"line":1374}},"targetSelectionRange":{"end":{"character":5,"line":1407},"start":{"character":4,"line":1374}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1407},"start":{"character":4,"line":1374}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::insert","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::insert","location":{"targetRange":{"end":{"character":5,"line":1444},"start":{"character":4,"line":1413}},"targetSelectionRange":{"end":{"character":5,"line":1444},"start":{"character":4,"line":1413}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1444},"start":{"character":4,"line":1413}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::get_or_insert","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::get_or_insert","location":{"targetRange":{"end":{"character":5,"line":1480},"start":{"character":4,"line":1446}},"targetSelectionRange":{"end":{"character":5,"line":1480},"start":{"character":4,"line":1446}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1480},"start":{"character":4,"line":1446}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::get_or_insert_default","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::get_or_insert_default","location":{"targetRange":{"end":{"character":5,"line":1513},"start":{"character":4,"line":1482}},"targetSelectionRange":{"end":{"character":5,"line":1513},"start":{"character":4,"line":1482}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1513},"start":{"character":4,"line":1482}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::get_or_insert_with","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::get_or_insert_with","location":{"targetRange":{"end":{"character":5,"line":1549},"start":{"character":4,"line":1515}},"targetSelectionRange":{"end":{"character":5,"line":1549},"start":{"character":4,"line":1515}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1549},"start":{"character":4,"line":1515}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::take","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::take","location":{"targetRange":{"end":{"character":5,"line":1576},"start":{"character":4,"line":1555}},"targetSelectionRange":{"end":{"character":5,"line":1576},"start":{"character":4,"line":1555}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1576},"start":{"character":4,"line":1555}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::replace","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::replace","location":{"targetRange":{"end":{"character":5,"line":1600},"start":{"character":4,"line":1578}},"targetSelectionRange":{"end":{"character":5,"line":1600},"start":{"character":4,"line":1578}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1600},"start":{"character":4,"line":1578}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::contains","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::contains","location":{"targetRange":{"end":{"character":5,"line":1630},"start":{"character":4,"line":1602}},"targetSelectionRange":{"end":{"character":5,"line":1630},"start":{"character":4,"line":1602}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1630},"start":{"character":4,"line":1602}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::zip","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::zip","location":{"targetRange":{"end":{"character":5,"line":1658},"start":{"character":4,"line":1632}},"targetSelectionRange":{"end":{"character":5,"line":1658},"start":{"character":4,"line":1632}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1658},"start":{"character":4,"line":1632}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::zip_with","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::zip_with","location":{"targetRange":{"end":{"character":5,"line":1701},"start":{"character":4,"line":1660}},"targetSelectionRange":{"end":{"character":5,"line":1701},"start":{"character":4,"line":1660}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1701},"start":{"character":4,"line":1660}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option<(T,U)>::unzip","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option<(T,U)>::unzip","location":{"targetRange":{"end":{"character":5,"line":1728},"start":{"character":4,"line":1705}},"targetSelectionRange":{"end":{"character":5,"line":1728},"start":{"character":4,"line":1705}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1728},"start":{"character":4,"line":1705}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option<&T>::copied","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option<&T>::copied","location":{"targetRange":{"end":{"character":5,"line":1757},"start":{"character":4,"line":1732}},"targetSelectionRange":{"end":{"character":5,"line":1757},"start":{"character":4,"line":1732}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1757},"start":{"character":4,"line":1732}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option<&T>::cloned","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option<&T>::cloned","location":{"targetRange":{"end":{"character":5,"line":1782},"start":{"character":4,"line":1759}},"targetSelectionRange":{"end":{"character":5,"line":1782},"start":{"character":4,"line":1759}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1782},"start":{"character":4,"line":1759}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option<&mutT>::copied","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option<&mutT>::copied","location":{"targetRange":{"end":{"character":5,"line":1809},"start":{"character":4,"line":1786}},"targetSelectionRange":{"end":{"character":5,"line":1809},"start":{"character":4,"line":1786}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1809},"start":{"character":4,"line":1786}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option<&mutT>::cloned","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option<&mutT>::cloned","location":{"targetRange":{"end":{"character":5,"line":1834},"start":{"character":4,"line":1811}},"targetSelectionRange":{"end":{"character":5,"line":1834},"start":{"character":4,"line":1811}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1834},"start":{"character":4,"line":1811}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option>::transpose","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option>::transpose","location":{"targetRange":{"end":{"character":5,"line":1863},"start":{"character":4,"line":1838}},"targetSelectionRange":{"end":{"character":5,"line":1863},"start":{"character":4,"line":1838}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1863},"start":{"character":4,"line":1838}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::default","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::default","location":{"targetRange":{"end":{"character":5,"line":1917},"start":{"character":4,"line":1906}},"targetSelectionRange":{"end":{"character":5,"line":1917},"start":{"character":4,"line":1906}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1917},"start":{"character":4,"line":1906}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::into_iter","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::into_iter","location":{"targetRange":{"end":{"character":5,"line":1941},"start":{"character":4,"line":1925}},"targetSelectionRange":{"end":{"character":5,"line":1941},"start":{"character":4,"line":1925}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1941},"start":{"character":4,"line":1925}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::from","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::from","location":{"targetRange":{"end":{"character":5,"line":1978},"start":{"character":4,"line":1967}},"targetSelectionRange":{"end":{"character":5,"line":1978},"start":{"character":4,"line":1967}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":1978},"start":{"character":4,"line":1967}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option<&T>::from","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option<&T>::from","location":{"targetRange":{"end":{"character":5,"line":2006},"start":{"character":4,"line":1984}},"targetSelectionRange":{"end":{"character":5,"line":2006},"start":{"character":4,"line":1984}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":2006},"start":{"character":4,"line":1984}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option<&mutT>::from","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option<&mutT>::from","location":{"targetRange":{"end":{"character":5,"line":2029},"start":{"character":4,"line":2012}},"targetSelectionRange":{"end":{"character":5,"line":2029},"start":{"character":4,"line":2012}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":2029},"start":{"character":4,"line":2012}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option::from_iter","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option::from_iter","location":{"targetRange":{"end":{"character":5,"line":2274},"start":{"character":4,"line":2208}},"targetSelectionRange":{"end":{"character":5,"line":2274},"start":{"character":4,"line":2208}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":2274},"start":{"character":4,"line":2208}}},{"command":{"arguments":[{"args":{"cargoArgs":["test","--doc"],"cargoExtraArgs":[],"executableArgs":["option::Option>::flatten","--nocapture"],"overrideCargo":null},"kind":"cargo","label":"doctest option::Option>::flatten","location":{"targetRange":{"end":{"character":5,"line":2354},"start":{"character":4,"line":2322}},"targetSelectionRange":{"end":{"character":5,"line":2354},"start":{"character":4,"line":2322}},"targetUri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}],"command":"rust-analyzer.runSingle","title":"▶︎ Run Doctest"},"range":{"end":{"character":5,"line":2354},"start":{"character":4,"line":2322}}},{"command":{"arguments":["file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs",{"character":9,"line":517},[{"range":{"end":{"character":1,"line":1702},"start":{"character":0,"line":532}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":1729},"start":{"character":0,"line":1704}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":1783},"start":{"character":0,"line":1731}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":1835},"start":{"character":0,"line":1785}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":1864},"start":{"character":0,"line":1837}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":2355},"start":{"character":0,"line":2321}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":77},"start":{"character":0,"line":72}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs"},{"range":{"end":{"character":1,"line":84},"start":{"character":0,"line":79}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs"},{"range":{"end":{"character":2,"line":117},"start":{"character":0,"line":104}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs"},{"range":{"end":{"character":2,"line":117},"start":{"character":0,"line":104}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs"},{"range":{"end":{"character":2,"line":117},"start":{"character":0,"line":104}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs"},{"range":{"end":{"character":2,"line":117},"start":{"character":0,"line":104}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs"},{"range":{"end":{"character":2,"line":117},"start":{"character":0,"line":104}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs"},{"range":{"end":{"character":2,"line":117},"start":{"character":0,"line":104}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs"},{"range":{"end":{"character":2,"line":117},"start":{"character":0,"line":104}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs"},{"range":{"end":{"character":2,"line":117},"start":{"character":0,"line":104}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs"},{"range":{"end":{"character":2,"line":117},"start":{"character":0,"line":104}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs"},{"range":{"end":{"character":2,"line":117},"start":{"character":0,"line":104}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs"},{"range":{"end":{"character":2,"line":117},"start":{"character":0,"line":104}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs"},{"range":{"end":{"character":2,"line":117},"start":{"character":0,"line":104}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/is_zero.rs"},{"range":{"end":{"character":60,"line":514},"start":{"character":0,"line":514}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":2306},"start":{"character":0,"line":2297}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":2314},"start":{"character":0,"line":2308}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":2275},"start":{"character":0,"line":2206}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":60,"line":514},"start":{"character":0,"line":514}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":1979},"start":{"character":0,"line":1964}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":2007},"start":{"character":0,"line":1981}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":2030},"start":{"character":0,"line":2009}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":1901},"start":{"character":0,"line":1880}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":60,"line":514},"start":{"character":0,"line":514}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":2295},"start":{"character":0,"line":2277}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":230},"start":{"character":0,"line":216}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/accum.rs"},{"range":{"end":{"character":60,"line":514},"start":{"character":0,"line":514}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":2319},"start":{"character":0,"line":2316}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":1942},"start":{"character":0,"line":1920}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":1952},"start":{"character":0,"line":1944}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":1962},"start":{"character":0,"line":1954}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":60,"line":514},"start":{"character":0,"line":514}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":157},"start":{"character":0,"line":149}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/cmp.rs"},{"range":{"end":{"character":60,"line":514},"start":{"character":0,"line":514}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":2,"line":215},"start":{"character":0,"line":198}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/equality.rs"},{"range":{"end":{"character":2,"line":215},"start":{"character":0,"line":198}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/equality.rs"},{"range":{"end":{"character":2,"line":215},"start":{"character":0,"line":198}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/equality.rs"},{"range":{"end":{"character":2,"line":215},"start":{"character":0,"line":198}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/equality.rs"},{"range":{"end":{"character":2,"line":215},"start":{"character":0,"line":198}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/equality.rs"},{"range":{"end":{"character":2,"line":215},"start":{"character":0,"line":198}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/equality.rs"},{"range":{"end":{"character":2,"line":215},"start":{"character":0,"line":198}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/equality.rs"},{"range":{"end":{"character":2,"line":215},"start":{"character":0,"line":198}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/equality.rs"},{"range":{"end":{"character":2,"line":215},"start":{"character":0,"line":198}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/equality.rs"},{"range":{"end":{"character":2,"line":215},"start":{"character":0,"line":198}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/equality.rs"},{"range":{"end":{"character":2,"line":215},"start":{"character":0,"line":198}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/equality.rs"},{"range":{"end":{"character":2,"line":215},"start":{"character":0,"line":198}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/array/equality.rs"},{"range":{"end":{"character":1,"line":214},"start":{"character":0,"line":189}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/accum.rs"},{"range":{"end":{"character":1,"line":1918},"start":{"character":0,"line":1903}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":60,"line":514},"start":{"character":0,"line":514}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":2,"line":426},"start":{"character":0,"line":421}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/mod.rs"},{"range":{"end":{"character":2,"line":426},"start":{"character":0,"line":421}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/mod.rs"},{"range":{"end":{"character":2,"line":426},"start":{"character":0,"line":421}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/mod.rs"},{"range":{"end":{"character":2,"line":426},"start":{"character":0,"line":421}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/mod.rs"},{"range":{"end":{"character":35,"line":175},"start":{"character":4,"line":175}},"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.32/src/context.rs"},{"range":{"end":{"character":1,"line":96},"start":{"character":0,"line":61}},"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.32/src/context.rs"},{"range":{"end":{"character":1,"line":127},"start":{"character":0,"line":112}},"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/arc-swap-0.4.7/src/ref_cnt.rs"},{"range":{"end":{"character":1,"line":14},"start":{"character":0,"line":4}},"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/future/option.rs"},{"range":{"end":{"character":43,"line":9},"start":{"character":0,"line":9}},"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/jsonrpc-core-15.1.0/src/calls.rs"},{"range":{"end":{"character":1,"line":386},"start":{"character":0,"line":380}},"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/jsonrpc-core-15.1.0/src/io.rs"},{"range":{"end":{"character":1,"line":22},"start":{"character":0,"line":14}},"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/parking_lot-0.10.2/src/util.rs"},{"range":{"end":{"character":1,"line":20},"start":{"character":0,"line":12}},"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/parking_lot_core-0.7.2/src/util.rs"},{"range":{"end":{"character":1,"line":114},"start":{"character":0,"line":108}},"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/quote-1.0.7/src/to_tokens.rs"},{"range":{"end":{"character":1,"line":653},"start":{"character":0,"line":635}},"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.114/src/de/impls.rs"},{"range":{"end":{"character":1,"line":112},"start":{"character":0,"line":98}},"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.114/src/ser/impls.rs"},{"range":{"end":{"character":5,"line":2472},"start":{"character":4,"line":2463}},"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/syn-1.0.35/src/expr.rs"},{"range":{"end":{"character":5,"line":655},"start":{"character":4,"line":647}},"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/syn-1.0.35/src/generics.rs"},{"range":{"end":{"character":5,"line":819},"start":{"character":4,"line":811}},"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/syn-1.0.35/src/generics.rs"},{"range":{"end":{"character":5,"line":1065},"start":{"character":4,"line":1057}},"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/syn-1.0.35/src/ty.rs"},{"range":{"end":{"character":1,"line":1045},"start":{"character":0,"line":1037}},"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/syn-1.0.35/src/parse.rs"}]],"command":"rust-analyzer.showReferences","title":"75 implementations"},"data":{"impls":{"position":{"character":9,"line":517},"textDocument":{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}},"range":{"end":{"character":15,"line":517},"start":{"character":9,"line":517}}},{"command":{"arguments":["file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs",{"character":7,"line":2037},[{"range":{"end":{"character":23,"line":2036},"start":{"character":0,"line":2036}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":2056},"start":{"character":0,"line":2041}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":40,"line":2067},"start":{"character":0,"line":2067}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":23,"line":2036},"start":{"character":0,"line":2036}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":40,"line":2065},"start":{"character":0,"line":2065}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":36,"line":2066},"start":{"character":0,"line":2066}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":2063},"start":{"character":0,"line":2058}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}]],"command":"rust-analyzer.showReferences","title":"7 implementations"},"data":{"impls":{"position":{"character":7,"line":2037},"textDocument":{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}},"range":{"end":{"character":11,"line":2037},"start":{"character":7,"line":2037}}},{"command":{"arguments":["file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs",{"character":11,"line":2076},[{"range":{"end":{"character":16,"line":2075},"start":{"character":0,"line":2075}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":2092},"start":{"character":0,"line":2080}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":44,"line":2109},"start":{"character":0,"line":2108}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":2117},"start":{"character":0,"line":2111}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":44,"line":2103},"start":{"character":0,"line":2102}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":40,"line":2106},"start":{"character":0,"line":2105}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":2100},"start":{"character":0,"line":2094}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":61,"line":137},"start":{"character":0,"line":137}},"uri":"file:///home/dick/.cargo/registry/src/github.com-1ecc6299db9ec823/itertools-0.9.0/src/peeking_take_while.rs"}]],"command":"rust-analyzer.showReferences","title":"8 implementations"},"data":{"impls":{"position":{"character":11,"line":2076},"textDocument":{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}},"range":{"end":{"character":15,"line":2076},"start":{"character":11,"line":2076}}},{"command":{"arguments":["file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs",{"character":11,"line":2126},[{"range":{"end":{"character":16,"line":2125},"start":{"character":0,"line":2125}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":2142},"start":{"character":0,"line":2130}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":47,"line":2158},"start":{"character":0,"line":2157}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":47,"line":2153},"start":{"character":0,"line":2152}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":43,"line":2156},"start":{"character":0,"line":2155}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":2150},"start":{"character":0,"line":2144}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}]],"command":"rust-analyzer.showReferences","title":"6 implementations"},"data":{"impls":{"position":{"character":11,"line":2126},"textDocument":{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}},"range":{"end":{"character":18,"line":2126},"start":{"character":11,"line":2126}}},{"command":{"arguments":["file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs",{"character":11,"line":2167},[{"range":{"end":{"character":23,"line":2165},"start":{"character":0,"line":2165}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":2183},"start":{"character":0,"line":2171}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":44,"line":2200},"start":{"character":0,"line":2199}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":23,"line":2165},"start":{"character":0,"line":2165}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":44,"line":2194},"start":{"character":0,"line":2193}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":40,"line":2197},"start":{"character":0,"line":2196}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"},{"range":{"end":{"character":1,"line":2191},"start":{"character":0,"line":2185}},"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}]],"command":"rust-analyzer.showReferences","title":"7 implementations"},"data":{"impls":{"position":{"character":11,"line":2167},"textDocument":{"uri":"file:///home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}}},"range":{"end":{"character":19,"line":2167},"start":{"character":11,"line":2167}}}] 17:00:16 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"mode","params":[],"id":31} 17:00:16 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 31, "jsonrpc": "2.0", "result": "n"} 17:00:16 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_virtual_texts","params":[2,3,0,22,[]],"id":32} 17:00:16 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 32, "jsonrpc": "2.0", "result": 0} 17:00:16 DEBUG unnamed src/language_client.rs:108 state.inlay_hints./home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs: null ==> [] 17:00:16 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 2, "viewport": {"end": 1899, "start": 1877}, "languageId": "rust", "buftype": "", "position": {"character": 7, "line": 1887}, "filename": "/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}} 17:00:16 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(2), "buftype": String(""), "filename": String("/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"), "languageId": String("rust"), "position": Object({"character": Number(7), "line": Number(1887)}), "viewport": Object({"end": Number(1899), "start": Number(1877)})}) force_redraw=false 17:00:16 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 49 ==> 1887 17:00:16 INFO unnamed src/language_server_protocol.rs:2847 get_signs_to_display; filename="/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs" viewport=Viewport { start: 1877, end: 1899 } 17:00:16 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs: null ==> {"end":1899,"start":1877} 17:00:16 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_signs","params":["/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs",[]],"id":33} 17:00:16 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 33, "jsonrpc": "2.0", "result": 0} 17:00:16 DEBUG unnamed src/language_client.rs:108 state.highlights./home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs: null ==> [] 17:00:16 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:ClearHighlights","params":["__LCN_DIAGNOSTIC_HIGHLIGHT__"]} 17:00:16 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"mode","params":[],"id":34} 17:00:16 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 34, "jsonrpc": "2.0", "result": "n"} 17:00:16 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_virtual_texts","params":[2,3,1877,1899,[]],"id":35} 17:00:16 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 35, "jsonrpc": "2.0", "result": 0} 17:04:21 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 2, "viewport": {"end": 22, "start": 0}, "languageId": "rust", "buftype": "", "position": {"character": 7, "line": 0}, "filename": "/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}} 17:04:21 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(2), "buftype": String(""), "filename": String("/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"), "languageId": String("rust"), "position": Object({"character": Number(7), "line": Number(0)}), "viewport": Object({"end": Number(22), "start": Number(0)})}) force_redraw=false 17:04:21 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 1887 ==> 0 17:04:21 INFO unnamed src/language_server_protocol.rs:2847 get_signs_to_display; filename="/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs" viewport=Viewport { start: 0, end: 22 } 17:04:21 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs.start: 1877 ==> 0 17:04:21 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs.end: 1899 ==> 22 17:04:21 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_signs","params":["/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs",[]],"id":36} 17:04:21 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 36, "jsonrpc": "2.0", "result": 0} 17:04:21 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:ClearHighlights","params":["__LCN_DIAGNOSTIC_HIGHLIGHT__"]} 17:04:21 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"mode","params":[],"id":37} 17:04:21 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 37, "jsonrpc": "2.0", "result": "n"} 17:04:21 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_virtual_texts","params":[2,3,0,22,[]],"id":38} 17:04:21 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 38, "jsonrpc": "2.0", "result": 0} 17:04:30 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 2, "viewport": {"end": 42, "start": 20}, "languageId": "rust", "buftype": "", "position": {"character": 2, "line": 20}, "filename": "/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}} 17:04:30 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(2), "buftype": String(""), "filename": String("/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"), "languageId": String("rust"), "position": Object({"character": Number(2), "line": Number(20)}), "viewport": Object({"end": Number(42), "start": Number(20)})}) force_redraw=false 17:04:30 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 0 ==> 20 17:04:30 INFO unnamed src/language_server_protocol.rs:2847 get_signs_to_display; filename="/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs" viewport=Viewport { start: 20, end: 42 } 17:04:30 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs.end: 22 ==> 42 17:04:30 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs.start: 0 ==> 20 17:04:30 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_signs","params":["/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs",[]],"id":39} 17:04:30 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 39, "jsonrpc": "2.0", "result": 0} 17:04:30 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:ClearHighlights","params":["__LCN_DIAGNOSTIC_HIGHLIGHT__"]} 17:04:30 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"mode","params":[],"id":40} 17:04:30 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 40, "jsonrpc": "2.0", "result": "n"} 17:04:30 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_virtual_texts","params":[2,3,20,42,[]],"id":41} 17:04:30 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 41, "jsonrpc": "2.0", "result": 0} 17:04:30 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 2, "viewport": {"end": 62, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 6, "line": 40}, "filename": "/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}} 17:04:30 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(2), "buftype": String(""), "filename": String("/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"), "languageId": String("rust"), "position": Object({"character": Number(6), "line": Number(40)}), "viewport": Object({"end": Number(62), "start": Number(40)})}) force_redraw=false 17:04:30 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 20 ==> 40 17:04:30 INFO unnamed src/language_server_protocol.rs:2847 get_signs_to_display; filename="/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs" viewport=Viewport { start: 40, end: 62 } 17:04:30 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs.end: 42 ==> 62 17:04:30 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs.start: 20 ==> 40 17:04:30 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_signs","params":["/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs",[]],"id":42} 17:04:30 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 42, "jsonrpc": "2.0", "result": 0} 17:04:30 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:ClearHighlights","params":["__LCN_DIAGNOSTIC_HIGHLIGHT__"]} 17:04:30 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"mode","params":[],"id":43} 17:04:30 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 43, "jsonrpc": "2.0", "result": "n"} 17:04:30 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_virtual_texts","params":[2,3,40,62,[]],"id":44} 17:04:30 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 44, "jsonrpc": "2.0", "result": 0} 17:04:31 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 2, "viewport": {"end": 82, "start": 60}, "languageId": "rust", "buftype": "", "position": {"character": 7, "line": 60}, "filename": "/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}} 17:04:31 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(2), "buftype": String(""), "filename": String("/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"), "languageId": String("rust"), "position": Object({"character": Number(7), "line": Number(60)}), "viewport": Object({"end": Number(82), "start": Number(60)})}) force_redraw=false 17:04:31 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 40 ==> 60 17:04:31 INFO unnamed src/language_server_protocol.rs:2847 get_signs_to_display; filename="/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs" viewport=Viewport { start: 60, end: 82 } 17:04:31 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs.end: 62 ==> 82 17:04:31 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs.start: 40 ==> 60 17:04:31 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_signs","params":["/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs",[]],"id":45} 17:04:31 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 45, "jsonrpc": "2.0", "result": 0} 17:04:31 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:ClearHighlights","params":["__LCN_DIAGNOSTIC_HIGHLIGHT__"]} 17:04:31 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"mode","params":[],"id":46} 17:04:31 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 46, "jsonrpc": "2.0", "result": "n"} 17:04:31 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_virtual_texts","params":[2,3,60,82,[]],"id":47} 17:04:31 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 47, "jsonrpc": "2.0", "result": 0} 17:04:31 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 2, "viewport": {"end": 101, "start": 80}, "languageId": "rust", "buftype": "", "position": {"character": 7, "line": 80}, "filename": "/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}} 17:04:31 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(2), "buftype": String(""), "filename": String("/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"), "languageId": String("rust"), "position": Object({"character": Number(7), "line": Number(80)}), "viewport": Object({"end": Number(101), "start": Number(80)})}) force_redraw=false 17:04:31 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 60 ==> 80 17:04:31 INFO unnamed src/language_server_protocol.rs:2847 get_signs_to_display; filename="/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs" viewport=Viewport { start: 80, end: 101 } 17:04:31 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs.end: 82 ==> 101 17:04:31 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs.start: 60 ==> 80 17:04:31 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_signs","params":["/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs",[]],"id":48} 17:04:31 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 48, "jsonrpc": "2.0", "result": 0} 17:04:31 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:ClearHighlights","params":["__LCN_DIAGNOSTIC_HIGHLIGHT__"]} 17:04:31 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"mode","params":[],"id":49} 17:04:31 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 49, "jsonrpc": "2.0", "result": "n"} 17:04:31 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_virtual_texts","params":[2,3,80,101,[]],"id":50} 17:04:31 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 50, "jsonrpc": "2.0", "result": 0} 17:04:31 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 2, "viewport": {"end": 119, "start": 99}, "languageId": "rust", "buftype": "", "position": {"character": 2, "line": 99}, "filename": "/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}} 17:04:31 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(2), "buftype": String(""), "filename": String("/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"), "languageId": String("rust"), "position": Object({"character": Number(2), "line": Number(99)}), "viewport": Object({"end": Number(119), "start": Number(99)})}) force_redraw=false 17:04:31 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 80 ==> 99 17:04:31 INFO unnamed src/language_server_protocol.rs:2847 get_signs_to_display; filename="/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs" viewport=Viewport { start: 99, end: 119 } 17:04:31 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs.end: 101 ==> 119 17:04:31 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs.start: 80 ==> 99 17:04:31 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_signs","params":["/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs",[]],"id":51} 17:04:31 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 51, "jsonrpc": "2.0", "result": 0} 17:04:31 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:ClearHighlights","params":["__LCN_DIAGNOSTIC_HIGHLIGHT__"]} 17:04:31 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"mode","params":[],"id":52} 17:04:31 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 52, "jsonrpc": "2.0", "result": "n"} 17:04:31 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_virtual_texts","params":[2,3,99,119,[]],"id":53} 17:04:31 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 53, "jsonrpc": "2.0", "result": 0} 17:04:32 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 2, "viewport": {"end": 139, "start": 117}, "languageId": "rust", "buftype": "", "position": {"character": 7, "line": 117}, "filename": "/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}} 17:04:32 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(2), "buftype": String(""), "filename": String("/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"), "languageId": String("rust"), "position": Object({"character": Number(7), "line": Number(117)}), "viewport": Object({"end": Number(139), "start": Number(117)})}) force_redraw=false 17:04:32 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 99 ==> 117 17:04:32 INFO unnamed src/language_server_protocol.rs:2847 get_signs_to_display; filename="/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs" viewport=Viewport { start: 117, end: 139 } 17:04:32 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs.start: 99 ==> 117 17:04:32 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs.end: 119 ==> 139 17:04:32 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_signs","params":["/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs",[]],"id":54} 17:04:32 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 54, "jsonrpc": "2.0", "result": 0} 17:04:32 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:ClearHighlights","params":["__LCN_DIAGNOSTIC_HIGHLIGHT__"]} 17:04:32 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"mode","params":[],"id":55} 17:04:32 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 55, "jsonrpc": "2.0", "result": "n"} 17:04:32 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_virtual_texts","params":[2,3,117,139,[]],"id":56} 17:04:32 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 56, "jsonrpc": "2.0", "result": 0} 17:04:32 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 2, "viewport": {"end": 159, "start": 137}, "languageId": "rust", "buftype": "", "position": {"character": 2, "line": 137}, "filename": "/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}} 17:04:32 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(2), "buftype": String(""), "filename": String("/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"), "languageId": String("rust"), "position": Object({"character": Number(2), "line": Number(137)}), "viewport": Object({"end": Number(159), "start": Number(137)})}) force_redraw=false 17:04:32 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 117 ==> 137 17:04:32 INFO unnamed src/language_server_protocol.rs:2847 get_signs_to_display; filename="/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs" viewport=Viewport { start: 137, end: 159 } 17:04:32 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs.start: 117 ==> 137 17:04:32 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs.end: 139 ==> 159 17:04:32 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_signs","params":["/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs",[]],"id":57} 17:04:32 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 57, "jsonrpc": "2.0", "result": 0} 17:04:32 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:ClearHighlights","params":["__LCN_DIAGNOSTIC_HIGHLIGHT__"]} 17:04:32 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"mode","params":[],"id":58} 17:04:32 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 58, "jsonrpc": "2.0", "result": "n"} 17:04:32 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_virtual_texts","params":[2,3,137,159,[]],"id":59} 17:04:32 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 59, "jsonrpc": "2.0", "result": 0} 17:04:32 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 2, "viewport": {"end": 179, "start": 157}, "languageId": "rust", "buftype": "", "position": {"character": 7, "line": 157}, "filename": "/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"}} 17:04:32 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(2), "buftype": String(""), "filename": String("/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs"), "languageId": String("rust"), "position": Object({"character": Number(7), "line": Number(157)}), "viewport": Object({"end": Number(179), "start": Number(157)})}) force_redraw=false 17:04:32 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 137 ==> 157 17:04:32 INFO unnamed src/language_server_protocol.rs:2847 get_signs_to_display; filename="/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs" viewport=Viewport { start: 157, end: 179 } 17:04:32 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs.start: 137 ==> 157 17:04:32 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs.end: 159 ==> 179 17:04:32 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_signs","params":["/home/dick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs",[]],"id":60} 17:04:32 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 60, "jsonrpc": "2.0", "result": 0} 17:04:32 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:ClearHighlights","params":["__LCN_DIAGNOSTIC_HIGHLIGHT__"]} 17:04:32 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"mode","params":[],"id":61} 17:04:32 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 61, "jsonrpc": "2.0", "result": "n"} 17:04:32 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_virtual_texts","params":[2,3,157,179,[]],"id":62} 17:04:32 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 62, "jsonrpc": "2.0", "result": 0} 17:04:36 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleBufEnter", "jsonrpc": "2.0", "params": {"bufnr": 1, "languageId": "rust", "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 17:04:36 INFO unnamed src/language_server_protocol.rs:2739 handle_buf_enter; params=Object({"bufnr": Number(1), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust")}) 17:04:36 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"setbufvar","params":["/home/dick/LanguageClient-neovim/src/rpcclient.rs","LanguageClient_isServerRunning",1]} 17:04:36 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 45, "line": 49}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 17:04:36 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(45), "line": Number(49)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 17:04:36 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 157 ==> 49 17:04:39 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 45, "line": 50}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 17:04:39 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(45), "line": Number(50)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 17:04:39 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 49 ==> 50 17:04:39 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 45, "line": 51}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 17:04:39 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(45), "line": Number(51)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 17:04:39 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 50 ==> 51 17:04:39 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 45, "line": 50}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 17:04:39 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(45), "line": Number(50)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 17:04:39 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 51 ==> 50 17:04:40 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 45, "line": 49}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 17:04:40 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(45), "line": Number(49)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 17:04:40 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 50 ==> 49 20:30:13 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 0, "line": 48}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 20:30:13 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(0), "line": Number(48)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 20:30:13 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 49 ==> 48 20:30:13 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 45, "line": 49}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 20:30:13 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(45), "line": Number(49)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 20:30:13 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 48 ==> 49 20:30:15 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 45, "line": 50}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 20:30:15 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(45), "line": Number(50)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 20:30:15 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 49 ==> 50 20:30:16 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 45, "line": 51}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 20:30:16 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(45), "line": Number(51)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 20:30:16 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 50 ==> 51 20:30:16 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 29, "line": 52}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 20:30:16 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(29), "line": Number(52)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 20:30:16 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 51 ==> 52 20:30:17 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 45, "line": 51}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 20:30:17 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(45), "line": Number(51)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 20:30:17 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 52 ==> 51 20:30:17 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 45, "line": 50}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 20:30:17 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(45), "line": Number(50)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 20:30:17 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 51 ==> 50 20:30:17 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 45, "line": 49}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 20:30:17 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(45), "line": Number(49)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 20:30:17 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 50 ==> 49 20:30:18 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 0, "line": 48}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 20:30:18 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(0), "line": Number(48)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 20:30:18 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 49 ==> 48 20:30:19 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 45, "line": 49}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 20:30:19 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(45), "line": Number(49)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 20:30:19 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 48 ==> 49 22:39:14 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 45, "line": 50}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 22:39:14 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(45), "line": Number(50)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 22:39:14 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 49 ==> 50 22:39:15 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 45, "line": 51}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 22:39:15 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(45), "line": Number(51)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 22:39:15 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 50 ==> 51 22:39:15 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 45, "line": 50}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 22:39:15 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(45), "line": Number(50)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 22:39:15 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 51 ==> 50 22:39:15 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 45, "line": 49}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 22:39:15 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(45), "line": Number(49)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 22:39:15 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 50 ==> 49 22:39:15 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 0, "line": 48}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 22:39:15 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(0), "line": Number(48)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 22:39:15 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 49 ==> 48 22:39:17 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 45, "line": 49}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 22:39:17 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(45), "line": Number(49)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 22:39:17 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 48 ==> 49 22:39:17 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 0, "line": 48}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 22:39:17 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(0), "line": Number(48)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 22:39:17 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 49 ==> 48 22:39:18 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 45, "line": 47}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 22:39:18 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(45), "line": Number(47)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 22:39:18 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 48 ==> 47 22:39:18 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 0, "line": 48}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 22:39:18 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(0), "line": Number(48)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 22:39:18 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 47 ==> 48 22:39:19 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 75, "start": 57}, "languageId": "rust", "buftype": "", "position": {"character": 45, "line": 57}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 22:39:19 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(45), "line": Number(57)}), "viewport": Object({"end": Number(75), "start": Number(57)})}) force_redraw=false 22:39:19 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 48 ==> 57 22:39:19 INFO unnamed src/language_server_protocol.rs:2847 get_signs_to_display; filename="/home/dick/LanguageClient-neovim/src/rpcclient.rs" viewport=Viewport { start: 57, end: 75 } 22:39:19 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/LanguageClient-neovim/src/rpcclient.rs.start: 40 ==> 57 22:39:19 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/LanguageClient-neovim/src/rpcclient.rs.end: 59 ==> 75 22:39:19 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_signs","params":["/home/dick/LanguageClient-neovim/src/rpcclient.rs",[]],"id":63} 22:39:19 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 63, "jsonrpc": "2.0", "result": 0} 22:39:19 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:ClearHighlights","params":["__LCN_DIAGNOSTIC_HIGHLIGHT__"]} 22:39:19 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"mode","params":[],"id":64} 22:39:19 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 64, "jsonrpc": "2.0", "result": "n"} 22:39:19 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_virtual_texts","params":[1,3,57,75,[]],"id":65} 22:39:19 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 65, "jsonrpc": "2.0", "result": 0} 22:39:19 DEBUG reader-None src/rpcclient.rs:207 <= None {"method": "languageClient/handleCursorMoved", "jsonrpc": "2.0", "params": {"bufnr": 1, "viewport": {"end": 59, "start": 40}, "languageId": "rust", "buftype": "", "position": {"character": 45, "line": 58}, "filename": "/home/dick/LanguageClient-neovim/src/rpcclient.rs"}} 22:39:19 INFO unnamed src/language_server_protocol.rs:2873 handle_cursor_moved; params=Object({"bufnr": Number(1), "buftype": String(""), "filename": String("/home/dick/LanguageClient-neovim/src/rpcclient.rs"), "languageId": String("rust"), "position": Object({"character": Number(45), "line": Number(58)}), "viewport": Object({"end": Number(59), "start": Number(40)})}) force_redraw=false 22:39:19 DEBUG unnamed src/language_client.rs:108 state.last_cursor_line: 57 ==> 58 22:39:19 INFO unnamed src/language_server_protocol.rs:2847 get_signs_to_display; filename="/home/dick/LanguageClient-neovim/src/rpcclient.rs" viewport=Viewport { start: 40, end: 59 } 22:39:19 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/LanguageClient-neovim/src/rpcclient.rs.end: 75 ==> 59 22:39:19 DEBUG unnamed src/language_client.rs:108 state.viewports./home/dick/LanguageClient-neovim/src/rpcclient.rs.start: 57 ==> 40 22:39:19 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_signs","params":["/home/dick/LanguageClient-neovim/src/rpcclient.rs",[]],"id":66} 22:39:19 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 66, "jsonrpc": "2.0", "result": 0} 22:39:19 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:ClearHighlights","params":["__LCN_DIAGNOSTIC_HIGHLIGHT__"]} 22:39:19 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"mode","params":[],"id":67} 22:39:19 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 67, "jsonrpc": "2.0", "result": "n"} 22:39:19 DEBUG writer-None src/rpcclient.rs:254 => None {"jsonrpc":"2.0","method":"s:set_virtual_texts","params":[1,3,40,59,[]],"id":68} 22:39:19 DEBUG reader-None src/rpcclient.rs:207 <= None {"id": 68, "jsonrpc": "2.0", "result": 0} 16:45:09 INFO reader-None src/rpcclient.rs:241 reader-None terminated