Skip to content

Files

Latest commit

Feb 10, 2022
6766d87 · Feb 10, 2022

History

History

unstable-api

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Feb 10, 2022
Dec 10, 2020
Mar 10, 2021
Mar 10, 2021

Unstable API Dump

This tool will dump the public API for an unstable feature.

Usage

From this directory, run something like:

cargo run --release -- --feature $feature --repo-root $path_to_rust

where $feature is the name of the unstable feature and $path_to_rust is the path to a local clone of rust-lang/rust. You'll probably need to run x.py first to make sure submodules are cloned.

You can also install it as a Cargo tool and use it that way:

cargo install --path .
cd $path_to_rust
cargo unstable-api --feature $feature

You can leave out the --repo-root option when running it inside the rust-lang/rust repository.

Output formatting

On Unix, the output is automatically formatted with rustfmt and highlighted with bat, if you have those tools installed.

Limitations

APIs that are generated by macros won't be picked up. This tool just parses the source code so it can be run without needing to build the standard library itself.

Example output

It'll output something like:

pub mod alloc {
    pub mod vec {
        impl<T, A: Allocator> Vec<T, A> {
            pub fn drain_filter<F>(&mut self, filter: F) -> DrainFilter<'_, T, F, A>
            where
                F: FnMut(&mut T) -> bool,
            {
            }
        }

        #[derive(Debug)]
        pub struct DrainFilter<'a, T, F, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global>
        where
            F: FnMut(&mut T) -> bool, {}

        impl<T, F, A: Allocator> Iterator for DrainFilter<'_, T, F, A>
        where
            F: FnMut(&mut T) -> bool,
        {
            type Item = T;
            fn next(&mut self) -> Option<T> {}
            fn size_hint(&self) -> (usize, Option<usize>) {}
        }

        impl<T, F, A: Allocator> Drop for DrainFilter<'_, T, F, A>
        where
            F: FnMut(&mut T) -> bool,
        {
            fn drop(&mut self) {}
        }
    }

    pub mod collections {
        pub mod linked_list {
            impl<T> LinkedList<T> {
                pub fn drain_filter<F>(&mut self, filter: F) -> DrainFilter<'_, T, F>
                where
                    F: FnMut(&mut T) -> bool,
                {
                }
            }

            pub struct DrainFilter<'a, T: 'a, F: 'a>
            where
                F: FnMut(&mut T) -> bool, {}

            impl<T, F> Iterator for DrainFilter<'_, T, F>
            where
                F: FnMut(&mut T) -> bool,
            {
                type Item = T;
                fn next(&mut self) -> Option<T> {}
                fn size_hint(&self) -> (usize, Option<usize>) {}
            }

            impl<T, F> Drop for DrainFilter<'_, T, F>
            where
                F: FnMut(&mut T) -> bool,
            {
                fn drop(&mut self) {}
            }

            impl<T: fmt::Debug, F> fmt::Debug for DrainFilter<'_, T, F>
            where
                F: FnMut(&mut T) -> bool,
            {
                fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {}
            }
        }
    }
}