-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Show the actual value of constant values in the documentation #66221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Test that the contents of constants are displayed as part of the | ||
// documentation. | ||
|
||
// @has show_const_contents/constant.CONST_S.html 'show this' | ||
// @!has show_const_contents/constant.CONST_S.html '; //' | ||
pub const CONST_S: &'static str = "show this"; | ||
|
||
// @has show_const_contents/constant.CONST_I32.html '= 42;' | ||
// @!has show_const_contents/constant.CONST_I32.html '; //' | ||
pub const CONST_I32: i32 = 42; | ||
|
||
// @has show_const_contents/constant.CONST_I32_HEX.html '= 0x42;' | ||
// @!has show_const_contents/constant.CONST_I32_HEX.html '; //' | ||
pub const CONST_I32_HEX: i32 = 0x42; | ||
|
||
// @has show_const_contents/constant.CONST_NEG_I32.html '= -42;' | ||
// @!has show_const_contents/constant.CONST_NEG_I32.html '; //' | ||
pub const CONST_NEG_I32: i32 = -42; | ||
|
||
// @has show_const_contents/constant.CONST_EQ_TO_VALUE_I32.html '= 42i32;' | ||
// @!has show_const_contents/constant.CONST_EQ_TO_VALUE_I32.html '// 42i32' | ||
pub const CONST_EQ_TO_VALUE_I32: i32 = 42i32; | ||
|
||
// @has show_const_contents/constant.CONST_CALC_I32.html '= 42 + 1; // 43i32' | ||
pub const CONST_CALC_I32: i32 = 42 + 1; | ||
|
||
// @!has show_const_contents/constant.CONST_REF_I32.html '= &42;' | ||
// @!has show_const_contents/constant.CONST_REF_I32.html '; //' | ||
pub const CONST_REF_I32: &'static i32 = &42; | ||
|
||
// @has show_const_contents/constant.CONST_I32_MAX.html '= i32::max_value(); // 2_147_483_647i32' | ||
pub const CONST_I32_MAX: i32 = i32::max_value(); | ||
|
||
// @!has show_const_contents/constant.UNIT.html '= ();' | ||
// @!has show_const_contents/constant.UNIT.html '; //' | ||
pub const UNIT: () = (); | ||
ohadravid marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
pub struct MyType(i32); | ||
|
||
// @!has show_const_contents/constant.MY_TYPE.html '= MyType(42);' | ||
// @!has show_const_contents/constant.MY_TYPE.html '; //' | ||
pub const MY_TYPE: MyType = MyType(42); | ||
|
||
pub struct MyTypeWithStr(&'static str); | ||
|
||
// @!has show_const_contents/constant.MY_TYPE_WITH_STR.html '= MyTypeWithStr("show this");' | ||
// @!has show_const_contents/constant.MY_TYPE_WITH_STR.html '; //' | ||
pub const MY_TYPE_WITH_STR: MyTypeWithStr = MyTypeWithStr("show this"); | ||
|
||
// @has show_const_contents/constant.EPSILON.html '1.1920929e-7f32;' | ||
// @!has show_const_contents/constant.EPSILON.html '; //' | ||
pub use std::f32::EPSILON; | ||
|
||
// @has show_const_contents/constant.MAX.html '= i32::max_value(); // 2_147_483_647i32' | ||
pub use std::i32::MAX; | ||
|
||
macro_rules! int_module { | ||
($T:ident) => ( | ||
pub const MIN: $T = $T::min_value(); | ||
) | ||
} | ||
|
||
// @has show_const_contents/constant.MIN.html '= i16::min_value(); // -32_768i16' | ||
int_module!(i16); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.