Skip to content

Commit e06ca65

Browse files
committed
tutorial: Remove the section on constants
We can mention that constants are declared with 'const' in one line. Don't need an entire section.
1 parent 0b0b50a commit e06ca65

File tree

1 file changed

+0
-28
lines changed

1 file changed

+0
-28
lines changed

doc/tutorial.md

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -342,34 +342,6 @@ character, such as `\n`, `\r`, and `\t`. String literals,
342342
written between double quotes, allow the same escape sequences. Rust strings
343343
may contain newlines.
344344

345-
## Constants
346-
347-
Compile-time constants are declared with `const`. A constant may have any
348-
scalar type (for example, integer or float). Other allowable constant types
349-
are fixed-length vectors, static strings (more on this later), and
350-
structs. Constants may be declared in any scope and may refer to other
351-
constants. The compiler does not infer types for constants, so constants must
352-
always be declared with a type annotation. By convention, they are written in
353-
all capital letters.
354-
355-
~~~
356-
// Scalars can be constants
357-
const MY_PASSWORD: int = 12345;
358-
359-
// Scalar constants can be combined with other constants
360-
const MY_DOGGIES_PASSWORD: int = MY_PASSWORD + 1;
361-
362-
// Fixed-length vectors
363-
const MY_VECTORY_PASSWORD: [int * 5] = [1, 2, 3, 4, 5];
364-
365-
// Static strings
366-
const MY_STRINGY_PASSWORD: &static/str = "12345";
367-
368-
// Structs
369-
struct Password { value: int }
370-
const MY_STRUCTY_PASSWORD: Password = Password { value: MY_PASSWORD };
371-
~~~
372-
373345
## Operators
374346

375347
Rust's set of operators contains very few surprises. Arithmetic is done with

0 commit comments

Comments
 (0)