Auto merge of #58341 - alexreg:cosmetic-2-doc-comments, r=steveklabnik
Cosmetic improvements to doc comments This has been factored out from https://github.com/rust-lang/rust/pull/58036 to only include changes to documentation comments (throughout the rustc codebase). r? @steveklabnik Once you're happy with this, maybe we could get it through with r=1, so it doesn't constantly get invalidated? (I'm not sure this will be an issue, but just in case...) Anyway, thanks for your advice so far!
This commit is contained in:
commit
b244f61b77
486 changed files with 2850 additions and 2822 deletions
|
@ -716,7 +716,7 @@ impl<'a> PrettyEncoder<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Set the number of spaces to indent for each level.
|
||||
/// Sets the number of spaces to indent for each level.
|
||||
/// This is safe to set during encoding.
|
||||
pub fn set_indent(&mut self, indent: usize) {
|
||||
// self.indent very well could be 0 so we need to use checked division.
|
||||
|
@ -1010,13 +1010,13 @@ impl Encodable for Json {
|
|||
}
|
||||
}
|
||||
|
||||
/// Create an `AsJson` wrapper which can be used to print a value as JSON
|
||||
/// Creates an `AsJson` wrapper which can be used to print a value as JSON
|
||||
/// on-the-fly via `write!`
|
||||
pub fn as_json<T>(t: &T) -> AsJson<'_, T> {
|
||||
AsJson { inner: t }
|
||||
}
|
||||
|
||||
/// Create an `AsPrettyJson` wrapper which can be used to print a value as JSON
|
||||
/// Creates an `AsPrettyJson` wrapper which can be used to print a value as JSON
|
||||
/// on-the-fly via `write!`
|
||||
pub fn as_pretty_json<T>(t: &T) -> AsPrettyJson<'_, T> {
|
||||
AsPrettyJson { inner: t, indent: None }
|
||||
|
@ -1039,7 +1039,7 @@ impl Json {
|
|||
}
|
||||
|
||||
/// Attempts to get a nested Json Object for each key in `keys`.
|
||||
/// If any key is found not to exist, find_path will return None.
|
||||
/// If any key is found not to exist, `find_path` will return `None`.
|
||||
/// Otherwise, it will return the Json value associated with the final key.
|
||||
pub fn find_path<'a>(&'a self, keys: &[&str]) -> Option<&'a Json>{
|
||||
let mut target = self;
|
||||
|
@ -1051,7 +1051,7 @@ impl Json {
|
|||
|
||||
/// If the Json value is an Object, performs a depth-first search until
|
||||
/// a value associated with the provided key is found. If no value is found
|
||||
/// or the Json value is not an Object, returns None.
|
||||
/// or the Json value is not an Object, returns `None`.
|
||||
pub fn search<'a>(&'a self, key: &str) -> Option<&'a Json> {
|
||||
match self {
|
||||
&Json::Object(ref map) => {
|
||||
|
@ -1072,13 +1072,13 @@ impl Json {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns true if the Json value is an Object. Returns false otherwise.
|
||||
/// Returns `true` if the Json value is an `Object`.
|
||||
pub fn is_object(&self) -> bool {
|
||||
self.as_object().is_some()
|
||||
}
|
||||
|
||||
/// If the Json value is an Object, returns the associated BTreeMap.
|
||||
/// Returns None otherwise.
|
||||
/// If the Json value is an `Object`, returns the associated `BTreeMap`;
|
||||
/// returns `None` otherwise.
|
||||
pub fn as_object(&self) -> Option<&Object> {
|
||||
match *self {
|
||||
Json::Object(ref map) => Some(map),
|
||||
|
@ -1086,13 +1086,13 @@ impl Json {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns true if the Json value is an Array. Returns false otherwise.
|
||||
/// Returns `true` if the Json value is an `Array`.
|
||||
pub fn is_array(&self) -> bool {
|
||||
self.as_array().is_some()
|
||||
}
|
||||
|
||||
/// If the Json value is an Array, returns the associated vector.
|
||||
/// Returns None otherwise.
|
||||
/// If the Json value is an `Array`, returns the associated vector;
|
||||
/// returns `None` otherwise.
|
||||
pub fn as_array(&self) -> Option<&Array> {
|
||||
match *self {
|
||||
Json::Array(ref array) => Some(&*array),
|
||||
|
@ -1100,13 +1100,13 @@ impl Json {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns true if the Json value is a String. Returns false otherwise.
|
||||
/// Returns `true` if the Json value is a `String`.
|
||||
pub fn is_string(&self) -> bool {
|
||||
self.as_string().is_some()
|
||||
}
|
||||
|
||||
/// If the Json value is a String, returns the associated str.
|
||||
/// Returns None otherwise.
|
||||
/// If the Json value is a `String`, returns the associated `str`;
|
||||
/// returns `None` otherwise.
|
||||
pub fn as_string(&self) -> Option<&str> {
|
||||
match *self {
|
||||
Json::String(ref s) => Some(&s[..]),
|
||||
|
@ -1114,7 +1114,7 @@ impl Json {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns true if the Json value is a Number. Returns false otherwise.
|
||||
/// Returns `true` if the Json value is a `Number`.
|
||||
pub fn is_number(&self) -> bool {
|
||||
match *self {
|
||||
Json::I64(_) | Json::U64(_) | Json::F64(_) => true,
|
||||
|
@ -1122,7 +1122,7 @@ impl Json {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns true if the Json value is a i64. Returns false otherwise.
|
||||
/// Returns `true` if the Json value is a `i64`.
|
||||
pub fn is_i64(&self) -> bool {
|
||||
match *self {
|
||||
Json::I64(_) => true,
|
||||
|
@ -1130,7 +1130,7 @@ impl Json {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns true if the Json value is a u64. Returns false otherwise.
|
||||
/// Returns `true` if the Json value is a `u64`.
|
||||
pub fn is_u64(&self) -> bool {
|
||||
match *self {
|
||||
Json::U64(_) => true,
|
||||
|
@ -1138,7 +1138,7 @@ impl Json {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns true if the Json value is a f64. Returns false otherwise.
|
||||
/// Returns `true` if the Json value is a `f64`.
|
||||
pub fn is_f64(&self) -> bool {
|
||||
match *self {
|
||||
Json::F64(_) => true,
|
||||
|
@ -1146,8 +1146,8 @@ impl Json {
|
|||
}
|
||||
}
|
||||
|
||||
/// If the Json value is a number, return or cast it to a i64.
|
||||
/// Returns None otherwise.
|
||||
/// If the Json value is a number, returns or cast it to a `i64`;
|
||||
/// returns `None` otherwise.
|
||||
pub fn as_i64(&self) -> Option<i64> {
|
||||
match *self {
|
||||
Json::I64(n) => Some(n),
|
||||
|
@ -1156,8 +1156,8 @@ impl Json {
|
|||
}
|
||||
}
|
||||
|
||||
/// If the Json value is a number, return or cast it to a u64.
|
||||
/// Returns None otherwise.
|
||||
/// If the Json value is a number, returns or cast it to a `u64`;
|
||||
/// returns `None` otherwise.
|
||||
pub fn as_u64(&self) -> Option<u64> {
|
||||
match *self {
|
||||
Json::I64(n) => Some(n as u64),
|
||||
|
@ -1166,8 +1166,8 @@ impl Json {
|
|||
}
|
||||
}
|
||||
|
||||
/// If the Json value is a number, return or cast it to a f64.
|
||||
/// Returns None otherwise.
|
||||
/// If the Json value is a number, returns or cast it to a `f64`;
|
||||
/// returns `None` otherwise.
|
||||
pub fn as_f64(&self) -> Option<f64> {
|
||||
match *self {
|
||||
Json::I64(n) => Some(n as f64),
|
||||
|
@ -1177,13 +1177,13 @@ impl Json {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns true if the Json value is a Boolean. Returns false otherwise.
|
||||
/// Returns `true` if the Json value is a `Boolean`.
|
||||
pub fn is_boolean(&self) -> bool {
|
||||
self.as_boolean().is_some()
|
||||
}
|
||||
|
||||
/// If the Json value is a Boolean, returns the associated bool.
|
||||
/// Returns None otherwise.
|
||||
/// If the Json value is a `Boolean`, returns the associated `bool`;
|
||||
/// returns `None` otherwise.
|
||||
pub fn as_boolean(&self) -> Option<bool> {
|
||||
match *self {
|
||||
Json::Boolean(b) => Some(b),
|
||||
|
@ -1191,13 +1191,13 @@ impl Json {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns true if the Json value is a Null. Returns false otherwise.
|
||||
/// Returns `true` if the Json value is a `Null`.
|
||||
pub fn is_null(&self) -> bool {
|
||||
self.as_null().is_some()
|
||||
}
|
||||
|
||||
/// If the Json value is a Null, returns ().
|
||||
/// Returns None otherwise.
|
||||
/// If the Json value is a `Null`, returns `()`;
|
||||
/// returns `None` otherwise.
|
||||
pub fn as_null(&self) -> Option<()> {
|
||||
match *self {
|
||||
Json::Null => Some(()),
|
||||
|
@ -1293,7 +1293,7 @@ impl Stack {
|
|||
/// Returns The number of elements in the Stack.
|
||||
pub fn len(&self) -> usize { self.stack.len() }
|
||||
|
||||
/// Returns true if the stack is empty.
|
||||
/// Returns `true` if the stack is empty.
|
||||
pub fn is_empty(&self) -> bool { self.stack.is_empty() }
|
||||
|
||||
/// Provides access to the StackElement at a given index.
|
||||
|
@ -1319,7 +1319,7 @@ impl Stack {
|
|||
true
|
||||
}
|
||||
|
||||
/// Returns true if the bottom-most elements of this stack are the same as
|
||||
/// Returns `true` if the bottom-most elements of this stack are the same as
|
||||
/// the ones passed as parameter.
|
||||
pub fn starts_with(&self, rhs: &[StackElement<'_>]) -> bool {
|
||||
if self.stack.len() < rhs.len() { return false; }
|
||||
|
@ -1329,7 +1329,7 @@ impl Stack {
|
|||
true
|
||||
}
|
||||
|
||||
/// Returns true if the top-most elements of this stack are the same as
|
||||
/// Returns `true` if the top-most elements of this stack are the same as
|
||||
/// the ones passed as parameter.
|
||||
pub fn ends_with(&self, rhs: &[StackElement<'_>]) -> bool {
|
||||
if self.stack.len() < rhs.len() { return false; }
|
||||
|
@ -1954,7 +1954,7 @@ pub struct Builder<T> {
|
|||
}
|
||||
|
||||
impl<T: Iterator<Item=char>> Builder<T> {
|
||||
/// Create a JSON Builder.
|
||||
/// Creates a JSON Builder.
|
||||
pub fn new(src: T) -> Builder<T> {
|
||||
Builder { parser: Parser::new(src), token: None, }
|
||||
}
|
||||
|
@ -2552,7 +2552,7 @@ impl<'a, T: Encodable> fmt::Display for AsJson<'a, T> {
|
|||
}
|
||||
|
||||
impl<'a, T> AsPrettyJson<'a, T> {
|
||||
/// Set the indentation level for the emitted JSON
|
||||
/// Sets the indentation level for the emitted JSON
|
||||
pub fn indent(mut self, indent: usize) -> AsPrettyJson<'a, T> {
|
||||
self.indent = Some(indent);
|
||||
self
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue