@@ -1215,7 +1215,7 @@ A static item must have a _constant expression_ giving its definition.
1215
1215
1216
1216
Static items must be explicitly typed.
1217
1217
The type may be ``` bool ``` , ``` char ``` , a number, or a type derived from those primitive types.
1218
- The derived types are references with the ` ' static` lifetime,
1218
+ The derived types are references with the ` static ` lifetime,
1219
1219
fixed-size arrays, tuples, and structs.
1220
1220
1221
1221
~~~~
@@ -1730,14 +1730,17 @@ names are effectively reserved. Some significant attributes include:
1730
1730
1731
1731
* The ` doc ` attribute, for documenting code in-place.
1732
1732
* The ` cfg ` attribute, for conditional-compilation by build-configuration.
1733
- * The ` lang ` attribute, for custom definitions of traits and functions that are known to the Rust compiler (see [ Language items] ( #language-items ) ).
1734
- * The ` link ` attribute, for describing linkage metadata for a extern blocks.
1735
1733
* The ` crate_id ` attribute, for describing the package ID of a crate.
1734
+ * The ` lang ` attribute, for custom definitions of traits and functions that are
1735
+ known to the Rust compiler (see [ Language items] ( #language-items ) ).
1736
+ * The ` link ` attribute, for describing linkage metadata for a extern blocks.
1736
1737
* The ` test ` attribute, for marking functions as unit tests.
1737
1738
* The ` allow ` , ` warn ` , ` forbid ` , and ` deny ` attributes, for
1738
1739
controlling lint checks (see [ Lint check attributes] ( #lint-check-attributes ) ).
1739
1740
* The ` deriving ` attribute, for automatically generating
1740
1741
implementations of certain traits.
1742
+ * The ` inline ` attribute, for expanding functions at caller location (see
1743
+ [ Inline attributes] ( #inline-attributes ) ).
1741
1744
* The ` static_assert ` attribute, for asserting that a static bool is true at compiletime
1742
1745
* The ` thread_local ` attribute, for defining a ` static mut ` as a thread-local. Note that this is
1743
1746
only a low-level building block, and is not local to a * task* , nor does it provide safety.
@@ -1910,6 +1913,25 @@ A complete list of the built-in language items follows:
1910
1913
> ** Note:** This list is likely to become out of date. We should auto-generate it
1911
1914
> from ` librustc/middle/lang_items.rs ` .
1912
1915
1916
+ ### Inline attributes
1917
+
1918
+ The inline attribute is used to suggest to the compiler to perform an inline
1919
+ expansion and place a copy of the function in the caller rather than generating
1920
+ code to call the function where it is defined.
1921
+
1922
+ The compiler automatically inlines functions based on internal heuristics.
1923
+ Incorrectly inlining functions can actually making the program slower, so it
1924
+ should be used with care.
1925
+
1926
+ ` #[inline] ` and ` #[inline(always)] ` always causes the function to be serialized
1927
+ into crate metadata to allow cross-crate inlining.
1928
+
1929
+ There are three different types of inline attributes:
1930
+
1931
+ * ` #[inline] ` hints the compiler to perform an inline expansion.
1932
+ * ` #[inline(always)] ` asks the compiler to always perform an inline expansion.
1933
+ * ` #[inline(never)] ` asks the compiler to never perform an inline expansion.
1934
+
1913
1935
### Deriving
1914
1936
1915
1937
The ` deriving ` attribute allows certain traits to be automatically
@@ -3223,12 +3245,12 @@ The type of a closure mapping an input of type `A` to an output of type `B` is `
3223
3245
An example of creating and calling a closure:
3224
3246
3225
3247
``` rust
3226
- let captured_var = 10 ;
3248
+ let captured_var = 10 ;
3227
3249
3228
- let closure_no_args = || println! (" captured_var={}" , captured_var );
3250
+ let closure_no_args = || println! (" captured_var={}" , captured_var );
3229
3251
3230
3252
let closure_args = | arg : int | -> int {
3231
- println! (" captured_var={}, arg={}" , captured_var , arg );
3253
+ println! (" captured_var={}, arg={}" , captured_var , arg );
3232
3254
arg // Note lack of semicolon after 'arg'
3233
3255
};
3234
3256
0 commit comments