{ "isIncomplete": true, "items": [ { "detail": "Alignment", "documentation": { "kind": "markdown", "value": "Possible alignments returned by `Formatter::align`" }, "filterText": "Alignment", "kind": 13, "label": "Alignment", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "Alignment", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "detail": "Arguments<'_>", "documentation": { "kind": "markdown", "value": "This structure represents a safely precompiled version of a format string\nand its arguments. This cannot be generated at runtime because it cannot\nsafely be done, so no constructors are given and the fields are private\nto prevent modification.\n\nThe [`format_args!`] macro will safely create an instance of this structure.\nThe macro validates the format string at compile-time so usage of the\n[`write()`] and [`format()`] functions can be safely performed.\n\nYou can use the `Arguments<'a>` that [`format_args!`] returns in `Debug`\nand `Display` contexts as seen below. The example also shows that `Debug`\nand `Display` format to the same thing: the interpolated format string\nin `format_args!`.\n\n```rust\nlet debug = format!(\"{:?}\", format_args!(\"{} foo {:?}\", 1, 2));\nlet display = format!(\"{}\", format_args!(\"{} foo {:?}\", 1, 2));\nassert_eq!(\"1 foo 2\", display);\nassert_eq!(display, debug);\n```\n\n[`format()`]: ../../std/fmt/fn.format.html" }, "filterText": "Arguments", "kind": 22, "label": "Arguments", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "Arguments", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "documentation": { "kind": "markdown", "value": "`b` formatting.\n\nThe `Binary` trait should format its output as a number in binary.\n\nFor primitive signed integers ([`i8`] to [`i128`], and [`isize`]),\nnegative values are formatted as the two’s complement representation.\n\nThe alternate flag, `#`, adds a `0b` in front of the output.\n\nFor more information on formatters, see [the module-level documentation][module].\n\n[module]: ../../std/fmt/index.html\n\n# Examples\n\nBasic usage with [`i32`]:\n\n```rust\nlet x = 42; // 42 is '101010' in binary\n\nassert_eq!(format!(\"{x:b}\"), \"101010\");\nassert_eq!(format!(\"{x:#b}\"), \"0b101010\");\n\nassert_eq!(format!(\"{:b}\", -16), \"11111111111111111111111111110000\");\n```\n\nImplementing `Binary` on a type:\n\n```rust\nuse std::fmt;\n\nstruct Length(i32);\n\nimpl fmt::Binary for Length {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n let val = self.0;\n\n fmt::Binary::fmt(&val, f) // delegate to i32's implementation\n }\n}\n\nlet l = Length(107);\n\nassert_eq!(format!(\"l as binary is: {l:b}\"), \"l as binary is: 1101011\");\n\nassert_eq!(\n // Note that the `0b` prefix added by `#` is included in the total width, so we\n // need to add two to correctly display all 32 bits.\n format!(\"l as binary is: {l:#034b}\"),\n \"l as binary is: 0b00000000000000000000000001101011\"\n);\n```" }, "filterText": "Binary", "kind": 8, "label": "Binary", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "Binary", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "documentation": { "kind": "markdown", "value": "`?` formatting.\n\n`Debug` should format the output in a programmer-facing, debugging context.\n\nGenerally speaking, you should just `derive` a `Debug` implementation.\n\nWhen used with the alternate format specifier `#?`, the output is pretty-printed.\n\nFor more information on formatters, see [the module-level documentation][module].\n\n[module]: ../../std/fmt/index.html\n\nThis trait can be used with `#[derive]` if all fields implement `Debug`. When\n`derive`d for structs, it will use the name of the `struct`, then `{`, then a\ncomma-separated list of each field's name and `Debug` value, then `}`. For\n`enum`s, it will use the name of the variant and, if applicable, `(`, then the\n`Debug` values of the fields, then `)`.\n\n# Stability\n\nDerived `Debug` formats are not stable, and so may change with future Rust\nversions. Additionally, `Debug` implementations of types provided by the\nstandard library (`std`, `core`, `alloc`, etc.) are not stable, and\nmay also change with future Rust versions.\n\n# Examples\n\nDeriving an implementation:\n\n```rust\n#[derive(Debug)]\nstruct Point {\n x: i32,\n y: i32,\n}\n\nlet origin = Point { x: 0, y: 0 };\n\nassert_eq!(\n format!(\"The origin is: {origin:?}\"),\n \"The origin is: Point { x: 0, y: 0 }\",\n);\n```\n\nManually implementing:\n\n```rust\nuse std::fmt;\n\nstruct Point {\n x: i32,\n y: i32,\n}\n\nimpl fmt::Debug for Point {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n f.debug_struct(\"Point\")\n .field(\"x\", &self.x)\n .field(\"y\", &self.y)\n .finish()\n }\n}\n\nlet origin = Point { x: 0, y: 0 };\n\nassert_eq!(\n format!(\"The origin is: {origin:?}\"),\n \"The origin is: Point { x: 0, y: 0 }\",\n);\n```\n\nThere are a number of helper methods on the [`Formatter`] struct to help you with manual\nimplementations, such as [`debug_struct`].\n\n[`debug_struct`]: Formatter::debug_struct\n\nTypes that do not wish to use the standard suite of debug representations\nprovided by the `Formatter` trait (`debug_struct`, `debug_tuple`,\n`debug_list`, `debug_set`, `debug_map`) can do something totally custom by\nmanually writing an arbitrary representation to the `Formatter`.\n\n```rust\nimpl fmt::Debug for Point {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n write!(f, \"Point [{} {}]\", self.x, self.y)\n }\n}\n```\n\n`Debug` implementations using either `derive` or the debug builder API\non [`Formatter`] support pretty-printing using the alternate flag: `{:#?}`.\n\nPretty-printing with `#?`:\n\n```rust\n#[derive(Debug)]\nstruct Point {\n x: i32,\n y: i32,\n}\n\nlet origin = Point { x: 0, y: 0 };\n\nlet expected = \"The origin is: Point {\n x: 0,\n y: 0,\n}\";\nassert_eq!(format!(\"The origin is: {origin:#?}\"), expected);\n```" }, "filterText": "Debug", "kind": 8, "label": "Debug(alias {:?})", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "Debug", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "detail": "macro Debug", "documentation": { "kind": "markdown", "value": "Derive macro generating an impl of the trait `Debug`." }, "filterText": "Debug", "kind": 3, "label": "Debug", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "Debug", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "detail": "DebugAsHex", "documentation": { "kind": "markdown", "value": "Specifies whether the [`Debug`] trait should use lower-/upper-case\nhexadecimal or normal integers." }, "filterText": "DebugAsHex", "kind": 13, "label": "DebugAsHex", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "DebugAsHex", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "detail": "DebugList<'_, '_>", "documentation": { "kind": "markdown", "value": "A struct to help with [`fmt::Debug`](Debug) implementations.\n\nThis is useful when you wish to output a formatted list of items as a part\nof your [`Debug::fmt`] implementation.\n\nThis can be constructed by the [`Formatter::debug_list`] method.\n\n# Examples\n\n```rust\nuse std::fmt;\n\nstruct Foo(Vec);\n\nimpl fmt::Debug for Foo {\n fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {\n fmt.debug_list().entries(self.0.iter()).finish()\n }\n}\n\nassert_eq!(\n format!(\"{:?}\", Foo(vec![10, 11])),\n \"[10, 11]\",\n);\n```" }, "filterText": "DebugList", "kind": 22, "label": "DebugList", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "DebugList", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "detail": "DebugMap<'_, '_>", "documentation": { "kind": "markdown", "value": "A struct to help with [`fmt::Debug`](Debug) implementations.\n\nThis is useful when you wish to output a formatted map as a part of your\n[`Debug::fmt`] implementation.\n\nThis can be constructed by the [`Formatter::debug_map`] method.\n\n# Examples\n\n```rust\nuse std::fmt;\n\nstruct Foo(Vec<(String, i32)>);\n\nimpl fmt::Debug for Foo {\n fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {\n fmt.debug_map().entries(self.0.iter().map(|&(ref k, ref v)| (k, v))).finish()\n }\n}\n\nassert_eq!(\n format!(\"{:?}\", Foo(vec![(\"A\".to_string(), 10), (\"B\".to_string(), 11)])),\n r#\"{\"A\": 10, \"B\": 11}\"#,\n);\n```" }, "filterText": "DebugMap", "kind": 22, "label": "DebugMap", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "DebugMap", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "detail": "DebugSet<'_, '_>", "documentation": { "kind": "markdown", "value": "A struct to help with [`fmt::Debug`](Debug) implementations.\n\nThis is useful when you wish to output a formatted set of items as a part\nof your [`Debug::fmt`] implementation.\n\nThis can be constructed by the [`Formatter::debug_set`] method.\n\n# Examples\n\n```rust\nuse std::fmt;\n\nstruct Foo(Vec);\n\nimpl fmt::Debug for Foo {\n fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {\n fmt.debug_set().entries(self.0.iter()).finish()\n }\n}\n\nassert_eq!(\n format!(\"{:?}\", Foo(vec![10, 11])),\n \"{10, 11}\",\n);\n```" }, "filterText": "DebugSet", "kind": 22, "label": "DebugSet", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "DebugSet", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "detail": "DebugStruct<'_, '_>", "documentation": { "kind": "markdown", "value": "A struct to help with [`fmt::Debug`](Debug) implementations.\n\nThis is useful when you wish to output a formatted struct as a part of your\n[`Debug::fmt`] implementation.\n\nThis can be constructed by the [`Formatter::debug_struct`] method.\n\n# Examples\n\n```rust\nuse std::fmt;\n\nstruct Foo {\n bar: i32,\n baz: String,\n}\n\nimpl fmt::Debug for Foo {\n fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {\n fmt.debug_struct(\"Foo\")\n .field(\"bar\", &self.bar)\n .field(\"baz\", &self.baz)\n .finish()\n }\n}\n\nassert_eq!(\n format!(\"{:?}\", Foo { bar: 10, baz: \"Hello World\".to_string() }),\n r#\"Foo { bar: 10, baz: \"Hello World\" }\"#,\n);\n```" }, "filterText": "DebugStruct", "kind": 22, "label": "DebugStruct", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "DebugStruct", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "detail": "DebugTuple<'_, '_>", "documentation": { "kind": "markdown", "value": "A struct to help with [`fmt::Debug`](Debug) implementations.\n\nThis is useful when you wish to output a formatted tuple as a part of your\n[`Debug::fmt`] implementation.\n\nThis can be constructed by the [`Formatter::debug_tuple`] method.\n\n# Examples\n\n```rust\nuse std::fmt;\n\nstruct Foo(i32, String);\n\nimpl fmt::Debug for Foo {\n fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {\n fmt.debug_tuple(\"Foo\")\n .field(&self.0)\n .field(&self.1)\n .finish()\n }\n}\n\nassert_eq!(\n format!(\"{:?}\", Foo(10, \"Hello World\".to_string())),\n r#\"Foo(10, \"Hello World\")\"#,\n);\n```" }, "filterText": "DebugTuple", "kind": 22, "label": "DebugTuple", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "DebugTuple", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "documentation": { "kind": "markdown", "value": "Format trait for an empty format, `{}`.\n\nImplementing this trait for a type will automatically implement the\n[`ToString`][tostring] trait for the type, allowing the usage\nof the [`.to_string()`][tostring_function] method. Prefer implementing\nthe `Display` trait for a type, rather than [`ToString`][tostring].\n\n`Display` is similar to [`Debug`], but `Display` is for user-facing\noutput, and so cannot be derived.\n\nFor more information on formatters, see [the module-level documentation][module].\n\n[module]: ../../std/fmt/index.html\n[tostring]: ../../std/string/trait.ToString.html\n[tostring_function]: ../../std/string/trait.ToString.html#tymethod.to_string\n\n# Completeness and parseability\n\n`Display` for a type might not necessarily be a lossless or complete representation of the type.\nIt may omit internal state, precision, or other information the type does not consider important\nfor user-facing output, as determined by the type. As such, the output of `Display` might not be\npossible to parse, and even if it is, the result of parsing might not exactly match the original\nvalue.\n\nHowever, if a type has a lossless `Display` implementation whose output is meant to be\nconveniently machine-parseable and not just meant for human consumption, then the type may wish\nto accept the same format in `FromStr`, and document that usage. Having both `Display` and\n`FromStr` implementations where the result of `Display` cannot be parsed with `FromStr` may\nsurprise users.\n\n# Internationalization\n\nBecause a type can only have one `Display` implementation, it is often preferable\nto only implement `Display` when there is a single most \"obvious\" way that\nvalues can be formatted as text. This could mean formatting according to the\n\"invariant\" culture and \"undefined\" locale, or it could mean that the type\ndisplay is designed for a specific culture/locale, such as developer logs.\n\nIf not all values have a justifiably canonical textual format or if you want\nto support alternative formats not covered by the standard set of possible\n[formatting traits], the most flexible approach is display adapters: methods\nlike [`str::escape_default`] or [`Path::display`] which create a wrapper\nimplementing `Display` to output the specific display format.\n\n[formatting traits]: ../../std/fmt/index.html#formatting-traits\n[`Path::display`]: ../../std/path/struct.Path.html#method.display\n\n# Examples\n\nImplementing `Display` on a type:\n\n```rust\nuse std::fmt;\n\nstruct Point {\n x: i32,\n y: i32,\n}\n\nimpl fmt::Display for Point {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n write!(f, \"({}, {})\", self.x, self.y)\n }\n}\n\nlet origin = Point { x: 0, y: 0 };\n\nassert_eq!(format!(\"The origin is: {origin}\"), \"The origin is: (0, 0)\");\n```" }, "filterText": "Display", "kind": 8, "label": "Display(alias {})", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "Display", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "detail": "Error", "documentation": { "kind": "markdown", "value": "The error type which is returned from formatting a message into a stream.\n\nThis type does not support transmission of an error other than that an error\noccurred. This is because, despite the existence of this error,\nstring formatting is considered an infallible operation.\n`fmt()` implementors should not return this `Error` unless they received it from their\n[`Formatter`]. The only time your code should create a new instance of this\nerror is when implementing `fmt::Write`, in order to cancel the formatting operation when\nwriting to the underlying stream fails.\n\nAny extra information must be arranged to be transmitted through some other means,\nsuch as storing it in a field to be consulted after the formatting operation has been\ncancelled. (For example, this is how [`std::io::Write::write_fmt()`] propagates IO errors\nduring writing.)\n\nThis type, `fmt::Error`, should not be\nconfused with [`std::io::Error`] or [`std::error::Error`], which you may also\nhave in scope.\n\n[`std::io::Error`]: ../../std/io/struct.Error.html\n[`std::io::Write::write_fmt()`]: ../../std/io/trait.Write.html#method.write_fmt\n[`std::error::Error`]: ../../std/error/trait.Error.html\n\n# Examples\n\n```rust\nuse std::fmt::{self, write};\n\nlet mut output = String::new();\nif let Err(fmt::Error) = write(&mut output, format_args!(\"Hello {}!\", \"world\")) {\n panic!(\"An error occurred\");\n}\n```" }, "filterText": "Error", "kind": 22, "label": "Error", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "Error", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "detail": "Formatter<'_>", "documentation": { "kind": "markdown", "value": "Configuration for formatting.\n\nA `Formatter` represents various options related to formatting. Users do not\nconstruct `Formatter`s directly; a mutable reference to one is passed to\nthe `fmt` method of all formatting traits, like [`Debug`] and [`Display`].\n\nTo interact with a `Formatter`, you'll call various methods to change the\nvarious options related to formatting. For examples, please see the\ndocumentation of the methods defined on `Formatter` below." }, "filterText": "Formatter", "kind": 22, "label": "Formatter", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "Formatter", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "detail": "FormattingOptions", "documentation": { "kind": "markdown", "value": "Options for formatting.\n\n`FormattingOptions` is a [`Formatter`] without an attached [`Write`] trait.\nIt is mainly used to construct `Formatter` instances." }, "filterText": "FormattingOptions", "kind": 22, "label": "FormattingOptions", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "FormattingOptions", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "detail": "FromFn<{unknown}>", "documentation": { "kind": "markdown", "value": "Implements [`fmt::Debug`] and [`fmt::Display`] using a function.\n\nCreated with [`from_fn`]." }, "filterText": "FromFn", "kind": 22, "label": "FromFn", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "FromFn", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "documentation": { "kind": "markdown", "value": "`e` formatting.\n\nThe `LowerExp` trait should format its output in scientific notation with a lower-case `e`.\n\nFor more information on formatters, see [the module-level documentation][module].\n\n[module]: ../../std/fmt/index.html\n\n# Examples\n\nBasic usage with `f64`:\n\n```rust\nlet x = 42.0; // 42.0 is '4.2e1' in scientific notation\n\nassert_eq!(format!(\"{x:e}\"), \"4.2e1\");\n```\n\nImplementing `LowerExp` on a type:\n\n```rust\nuse std::fmt;\n\nstruct Length(i32);\n\nimpl fmt::LowerExp for Length {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n let val = f64::from(self.0);\n fmt::LowerExp::fmt(&val, f) // delegate to f64's implementation\n }\n}\n\nlet l = Length(100);\n\nassert_eq!(\n format!(\"l in scientific notation is: {l:e}\"),\n \"l in scientific notation is: 1e2\"\n);\n\nassert_eq!(\n format!(\"l in scientific notation is: {l:05e}\"),\n \"l in scientific notation is: 001e2\"\n);\n```" }, "filterText": "LowerExp", "kind": 8, "label": "LowerExp", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "LowerExp", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "documentation": { "kind": "markdown", "value": "`x` formatting.\n\nThe `LowerHex` trait should format its output as a number in hexadecimal, with `a` through `f`\nin lower case.\n\nFor primitive signed integers (`i8` to `i128`, and `isize`),\nnegative values are formatted as the two’s complement representation.\n\nThe alternate flag, `#`, adds a `0x` in front of the output.\n\nFor more information on formatters, see [the module-level documentation][module].\n\n[module]: ../../std/fmt/index.html\n\n# Examples\n\nBasic usage with `i32`:\n\n```rust\nlet y = 42; // 42 is '2a' in hex\n\nassert_eq!(format!(\"{y:x}\"), \"2a\");\nassert_eq!(format!(\"{y:#x}\"), \"0x2a\");\n\nassert_eq!(format!(\"{:x}\", -16), \"fffffff0\");\n```\n\nImplementing `LowerHex` on a type:\n\n```rust\nuse std::fmt;\n\nstruct Length(i32);\n\nimpl fmt::LowerHex for Length {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n let val = self.0;\n\n fmt::LowerHex::fmt(&val, f) // delegate to i32's implementation\n }\n}\n\nlet l = Length(9);\n\nassert_eq!(format!(\"l as hex is: {l:x}\"), \"l as hex is: 9\");\n\nassert_eq!(format!(\"l as hex is: {l:#010x}\"), \"l as hex is: 0x00000009\");\n```" }, "filterText": "LowerHex", "kind": 8, "label": "LowerHex", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "LowerHex", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "documentation": { "kind": "markdown", "value": "`o` formatting.\n\nThe `Octal` trait should format its output as a number in base-8.\n\nFor primitive signed integers (`i8` to `i128`, and `isize`),\nnegative values are formatted as the two’s complement representation.\n\nThe alternate flag, `#`, adds a `0o` in front of the output.\n\nFor more information on formatters, see [the module-level documentation][module].\n\n[module]: ../../std/fmt/index.html\n\n# Examples\n\nBasic usage with `i32`:\n\n```rust\nlet x = 42; // 42 is '52' in octal\n\nassert_eq!(format!(\"{x:o}\"), \"52\");\nassert_eq!(format!(\"{x:#o}\"), \"0o52\");\n\nassert_eq!(format!(\"{:o}\", -16), \"37777777760\");\n```\n\nImplementing `Octal` on a type:\n\n```rust\nuse std::fmt;\n\nstruct Length(i32);\n\nimpl fmt::Octal for Length {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n let val = self.0;\n\n fmt::Octal::fmt(&val, f) // delegate to i32's implementation\n }\n}\n\nlet l = Length(9);\n\nassert_eq!(format!(\"l as octal is: {l:o}\"), \"l as octal is: 11\");\n\nassert_eq!(format!(\"l as octal is: {l:#06o}\"), \"l as octal is: 0o0011\");\n```" }, "filterText": "Octal", "kind": 8, "label": "Octal", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "Octal", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "documentation": { "kind": "markdown", "value": "`p` formatting.\n\nThe `Pointer` trait should format its output as a memory location. This is commonly presented\nas hexadecimal. For more information on formatters, see [the module-level documentation][module].\n\nPrinting of pointers is not a reliable way to discover how Rust programs are implemented.\nThe act of reading an address changes the program itself, and may change how the data is represented\nin memory, and may affect which optimizations are applied to the code.\n\nThe printed pointer values are not guaranteed to be stable nor unique identifiers of objects.\nRust allows moving values to different memory locations, and may reuse the same memory locations\nfor different purposes.\n\nThere is no guarantee that the printed value can be converted back to a pointer.\n\n[module]: ../../std/fmt/index.html\n\n# Examples\n\nBasic usage with `&i32`:\n\n```rust\nlet x = &42;\n\nlet address = format!(\"{x:p}\"); // this produces something like '0x7f06092ac6d0'\n```\n\nImplementing `Pointer` on a type:\n\n```rust\nuse std::fmt;\n\nstruct Length(i32);\n\nimpl fmt::Pointer for Length {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n // use `as` to convert to a `*const T`, which implements Pointer, which we can use\n\n let ptr = self as *const Self;\n fmt::Pointer::fmt(&ptr, f)\n }\n}\n\nlet l = Length(42);\n\nprintln!(\"l is in memory here: {l:p}\");\n\nlet l_ptr = format!(\"{l:018p}\");\nassert_eq!(l_ptr.len(), 18);\nassert_eq!(&l_ptr[..2], \"0x\");\n```" }, "filterText": "Pointer", "kind": 8, "label": "Pointer", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "Pointer", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "documentation": { "kind": "markdown", "value": "The type returned by formatter methods.\n\n# Examples\n\n```rust\nuse std::fmt;\n\n#[derive(Debug)]\nstruct Triangle {\n a: f32,\n b: f32,\n c: f32\n}\n\nimpl fmt::Display for Triangle {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n write!(f, \"({}, {}, {})\", self.a, self.b, self.c)\n }\n}\n\nlet pythagorean_triple = Triangle { a: 3.0, b: 4.0, c: 5.0 };\n\nassert_eq!(format!(\"{pythagorean_triple}\"), \"(3, 4, 5)\");\n```" }, "filterText": "Result", "kind": 22, "label": "Result", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "Result", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "detail": "Sign", "documentation": { "kind": "markdown", "value": "The signedness of a [`Formatter`] (or of a [`FormattingOptions`])." }, "filterText": "Sign", "kind": 13, "label": "Sign", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "Sign", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "documentation": { "kind": "markdown", "value": "`E` formatting.\n\nThe `UpperExp` trait should format its output in scientific notation with an upper-case `E`.\n\nFor more information on formatters, see [the module-level documentation][module].\n\n[module]: ../../std/fmt/index.html\n\n# Examples\n\nBasic usage with `f64`:\n\n```rust\nlet x = 42.0; // 42.0 is '4.2E1' in scientific notation\n\nassert_eq!(format!(\"{x:E}\"), \"4.2E1\");\n```\n\nImplementing `UpperExp` on a type:\n\n```rust\nuse std::fmt;\n\nstruct Length(i32);\n\nimpl fmt::UpperExp for Length {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n let val = f64::from(self.0);\n fmt::UpperExp::fmt(&val, f) // delegate to f64's implementation\n }\n}\n\nlet l = Length(100);\n\nassert_eq!(\n format!(\"l in scientific notation is: {l:E}\"),\n \"l in scientific notation is: 1E2\"\n);\n\nassert_eq!(\n format!(\"l in scientific notation is: {l:05E}\"),\n \"l in scientific notation is: 001E2\"\n);\n```" }, "filterText": "UpperExp", "kind": 8, "label": "UpperExp", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "UpperExp", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "documentation": { "kind": "markdown", "value": "`X` formatting.\n\nThe `UpperHex` trait should format its output as a number in hexadecimal, with `A` through `F`\nin upper case.\n\nFor primitive signed integers (`i8` to `i128`, and `isize`),\nnegative values are formatted as the two’s complement representation.\n\nThe alternate flag, `#`, adds a `0x` in front of the output.\n\nFor more information on formatters, see [the module-level documentation][module].\n\n[module]: ../../std/fmt/index.html\n\n# Examples\n\nBasic usage with `i32`:\n\n```rust\nlet y = 42; // 42 is '2A' in hex\n\nassert_eq!(format!(\"{y:X}\"), \"2A\");\nassert_eq!(format!(\"{y:#X}\"), \"0x2A\");\n\nassert_eq!(format!(\"{:X}\", -16), \"FFFFFFF0\");\n```\n\nImplementing `UpperHex` on a type:\n\n```rust\nuse std::fmt;\n\nstruct Length(i32);\n\nimpl fmt::UpperHex for Length {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n let val = self.0;\n\n fmt::UpperHex::fmt(&val, f) // delegate to i32's implementation\n }\n}\n\nlet l = Length(i32::MAX);\n\nassert_eq!(format!(\"l as hex is: {l:X}\"), \"l as hex is: 7FFFFFFF\");\n\nassert_eq!(format!(\"l as hex is: {l:#010X}\"), \"l as hex is: 0x7FFFFFFF\");\n```" }, "filterText": "UpperHex", "kind": 8, "label": "UpperHex", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "UpperHex", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "documentation": { "kind": "markdown", "value": "A trait for writing or formatting into Unicode-accepting buffers or streams.\n\nThis trait only accepts UTF-8–encoded data and is not [flushable]. If you only\nwant to accept Unicode and you don't need flushing, you should implement this trait;\notherwise you should implement [`std::io::Write`].\n\n[`std::io::Write`]: ../../std/io/trait.Write.html\n[flushable]: ../../std/io/trait.Write.html#tymethod.flush" }, "filterText": "Write", "kind": 8, "label": "Write", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "Write", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "detail": "fn(Arguments<'_>) -> String", "documentation": { "kind": "markdown", "value": "Takes an [`Arguments`] struct and returns the resulting formatted string.\n\nThe [`Arguments`] instance can be created with the [`format_args!`] macro.\n\n# Examples\n\nBasic usage:\n\n```rust\nuse std::fmt;\n\nlet s = fmt::format(format_args!(\"Hello, {}!\", \"world\"));\nassert_eq!(s, \"Hello, world!\");\n```\n\nPlease note that using [`format!`] might be preferable.\nExample:\n\n```rust\nlet s = format!(\"Hello, {}!\", \"world\");\nassert_eq!(s, \"Hello, world!\");\n```\n\n[`format_args!`]: core::format_args\n[`format!`]: crate::format" }, "filterText": "format", "kind": 3, "label": "format", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "format", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "detail": "fn(F) -> FromFn", "documentation": { "kind": "markdown", "value": "Creates a type whose [`fmt::Debug`] and [`fmt::Display`] impls are provided with the function\n`f`.\n\n# Examples\n\n```rust\n#![feature(debug_closure_helpers)]\nuse std::fmt;\n\nlet value = 'a';\nassert_eq!(format!(\"{}\", value), \"a\");\nassert_eq!(format!(\"{:?}\", value), \"'a'\");\n\nlet wrapped = fmt::from_fn(|f| write!(f, \"{value:?}\"));\nassert_eq!(format!(\"{}\", wrapped), \"'a'\");\nassert_eq!(format!(\"{:?}\", wrapped), \"'a'\");\n```" }, "filterText": "from_fn", "kind": 3, "label": "from_fn", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "from_fn", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } }, { "detail": "fn(&mut (dyn Write + 'static), Arguments<'_>) -> Result<(), Error>", "documentation": { "kind": "markdown", "value": "Takes an output stream and an `Arguments` struct that can be precompiled with\nthe `format_args!` macro.\n\nThe arguments will be formatted according to the specified format string\ninto the output stream provided.\n\n# Examples\n\nBasic usage:\n\n```rust\nuse std::fmt;\n\nlet mut output = String::new();\nfmt::write(&mut output, format_args!(\"Hello {}!\", \"world\"))\n .expect(\"Error occurred while trying to write in String\");\nassert_eq!(output, \"Hello world!\");\n```\n\nPlease note that using [`write!`] might be preferable. Example:\n\n```rust\nuse std::fmt::Write;\n\nlet mut output = String::new();\nwrite!(&mut output, \"Hello {}!\", \"world\")\n .expect(\"Error occurred while trying to write in String\");\nassert_eq!(output, \"Hello world!\");\n```\n\n[`write!`]: crate::write!" }, "filterText": "write", "kind": 3, "label": "write", "preselect": true, "sortText": "7fffffff", "textEdit": { "newText": "write", "range": { "end": { "character": 14, "line": 1 }, "start": { "character": 14, "line": 1 } } } } ] }