check_doc_test(
"generate_getter",
r#####"
+//- minicore: as_ref
+pub struct String;
+impl AsRef<str> for String {
+ fn as_ref(&self) -> &str {
+ ""
+ }
+}
+
struct Person {
nam$0e: String,
}
"#####,
r#####"
+pub struct String;
+impl AsRef<str> for String {
+ fn as_ref(&self) -> &str {
+ ""
+ }
+}
+
struct Person {
name: String,
}
impl Person {
/// Get a reference to the person's name.
fn $0name(&self) -> &str {
- self.name.as_str()
+ self.name.as_ref()
}
}
"#####,
)
}
+#[test]
+fn doctest_unwrap_result_return_type() {
+ check_doc_test(
+ "unwrap_result_return_type",
+ r#####"
+//- minicore: result
+fn foo() -> Result<i32>$0 { Ok(42i32) }
+"#####,
+ r#####"
+fn foo() -> i32 { 42i32 }
+"#####,
+ )
+}
+
#[test]
fn doctest_wrap_return_type_in_result() {
check_doc_test(