rust/src/doc/book/syntax-index.md
Steve Klabnik 024aa9a345 src/doc/trpl -> src/doc/book
The book was located under 'src/doc/trpl' because originally, it was
going to be hosted under that URL. Late in the game, before 1.0, we
decided that /book was a better one, so we changed the output, but
not the input. This causes confusion for no good reason. So we'll change
the source directory to look like the output directory, like for every
other thing in src/doc.
2015-11-19 11:30:18 -05:00

13 KiB

% Syntax Index

Keywords

Operators and Symbols

  • ! (expr!(…), expr!{…}, expr![…]): denotes macro expansion. See Macros.
  • ! (!expr): bitwise or logical complement. Overloadable (Not).
  • % (expr % expr): arithmetic remainder. Overloadable (Rem).
  • %= (var %= expr): arithmetic remainder & assignment.
  • & (expr & expr): bitwise and. Overloadable (BitAnd).
  • & (&expr): borrow. See References and Borrowing.
  • & (&type, &mut type, &'a type, &'a mut type): borrowed pointer type. See References and Borrowing.
  • &= (var &= expr): bitwise and & assignment.
  • && (expr && expr): logical and.
  • * (expr * expr): arithmetic multiplication. Overloadable (Mul).
  • * (*expr): dereference.
  • * (*const type, *mut type): raw pointer. See Raw Pointers.
  • *= (var *= expr): arithmetic multiplication & assignment.
  • + (expr + expr): arithmetic addition. Overloadable (Add).
  • + (trait + trait, 'a + trait): compound type constraint. See Traits (Multiple Trait Bounds).
  • += (var += expr): arithmetic addition & assignment.
  • ,: argument and element separator. See Attributes, Functions, Structs, Generics, Match, Closures, Crates and Modules (Importing Modules with use).
  • - (expr - expr): arithmetic subtraction. Overloadable (Sub).
  • - (- expr): arithmetic negation. Overloadable (Neg).
  • -= (var -= expr): arithmetic subtraction & assignment.
  • -> (fn(…) -> type, |…| -> type): function and closure return type. See Functions, Closures.
  • -> ! (fn(…) -> !, |…| -> !): diverging function or closure. See Diverging Functions.
  • . (expr.ident): member access. See Structs, Method Syntax.
  • .. (.., expr.., ..expr, expr..expr): right-exclusive range literal.
  • .. (..expr): struct literal update syntax. See Structs (Update syntax).
  • .. (variant(x, ..), struct_type { x, .. }): "and the rest" pattern binding. See Patterns (Ignoring bindings).
  • ... (expr ... expr): inclusive range pattern. See Patterns (Ranges).
  • / (expr / expr): arithmetic division. Overloadable (Div).
  • /= (var /= expr): arithmetic division & assignment.
  • : (pat: type, ident: type): constraints. See Variable Bindings, Functions, Structs, Traits.
  • : (ident: expr): struct field initializer. See Structs.
  • : ('a: loop {…}): loop label. See Loops (Loops Labels).
  • ;: statement and item terminator.
  • ; ([…; len]): part of fixed-size array syntax. See Primitive Types (Arrays).
  • << (expr << expr): left-shift. Overloadable (Shl).
  • <<= (var <<= expr): left-shift & assignment.
  • < (expr < expr): less-than comparison. Overloadable (Cmp, PartialCmp).
  • <= (var <= expr): less-than or equal-to comparison. Overloadable (Cmp, PartialCmp).
  • = (var = expr, ident = type): assignment/equivalence. See Variable Bindings, type Aliases, generic parameter defaults.
  • == (var == expr): comparison. Overloadable (Eq, PartialEq).
  • => (pat => expr): part of match arm syntax. See Match.
  • > (expr > expr): greater-than comparison. Overloadable (Cmp, PartialCmp).
  • >= (var >= expr): greater-than or equal-to comparison. Overloadable (Cmp, PartialCmp).
  • >> (expr >> expr): right-shift. Overloadable (Shr).
  • >>= (var >>= expr): right-shift & assignment.
  • @ (ident @ pat): pattern binding. See Patterns (Bindings).
  • ^ (expr ^ expr): bitwise exclusive or. Overloadable (BitXor).
  • ^= (var ^= expr): bitwise exclusive or & assignment.
  • | (expr | expr): bitwise or. Overloadable (BitOr).
  • | (pat | pat): pattern alternatives. See Patterns (Multiple patterns).
  • |= (var |= expr): bitwise or & assignment.
  • || (expr || expr): logical or.
  • _: "ignored" pattern binding. See Patterns (Ignoring bindings).

Other Syntax

  • path<…> (e.g. Vec<u8>): specifies parameters to generic type in a type. See Generics.
  • path::<…>, method::<…> (e.g. "42".parse::<i32>()): specifies parameters to generic type, function, or method in an expression.
  • fn ident<…> …: define generic function. See Generics.
  • struct ident<…> …: define generic structure. See Generics.
  • enum ident<…> …: define generic enumeration. See Generics.
  • impl<…> …: define generic implementation.
  • for<…> type: higher-ranked lifetime bounds.
  • type<ident=type> (e.g. Iterator<Item=T>): a generic type where one or more associated types have specific assignments. See Associated Types.
  • T: U: generic parameter T constrained to types that implement U. See Traits.
  • T: 'a: generic type T must outlive lifetime 'a.
  • 'b: 'a: generic lifetime 'b must outlive lifetime 'a.
  • T: ?Sized: allow generic type parameter to be a dynamically-sized type. See Unsized Types (?Sized).
  • 'a + trait, trait + trait: compound type constraint. See Traits (Multiple Trait Bounds).
  • #[meta]: outer attribute. See Attributes.
  • #![meta]: inner attribute. See Attributes.
  • $ident: macro substitution. See Macros.
  • $ident:kind: macro capture. See Macros.
  • $(…)…: macro repetition. See Macros.
  • //: line comment. See Comments.
  • //!: inner line doc comment. See Comments.
  • ///: outer line doc comment. See Comments.
  • /*…*/: block comment. See Comments.
  • /*!…*/: inner block doc comment. See Comments.
  • /**…*/: outer block doc comment. See Comments.
  • {…}: block expression.
  • Type {…}: struct literal. See Structs.