I would like to know if it is possible to take the docstrings of an underlying function that I am wrapping and include them in the outer wrapping function's docstrings.
For example, let's suppose I want to create a wrapper for the Vec
struct, the only difference being that for every function call, I always println something.
For example, I might have something like this:
struct SuperVec<T>(Vec<T>)
impl<T> for SuperVec<T> {
fn new() -> Self {
println!("You just called new! Good for you!");
SuperVec(Vec::new())
}
}
A struct like a Vec
has many functions, and while wrapping them is easy enough, copying/pasting all of the docstrings is quite difficult. I wanted to know if there is a way to do something like:
impl<T> for SuperVec<T> {
/// @include Vec::new
fn new() -> Self {
// ......
}
}
that would automatically paste the current docstrings for the Vec::new
function that I am wrapping and add them to the new
function for SuperVec.
Please let me know. If not, perhaps it would be worth it for me to write an RFC (although I have never done it before), if other people were interested.