Build a detail string for a method showing its signature.
(method: &MethodInfo)
| 384 | |
| 385 | /// Build a detail string for a method showing its signature. |
| 386 | fn build_method_detail(method: &MethodInfo) -> Option<String> { |
| 387 | let mut detail = String::new(); |
| 388 | |
| 389 | // Visibility prefix. |
| 390 | match method.visibility { |
| 391 | Visibility::Public => {} |
| 392 | Visibility::Protected => detail.push_str("protected "), |
| 393 | Visibility::Private => detail.push_str("private "), |
| 394 | } |
| 395 | |
| 396 | if method.is_static { |
| 397 | detail.push_str("static "); |
| 398 | } |
| 399 | |
| 400 | // Parameter list. |
| 401 | detail.push('('); |
| 402 | let params: Vec<String> = method |
| 403 | .parameters |
| 404 | .iter() |
| 405 | .map(|p| { |
| 406 | let mut s = String::new(); |
| 407 | if let Some(ref t) = p.type_hint { |
| 408 | s.push_str(&t.to_string()); |
| 409 | s.push(' '); |
| 410 | } |
| 411 | if p.is_variadic { |
| 412 | s.push_str("..."); |
| 413 | } |
| 414 | s.push_str(&p.name); |
| 415 | s |
| 416 | }) |
| 417 | .collect(); |
| 418 | detail.push_str(¶ms.join(", ")); |
| 419 | detail.push(')'); |
| 420 | |
| 421 | // Return type. |
| 422 | if let Some(ref ret) = method.return_type { |
| 423 | detail.push_str(": "); |
| 424 | detail.push_str(&ret.to_string()); |
| 425 | } |
| 426 | |
| 427 | Some(detail) |
| 428 | } |
| 429 | |
| 430 | /// Build a detail string for a standalone function showing its signature. |
| 431 | fn build_function_detail(func: &FunctionInfo) -> Option<String> { |