3 /// Cast between types, or rename an import.
5 /// `as` is most commonly used to turn primitive types into other primitive types, but it has other
6 /// uses that include turning pointers into addresses, addresses into pointers, and pointers into
10 /// let thing1: u8 = 89.0 as u8;
11 /// assert_eq!('B' as u32, 66);
12 /// assert_eq!(thing1 as char, 'Y');
13 /// let thing2: f32 = thing1 as f32 + 10.5;
14 /// assert_eq!(true as u8 + thing2 as u8, 100);
17 /// In general, any cast that can be performed via ascribing the type can also be done using `as`,
18 /// so instead of writing `let x: u32 = 123`, you can write `let x = 123 as u32` (Note: `let x: u32
19 /// = 123` would be best in that situation). The same is not true in the other direction, however,
20 /// explicitly using `as` allows a few more coercions that aren't allowed implicitly, such as
21 /// changing the type of a raw pointer or turning closures into raw pointers.
23 /// Other places `as` is used include as extra syntax for [`crate`] and `use`, to change the name
24 /// something is imported as.
26 /// For more information on what `as` is capable of, see the [Reference]
28 /// [Reference]: ../reference/expressions/operator-expr.html#type-cast-expressions
29 /// [`crate`]: keyword.crate.html
32 #[doc(keyword = "break")]
34 /// Exit early from a loop.
36 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
38 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
41 #[doc(keyword = "const")]
43 /// Compile-time constants and deterministic functions.
45 /// Sometimes a certain value is used many times throughout a program, and it can become
46 /// inconvenient to copy it over and over. What's more, it's not always possible or desirable to
47 /// make it a variable that gets carried around to each function that needs it. In these cases, the
48 /// `const` keyword provides a convenient alternative to code duplication.
51 /// const THING: u32 = 0xABAD1DEA;
53 /// let foo = 123 + THING;
56 /// Constants must be explicitly typed, unlike with `let` you can't ignore its type and let the
57 /// compiler figure it out. Any constant value can be defined in a const, which in practice happens
58 /// to be most things that would be reasonable to have a constant (barring `const fn`s). For
59 /// example, you can't have a File as a `const`.
61 /// The only lifetime allowed in a constant is `'static`, which is the lifetime that encompasses
62 /// all others in a Rust program. For example, if you wanted to define a constant string, it would
66 /// const WORDS: &str = "hello rust!";
69 /// Thanks to static lifetime elision, you usually don't have to explicitly use 'static:
72 /// const WORDS: &str = "hello convenience!";
75 /// `const` items looks remarkably similar to `static` items, which introduces some confusion as
76 /// to which one should be used at which times. To put it simply, constants are inlined wherever
77 /// they're used, making using them identical to simply replacing the name of the const with its
78 /// value. Static variables on the other hand point to a single location in memory, which all
79 /// accesses share. This means that, unlike with constants, they can't have destructors, and act as
80 /// a single value across the entire codebase.
82 /// Constants, as with statics, should always be in SCREAMING_SNAKE_CASE.
84 /// The `const` keyword is also used in raw pointers in combination with `mut`, as seen in `*const
85 /// T` and `*mut T`. More about that can be read at the [pointer] primitive part of the Rust docs.
87 /// For more detail on `const`, see the [Rust Book] or the [Reference]
89 /// [pointer]: primitive.pointer.html
91 /// ../book/ch03-01-variables-and-mutability.html#differences-between-variables-and-constants
92 /// [Reference]: ../reference/items/constant-items.html
95 #[doc(keyword = "continue")]
97 /// Skip to the next iteration of a loop.
99 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
101 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
102 mod continue_keyword { }
104 #[doc(keyword = "crate")]
106 /// A Rust binary or library.
108 /// The primary use of the `crate` keyword is as a part of `extern crate` declarations, which are
109 /// used to specify a dependency on a crate external to the one it's declared in. Crates are the
110 /// fundamental compilation unit of Rust code, and can be seen as libraries or projects. More can
111 /// be read about crates in the [Reference].
114 /// extern crate rand;
115 /// extern crate my_crate as thing;
116 /// extern crate std; // implicitly added to the root of every Rust project
119 /// The `as` keyword can be used to change what the crate is referred to as in your project. If a
120 /// crate name includes a dash, it is implicitly imported with the dashes replaced by underscores.
122 /// `crate` is also used as in conjunction with `pub` to signify that the item it's attached to
123 /// is public only to other members of the same crate it's in.
126 /// # #[allow(unused_imports)]
127 /// pub(crate) use std::io::Error as IoError;
128 /// pub(crate) enum CoolMarkerType { }
129 /// pub struct PublicThing {
130 /// pub(crate) semi_secret_thing: bool,
134 /// [Reference]: ../reference/items/extern-crates.html
135 mod crate_keyword { }
137 #[doc(keyword = "else")]
139 /// What to do when an [`if`] condition does not hold.
141 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
143 /// [`if`]: keyword.if.html
144 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
147 #[doc(keyword = "enum")]
149 /// A type that can be any one of several variants.
151 /// Enums in Rust are similar to those of other compiled languages like C, but have important
152 /// differences that make them considerably more powerful. What Rust calls enums are more commonly
153 /// known as [Algebraic Data Types][ADT] if you're coming from a functional programming background.
154 /// The important detail is that each enum variant can have data to go along with it.
158 /// enum SimpleEnum {
170 /// enum ComplexEnum {
174 /// usual_struct_stuff: bool,
179 /// enum EmptyEnum { }
182 /// The first enum shown is the usual kind of enum you'd find in a C-style language. The second
183 /// shows off a hypothetical example of something storing location data, with `Coord` being any
184 /// other type that's needed, for example a struct. The third example demonstrates the kind of
185 /// data a variant can store, ranging from nothing, to a tuple, to an anonymous struct.
187 /// Instantiating enum variants involves explicitly using the enum's name as its namespace,
188 /// followed by one of its variants. `SimpleEnum::SecondVariant` would be an example from above.
189 /// When data follows along with a variant, such as with rust's built-in [`Option`] type, the data
190 /// is added as the type describes, for example `Option::Some(123)`. The same follows with
191 /// struct-like variants, with things looking like `ComplexEnum::LotsOfThings { usual_struct_stuff:
192 /// true, blah: "hello!".to_string(), }`. Empty Enums are similar to () in that they cannot be
193 /// instantiated at all, and are used mainly to mess with the type system in interesting ways.
195 /// For more information, take a look at the [Rust Book] or the [Reference]
197 /// [ADT]: https://en.wikipedia.org/wiki/Algebraic_data_type
198 /// [`Option`]: option/enum.Option.html
199 /// [Rust Book]: ../book/ch06-01-defining-an-enum.html
200 /// [Reference]: ../reference/items/enumerations.html
203 #[doc(keyword = "extern")]
205 /// Link to or import external code.
207 /// The `extern` keyword is used in two places in Rust. One is in conjunction with the [`crate`]
208 /// keyword to make your Rust code aware of other Rust crates in your project, i.e., `extern crate
209 /// lazy_static;`. The other use is in foreign function interfaces (FFI).
211 /// `extern` is used in two different contexts within FFI. The first is in the form of external
212 /// blocks, for declaring function interfaces that Rust code can call foreign code by.
215 /// #[link(name = "my_c_library")]
217 /// fn my_c_function(x: i32) -> bool;
221 /// This code would attempt to link with `libmy_c_library.so` on unix-like systems and
222 /// `my_c_library.dll` on Windows at runtime, and panic if it can't find something to link to. Rust
223 /// code could then use `my_c_function` as if it were any other unsafe Rust function. Working with
224 /// non-Rust languages and FFI is inherently unsafe, so wrappers are usually built around C APIs.
226 /// The mirror use case of FFI is also done via the `extern` keyword:
230 /// pub extern fn callable_from_c(x: i32) -> bool {
235 /// If compiled as a dylib, the resulting .so could then be linked to from a C library, and the
236 /// function could be used as if it was from any other library.
238 /// For more information on FFI, check the [Rust book] or the [Reference].
241 /// ../book/ch19-01-unsafe-rust.html#using-extern-functions-to-call-external-code
242 /// [Reference]: ../reference/items/external-blocks.html
243 mod extern_keyword { }
245 #[doc(keyword = "false")]
247 /// A value of type [`bool`] representing logical **false**.
249 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
251 /// [`bool`]: primitive.bool.html
252 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
253 mod false_keyword { }
255 #[doc(keyword = "fn")]
257 /// A function or function pointer.
259 /// Functions are the primary way code is executed within Rust. Function blocks, usually just
260 /// called functions, can be defined in a variety of different places and be assigned many
261 /// different attributes and modifiers.
263 /// Standalone functions that just sit within a module not attached to anything else are common,
264 /// but most functions will end up being inside [`impl`] blocks, either on another type itself, or
265 /// as a trait impl for that type.
268 /// fn standalone_function() {
272 /// pub fn public_thing(argument: bool) -> String {
282 /// pub fn new() -> Self {
290 /// In addition to presenting fixed types in the form of `fn name(arg: type, ..) -> return_type`,
291 /// functions can also declare a list of type parameters along with trait bounds that they fall
295 /// fn generic_function<T: Clone>(x: T) -> (T, T, T) {
296 /// (x.clone(), x.clone(), x.clone())
299 /// fn generic_where<T>(x: T) -> T
300 /// where T: std::ops::Add<Output = T> + Copy
306 /// Declaring trait bounds in the angle brackets is functionally identical to using a `where`
307 /// clause. It's up to the programmer to decide which works better in each situation, but `where`
308 /// tends to be better when things get longer than one line.
310 /// Along with being made public via `pub`, `fn` can also have an [`extern`] added for use in
313 /// For more information on the various types of functions and how they're used, consult the [Rust
314 /// book] or the [Reference].
316 /// [`impl`]: keyword.impl.html
317 /// [`extern`]: keyword.extern.html
318 /// [Rust book]: ../book/ch03-03-how-functions-work.html
319 /// [Reference]: ../reference/items/functions.html
322 #[doc(keyword = "for")]
324 /// Iteration with [`in`], trait implementation with [`impl`], or [higher-ranked trait bounds]
327 /// The `for` keyword is used in many syntactic locations:
329 /// * `for` is used in for-in-loops (see below).
330 /// * `for` is used when implementing traits as in `impl Trait for Type` (see [`impl`] for more info
332 /// * `for` is also used for [higher-ranked trait bounds] as in `for<'a> &'a T: PartialEq<i32>`.
334 /// for-in-loops, or to be more precise, iterator loops, are a simple syntactic sugar over a common
335 /// practice within Rust, which is to loop over an iterator until that iterator returns `None` (or
336 /// `break` is called).
340 /// println!("{}", i * 2);
343 /// for i in std::iter::repeat(5) {
344 /// println!("turns out {} never stops being 5", i);
345 /// break; // would loop forever otherwise
348 /// 'outer: for x in 5..50 {
357 /// As shown in the example above, `for` loops (along with all other loops) can be tagged, using
358 /// similar syntax to lifetimes (only visually similar, entirely distinct in practice). Giving the
359 /// same tag to `break` breaks the tagged loop, which is useful for inner loops. It is definitely
362 /// A `for` loop expands as shown:
366 /// # let iterator = 0..2;
367 /// for loop_variable in iterator {
374 /// # let iterator = 0..2;
376 /// let mut _iter = std::iter::IntoIterator::into_iter(iterator);
378 /// match _iter.next() {
379 /// Some(loop_variable) => {
388 /// More details on the functionality shown can be seen at the [`IntoIterator`] docs.
390 /// For more information on for-loops, see the [Rust book] or the [Reference].
392 /// [`in`]: keyword.in.html
393 /// [`impl`]: keyword.impl.html
394 /// [higher-ranked trait bounds]: ../reference/trait-bounds.html#higher-ranked-trait-bounds
395 /// [`IntoIterator`]: iter/trait.IntoIterator.html
397 /// ../book/ch03-05-control-flow.html#looping-through-a-collection-with-for
398 /// [Reference]: ../reference/expressions/loop-expr.html#iterator-loops
401 #[doc(keyword = "if")]
403 /// Evaluate a block if a condition holds.
405 /// `if` is a familiar construct to most programmers, and is the main way you'll often do logic in
406 /// your code. However, unlike in most languages, `if` blocks can also act as expressions.
409 /// # let rude = true;
411 /// println!("whoops, mathematics broke");
413 /// println!("everything's fine!");
416 /// let greeting = if rude {
422 /// if let Ok(x) = "123".parse::<i32>() {
423 /// println!("{} double that and you get {}!", greeting, x * 2);
427 /// Shown above are the three typical forms an `if` block comes in. First is the usual kind of
428 /// thing you'd see in many languages, with an optional `else` block. Second uses `if` as an
429 /// expression, which is only possible if all branches return the same type. An `if` expression can
430 /// be used everywhere you'd expect. The third kind of `if` block is an `if let` block, which
431 /// behaves similarly to using a `match` expression:
434 /// if let Some(x) = Some(123) {
438 /// // something else
441 /// match Some(123) {
447 /// // something else
452 /// Each kind of `if` expression can be mixed and matched as needed.
455 /// if true == false {
456 /// println!("oh no");
457 /// } else if "something" == "other thing" {
458 /// println!("oh dear");
459 /// } else if let Some(200) = "blarg".parse::<i32>().ok() {
460 /// println!("uh oh");
462 /// println!("phew, nothing's broken");
466 /// The `if` keyword is used in one other place in Rust, namely as a part of pattern matching
467 /// itself, allowing patterns such as `Some(x) if x > 200` to be used.
469 /// For more information on `if` expressions, see the [Rust book] or the [Reference].
471 /// [Rust book]: ../book/ch03-05-control-flow.html#if-expressions
472 /// [Reference]: ../reference/expressions/if-expr.html
475 #[doc(keyword = "impl")]
477 /// Implement some functionality for a type.
479 /// The `impl` keyword is primarily used to define implementations on types. Inherent
480 /// implementations are standalone, while trait implementations are used to implement traits for
481 /// types, or other traits.
483 /// Functions and consts can both be defined in an implementation. A function defined in an
484 /// `impl` block can be standalone, meaning it would be called like `Foo::bar()`. If the function
485 /// takes `self`, `&self`, or `&mut self` as its first argument, it can also be called using
486 /// method-call syntax, a familiar feature to any object oriented programmer, like `foo.bar()`.
495 /// println!("boo! Example::boo() was called!");
498 /// fn answer(&mut self) {
499 /// self.number += 42;
502 /// fn get_number(&self) -> i32 {
508 /// fn do_thingy(&self);
511 /// impl Thingy for Example {
512 /// fn do_thingy(&self) {
513 /// println!("doing a thing! also, number is {}!", self.number);
518 /// For more information on implementations, see the [Rust book][book1] or the [Reference].
520 /// The other use of the `impl` keyword is in `impl Trait` syntax, which can be seen as a shorthand
521 /// for "a concrete type that implements this trait". Its primary use is working with closures,
522 /// which have type definitions generated at compile time that can't be simply typed out.
525 /// fn thing_returning_closure() -> impl Fn(i32) -> bool {
526 /// println!("here's a closure for you!");
527 /// |x: i32| x % 3 == 0
531 /// For more information on `impl Trait` syntax, see the [Rust book][book2].
533 /// [book1]: ../book/ch05-03-method-syntax.html
534 /// [Reference]: ../reference/items/implementations.html
535 /// [book2]: ../book/ch10-02-traits.html#returning-types-that-implement-traits
538 #[doc(keyword = "in")]
540 /// Iterate over a series of values with [`for`].
542 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
544 /// [`for`]: keyword.for.html
545 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
548 #[doc(keyword = "let")]
550 /// Bind a value to a variable.
552 /// The primary use for the `let` keyword is in `let` statements, which are used to introduce a new
553 /// set of variables into the current scope, as given by a pattern.
556 /// # #![allow(unused_assignments)]
557 /// let thing1: i32 = 100;
558 /// let thing2 = 200 + thing1;
560 /// let mut changing_thing = true;
561 /// changing_thing = false;
563 /// let (part1, part2) = ("first", "second");
570 /// let Example { a, b: _ } = Example {
577 /// The pattern is most commonly a single variable, which means no pattern matching is done and
578 /// the expression given is bound to the variable. Apart from that, patterns used in `let` bindings
579 /// can be as complicated as needed, given that the pattern is exhaustive. See the [Rust
580 /// book][book1] for more information on pattern matching. The type of the pattern is optionally
581 /// given afterwards, but if left blank is automatically inferred by the compiler if possible.
583 /// Variables in Rust are immutable by default, and require the `mut` keyword to be made mutable.
585 /// Multiple variables can be defined with the same name, known as shadowing. This doesn't affect
586 /// the original variable in any way beyond being unable to directly access it beyond the point of
587 /// shadowing. It continues to remain in scope, getting dropped only when it falls out of scope.
588 /// Shadowed variables don't need to have the same type as the variables shadowing them.
591 /// let shadowing_example = true;
592 /// let shadowing_example = 123.4;
593 /// let shadowing_example = shadowing_example as u32;
594 /// let mut shadowing_example = format!("cool! {}", shadowing_example);
595 /// shadowing_example += " something else!"; // not shadowing
598 /// Other places the `let` keyword is used include along with [`if`], in the form of `if let`
599 /// expressions. They're useful if the pattern being matched isn't exhaustive, such as with
600 /// enumerations. `while let` also exists, which runs a loop with a pattern matched value until
601 /// that pattern can't be matched.
603 /// For more information on the `let` keyword, see the [Rust book][book2] or the [Reference]
605 /// [book1]: ../book/ch06-02-match.html
606 /// [`if`]: keyword.if.html
607 /// [book2]: ../book/ch18-01-all-the-places-for-patterns.html#let-statements
608 /// [Reference]: ../reference/statements.html#let-statements
611 #[doc(keyword = "loop")]
613 /// Loop indefinitely.
615 /// `loop` is used to define the simplest kind of loop supported in Rust. It runs the code inside
616 /// it until the code uses `break` or the program exits.
620 /// println!("hello world forever!");
626 /// println!("i is {}", i);
634 /// Unlike the other kinds of loops in Rust (`while`, `while let`, and `for`), loops can be used as
635 /// expressions that return values via `break`.
639 /// let something = loop {
645 /// assert_eq!(something, 128);
648 /// Every `break` in a loop has to have the same type. When it's not explicitly giving something,
649 /// `break;` returns `()`.
651 /// For more information on `loop` and loops in general, see the [Reference].
653 /// [Reference]: ../reference/expressions/loop-expr.html
656 #[doc(keyword = "match")]
658 /// Control flow based on pattern matching.
660 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
662 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
663 mod match_keyword { }
665 #[doc(keyword = "mod")]
667 /// Organize code into [modules].
669 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
671 /// [modules]: ../reference/items/modules.html
672 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
675 #[doc(keyword = "move")]
677 /// Capture a [closure]'s environment by value.
679 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
681 /// [closure]: ../book/second-edition/ch13-01-closures.html
682 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
685 #[doc(keyword = "mut")]
687 /// A mutable binding, reference, or pointer.
689 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
691 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
694 #[doc(keyword = "pub")]
696 /// Make an item visible to others.
698 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
700 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
703 #[doc(keyword = "ref")]
705 /// Bind by reference during pattern matching.
707 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
709 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
712 #[doc(keyword = "return")]
714 /// Return a value from a function.
716 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
718 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
719 mod return_keyword { }
721 #[doc(keyword = "self")]
723 /// The receiver of a method, or the current module.
725 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
727 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
730 #[doc(keyword = "Self")]
732 /// The implementing type within a [`trait`] or [`impl`] block, or the current type within a type
735 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
737 /// [`impl`]: keyword.impl.html
738 /// [`trait`]: keyword.trait.html
739 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
740 mod self_upper_keyword { }
742 #[doc(keyword = "static")]
744 /// A place that is valid for the duration of a program.
746 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
748 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
749 mod static_keyword { }
751 #[doc(keyword = "struct")]
753 /// A type that is composed of other types.
755 /// Structs in Rust come in three flavors: Structs with named fields, tuple structs, and unit
765 /// struct Tuple(u32, String);
770 /// Regular structs are the most commonly used. Each field defined within them has a name and a
771 /// type, and once defined can be accessed using `example_struct.field` syntax. The fields of a
772 /// struct share its mutability, so `foo.bar = 2;` would only be valid if `foo` was mutable. Adding
773 /// `pub` to a field makes it visible to code in other modules, as well as allowing it to be
774 /// directly accessed and modified.
776 /// Tuple structs are similar to regular structs, but its fields have no names. They are used like
777 /// tuples, with deconstruction possible via `let TupleStruct(x, y) = foo;` syntax. For accessing
778 /// individual variables, the same syntax is used as with regular tuples, namely `foo.0`, `foo.1`,
779 /// etc, starting at zero.
781 /// Unit structs are most commonly used as marker. They have a size of zero bytes, but unlike empty
782 /// enums they can be instantiated, making them isomorphic to the unit type `()`. Unit structs are
783 /// useful when you need to implement a trait on something, but don't need to store any data inside
788 /// Structs can be instantiated in different ways, all of which can be mixed and
789 /// matched as needed. The most common way to make a new struct is via a constructor method such as
790 /// `new()`, but when that isn't available (or you're writing the constructor itself), struct
791 /// literal syntax is used:
794 /// # struct Foo { field1: f32, field2: String, etc: bool }
795 /// let example = Foo {
797 /// field2: "blah".to_string(),
802 /// It's only possible to directly instantiate a struct using struct literal syntax when all of its
803 /// fields are visible to you.
805 /// There are a handful of shortcuts provided to make writing constructors more convenient, most
806 /// common of which is the Field Init shorthand. When there is a variable and a field of the same
807 /// name, the assignment can be simplified from `field: field` into simply `field`. The following
808 /// example of a hypothetical constructor demonstrates this:
817 /// pub fn new(name: String) -> Self {
826 /// Another shortcut for struct instantiation is available, used when you need to make a new
827 /// struct that has the same values as most of a previous struct of the same type, called struct
831 /// # struct Foo { field1: String, field2: () }
832 /// # let thing = Foo { field1: "".to_string(), field2: () };
833 /// let updated_thing = Foo {
834 /// field1: "a new value".to_string(),
839 /// Tuple structs are instantiated in the same way as tuples themselves, except with the struct's
840 /// name as a prefix: `Foo(123, false, 0.1)`.
842 /// Empty structs are instantiated with just their name, and don't need anything else. `let thing =
845 /// # Style conventions
847 /// Structs are always written in CamelCase, with few exceptions. While the trailing comma on a
848 /// struct's list of fields can be omitted, it's usually kept for convenience in adding and
849 /// removing fields down the line.
851 /// For more information on structs, take a look at the [Rust Book][book] or the
852 /// [Reference][reference].
854 /// [`PhantomData`]: marker/struct.PhantomData.html
855 /// [book]: ../book/ch05-01-defining-structs.html
856 /// [reference]: ../reference/items/structs.html
857 mod struct_keyword { }
859 #[doc(keyword = "super")]
861 /// The parent of the current [module].
863 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
865 /// [module]: ../reference/items/modules.html
866 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
867 mod super_keyword { }
869 #[doc(keyword = "trait")]
871 /// A common interface for a class of types.
873 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
875 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
876 mod trait_keyword { }
878 #[doc(keyword = "true")]
880 /// A value of type [`bool`] representing logical **true**.
882 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
884 /// [`bool`]: primitive.bool.html
885 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
888 #[doc(keyword = "type")]
890 /// Define an alias for an existing type.
892 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
894 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
897 #[doc(keyword = "unsafe")]
899 /// Code or interfaces whose [memory safety] cannot be verified by the type system.
901 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
903 /// [memory safety]: ../book/ch19-01-unsafe-rust.html
904 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
905 mod unsafe_keyword { }
907 #[doc(keyword = "use")]
909 /// Import or rename items from other crates or modules.
911 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
913 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
916 #[doc(keyword = "where")]
918 /// Add constraints that must be upheld to use an item.
920 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
922 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
923 mod where_keyword { }
925 #[doc(keyword = "while")]
927 /// Loop while a condition is upheld.
929 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
931 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
932 mod while_keyword { }
934 // 2018 Edition keywords
936 #[unstable(feature = "async_await", issue = "50547")]
937 #[doc(keyword = "async")]
939 /// Return a [`Future`] instead of blocking the current thread.
941 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
943 /// [`Future`]: ./future/trait.Future.html
944 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
945 mod async_keyword { }
947 #[unstable(feature = "async_await", issue = "50547")]
948 #[doc(keyword = "await")]
950 /// Suspend execution until the result of a [`Future`] is ready.
952 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
954 /// [`Future`]: ./future/trait.Future.html
955 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
956 mod await_keyword { }
958 #[doc(keyword = "dyn")]
960 /// Name the type of a [trait object].
962 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
964 /// [trait object]: ../book/ch17-02-trait-objects.html
965 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
968 #[doc(keyword = "union")]
970 /// The [Rust equivalent of a C-style union][union].
972 /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
974 /// [union]: ../reference/items/unions.html
975 /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
976 mod union_keyword { }