Counting number of stable methods of libstd

I'm curious how fast libstd grows. I'd like to count number of functions in it.

I've tried by counting number of "std" items in rustdoc's search index, but it gives odd results with a bump between 1.26-1.28:

I suspect that's due to counting unstable items, perhaps stdsimd.

Any ideas for a better method?

Counting the number of #[(stable will give a decent underestimate.

(It's an underestimate because in e.g. std::num, macros are used to paste the same functionality between the different numeric types. This might actually be a benefit: only count count_ones twice rather than 24(?) times. Also whitespace is allowed in there, but you can account for that with a cleverer grep.)

In fact, if you parse the entire #[stable] attribute, you can attribute each public API to its stabilized version in one pass, since all #[stable] attributes include the stabilized version.

1 Like

Brilliant!

  45 1.0 env
  39 1.0 process
2511 1.0 rust1
   2 1.1 box_borrow
   9 1.1 dir_entry_ext
   5 1.1 file_type
   1 1.1 fmt_write_char
  20 1.1 from_raw_os
  16 1.1 fs_ext
   2 1.1 ip_u32
   5 1.1 iter_cloned
  81 1.1 metadata_ext
 630 1.1 raw_ext
  17 1.1 raw_os
   4 1.1 receiver_into_iter
   1 1.1 set_permissions
   4 1.1 split_whitespace
   4 1.1 symlink
   1 1.1 symlink_metadata
   2 1.2 cell_eq
  24 1.2 debug_builders
   7 1.2 extend_ref
   1 1.2 formatter_write
   1 1.2 io_invalid_data
   8 1.2 iter_empty
   6 1.2 iter_once
  10 1.2 num_wrapping
   1 1.2 once_new
  13 1.2 process_extensions
   3 1.2 str_matches
   6 1.2 sync_poison
   2 1.2 unicode_case_mapping
   2 1.3 atomic_debug
   2 1.3 box_slice_clone
   2 1.3 cstr_borrow
   1 1.3 cstr_debug
   5 1.3 derefmut_for_string
  10 1.3 duration
  12 1.3 error_downcast
   1 1.3 hash_slice
  10 1.3 hasher_write
   3 1.3 io_error_inner
   1 1.3 process_id
   1 1.3 rename_connect_to_join
   1 1.3 time
   1 1.3 wrapping_div
   2 1.4 addr_parse_error_error
   2 1.4 append
   3 1.4 arc_unique
   8 1.4 arc_weak
   2 1.4 array_borrow
   2 1.4 array_default
   1 1.4 binaryheap_debug
   2 1.4 box_raw
   2 1.4 box_str
  11 1.4 core_prelude
   2 1.4 cstr_memory
   2 1.4 cstr_to_str
   2 1.4 extend_string
   1 1.4 fmt_write_blanket_impl
   7 1.4 fnptr_impls
   2 1.4 hash_extend_copy
  30 1.4 into_raw_os
   4 1.4 iter_to_slice
   2 1.4 option_iter
   1 1.4 park_timeout
   3 1.4 rc_unique
   8 1.4 rc_weak
   1 1.4 result_expect
   2 1.4 result_iter
   8 1.4 socket_timeout
   2 1.4 split_off
   2 1.4 str_split_at
   1 1.4 thread_sleep
   1 1.4 vec_deque_retain
   4 1.5 binary_heap_extras_15
   2 1.5 char_from_unchecked
   1 1.5 cursor_box_slice
   6 1.5 deque_extras_15
  12 1.5 file_type_ext
   7 1.5 fmt_flags
   1 1.5 fs_canonicalize
   8 1.5 iter_order
  20 1.5 lossless_int_conv
   1 1.5 mut_slice_default
   8 1.5 path_ext
   4 1.5 slice_splits
   4 1.5 smart_ptr_as_ref
   2 1.5 socket_addr_from_str
   3 1.5 str_match_indices
   1 1.5 str_parse_error
   1 1.5 str_slice_mut
   1 1.5 utf8_error
   2 1.5 vec_as_mut
   1 1.5 vec_resize
   3 1.5 wait_timeout
   2 1.6 core
   2 1.6 cow_from_path
  10 1.6 dir_builder
  34 1.6 drain
   3 1.6 from_for_ptrs
   2 1.6 iter_cmp_by_key
  11 1.6 lossless_float_conv
   1 1.6 mutex_get_mut
   1 1.6 mutex_into_inner
   2 1.6 partialeq_path
   2 1.6 path_into_iter
   2 1.6 read_exact
   1 1.6 rwlock_get_mut
   1 1.6 rwlock_into_inner
   2 1.6 string_box_error
   1 1.6 vec_extend_from_slice
   2 1.7 btree_drop
   7 1.7 build_hasher
   1 1.7 clone_from_slice
   4 1.7 cstring_asref
   9 1.7 cstring_into
   2 1.7 f32_deg_rad_conversions
   8 1.7 hashmap_build_hasher
   9 1.7 ip_17
   9 1.7 ip_addr
   1 1.7 path_strip_prefix
   1 1.7 process_output_debug
   1 1.7 slice_sort_by_key
   2 1.7 string_as_str
   3 1.7 strip_prefix
   2 1.7 vec_as_slice
  26 1.7 wrapping
   1 1.7 wrapping_impls
   1 1.8 box_error
   2 1.8 cell_map
   4 1.8 cmp_os_str
   6 1.8 cmp_path
   2 1.8 cow_from_vec
   1 1.8 cow_os_str_as_ref_path
   2 1.8 drop_in_place
   4 1.8 encode_utf16
 251 1.8 metadata_ext2
   3 1.8 mpsc_debug
  44 1.8 op_assign_traits
  16 1.8 pthread_t
   1 1.8 slice_to_socket_addrs
   1 1.8 str_parse_error2
  20 1.8 time2
   1 1.8 vec_into_iter_clone
   2 1.9 ascii
  19 1.9 catch_unwind
   1 1.9 chain_bufread
   1 1.9 copy_from_slice
  19 1.9 core_impl_debug
   9 1.9 decode_utf16
   1 1.9 double_ended_skip_iterator
   1 1.9 expand_open_options2
   1 1.9 file_try_clone
   1 1.9 from_slice_v4
   2 1.9 hashmap_public_hasher
   1 1.9 ipv6_from_octets
   1 1.9 is_char_boundary
  31 1.9 net2_mutators
   2 1.9 osstring_default
   7 1.9 osstring_simple_functions
   2 1.9 process_exec2
   3 1.9 ptr_as_ref
   1 1.9 resume_unwind
   6 1.9 set_recovery
   8 1.9 sockaddr_setters
   1 1.9 str_to_string_specialization
   7 1.9 thread_extensions
   8 1.9 time_augmented_assignment
   2 1.9 volatile
   4 1.10 cell_ord
   1 1.10 condvar_default
   2 1.10 cstr_default
   4 1.10 cstr_from_bytes
   4 1.10 downgraded_weak
   4 1.10 extended_compare_and_swap
   3 1.10 fs_time
   6 1.10 map_entry_keys
   9 1.10 map_values_mut
   1 1.10 mutex_default
   9 1.10 open_options_ext
  10 1.10 panic_hooks
   1 1.10 rw_lock_default
   1 1.10 slice_binary_search_by_key
  63 1.10 unix_socket
   1 1.10 unsafe_cell_default
   2 1.10 vecdeque_vec_conversions
   1 1.10 wrapping_display
   1 1.10 wrapping_neg
   1 1.11 binary_heap_append
   2 1.11 btree_append
   2 1.11 btree_split_off
   2 1.11 cell_get_mut
   1 1.11 default
   2 1.11 exact_size_escape
   1 1.11 fmt_error
   2 1.11 iter_arith
   4 1.11 wrapping_fmt
   5 1.12 binary_heap_peek_mut
   2 1.12 cell_as_ptr
   3 1.12 cell_from
   3 1.12 cow_str_from_iter
   3 1.12 debug_btree_map
   3 1.12 debug_hash_map
   2 1.12 env_iterators
   5 1.12 exit_status_from
   1 1.12 fn_once_output
   4 1.12 ip_shared
   1 1.12 ipv6_to_octets
   9 1.12 iter_arith_traits
   1 1.12 linked_list_contains
   4 1.12 map_entry_recover_keys2
   4 1.12 mpsc_recv_timeout
   1 1.12 option_from
   1 1.12 stringaddassign
   2 1.12 unwind_safe_lock_refs
   1 1.12 vec_deque_contains
   2 1.13 assert_ne
   2 1.13 char_convert
   1 1.13 cstring_drop
   1 1.13 dir_entry_debug
   4 1.13 hashmap_default_hasher
   3 1.13 no_panic_abs
   1 1.13 path_components_debug
   1 1.13 path_iter_debug
   1 1.13 slice_iter_as_ref
  10 1.13 try_borrow
   1 1.13 vec_intoiter_debug
   4 1.14 cow_add
   1 1.14 from_path_buf_for_os_string
   1 1.14 from_string_for_vec_u8
   1 1.14 io_error_from_errorkind
   1 1.14 string_from_cow_str
   4 1.14 unwind_safe_atomic_refs
   1 1.14 vec_from_cow_slice
   1 1.14 wrapping_iter_arith
  10 1.14 wrapping_ref
   2 1.15 arc_counts
   4 1.15 atomic_access
   1 1.15 cell_extras
  14 1.15 file_offset
   1 1.15 io_take_into_inner
   1 1.15 iter_max_by
   1 1.15 iter_min_by
   2 1.15 mpsc_recv_timeout_error
  16 1.15 proc_macro_lib
   2 1.15 process_exec
   2 1.15 rc_counts
   3 1.15 receiver_try_iter
   5 1.15 slice_get_slice_impls
   2 1.15 unicode_encode_char
   2 1.15 vec_into_iter_as_slice
   4 1.16 char_struct_display
   2 1.16 dedup_by
   2 1.16 deque_extras
   4 1.16 duration_checked_ops
   2 1.16 duration_sum
   1 1.16 insert_str
   8 1.16 ip_cmp
   4 1.16 ip_from_ip
   2 1.16 ipaddr_checker
   1 1.16 ipv6_from_segments
   2 1.16 iter_arith_traits_result
   2 1.16 ptr_wrapping_offset
   1 1.16 repeat_str
   1 1.16 result_unwrap_or_default
   1 1.16 set_permissions_atomic
   2 1.16 sockaddr_checker
  48 1.16 std_debug
   1 1.16 str_replacen
   1 1.16 string_split_off
   1 1.16 string_to_socket_addrs
   3 1.16 windows_process_extensions
   1 1.17 addr_from_into_ip
   1 1.17 box_default_extra
   1 1.17 box_from_c_str
   1 1.17 box_from_os_str
   1 1.17 box_from_path
   2 1.17 box_from_slice
  14 1.17 btree_range
  24 1.17 collection_debug
   6 1.17 collections_bound
   1 1.17 cow_str_to_string_specialization
   2 1.17 default_box_extra
   1 1.17 default_for_pathbuf
   2 1.17 frombyteswithnulerror_impls
   3 1.17 ip_from_slice
   4 1.17 move_cell
   2 1.17 ordering_chaining
   1 1.17 process_abort
   3 1.17 ptr_eq
   2 1.17 ptr_unaligned
   4 1.17 rc_raw
   1 1.17 result_expect_err
   1 1.17 string_from_iter_by_ref
   1 1.17 string_to_string_specialization
   1 1.17 vec_deque_partial_eq_slice
   1 1.18 binary_heap_peek_mut_pop
   1 1.18 c_string_from_box
   1 1.18 os_string_from_box
   1 1.18 path_buf_from_box
   3 1.18 peek
   1 1.18 process_try_wait
   2 1.18 retain_hash_collection
   1 1.18 string_from_box
   1 1.18 vec_from_box
   1 1.19 boxed_str_conv
   1 1.19 command_envs
   2 1.19 eprint
   2 1.19 herd_cows
   1 1.19 mutexguard
   1 1.19 osstring_shrink_to_fit
   4 1.19 reverse_cmp_key
   2 1.19 thread_id
   1 1.19 vec_from_mut
   1 1.20 as_c_str
   1 1.20 box_from_c_string
   1 1.20 box_from_os_string
   1 1.20 box_from_path_buf
   1 1.20 box_from_str
   1 1.20 box_from_vec
   5 1.20 char_escape_debug
   5 1.20 char_from_str
   1 1.20 compile_error_macro
   4 1.20 float_bits_conv
   2 1.20 into_boxed_c_str
   2 1.20 into_boxed_os_str
   2 1.20 into_boxed_path
   7 1.20 manually_drop
   5 1.20 more_io_inner_methods
   2 1.20 option_entry
   3 1.20 sort_unstable
   5 1.20 std_guard_impls
   4 1.20 stdio_from
   2 1.20 str_box_extras
   8 1.20 str_checked_slicing
   3 1.20 str_mut_extras
   1 1.20 utf8_error_error_len
   9 1.21 asraw_stdio
   1 1.21 compiler_fences
   8 1.21 discriminant_value
   1 1.21 iterator_for_each
   1 1.21 needs_drop
   2 1.21 ord_max_min
  10 1.21 shared_from_slice
   1 1.21 tcpstream_connect_timeout
   6 1.21 vec_splice
   2 1.22 cow_box_error
   2 1.22 indirect_hasher_impl
   1 1.22 op_assign_builtins_by_ref
  24 1.23 ascii_methods_on_intrinsics
   1 1.23 atomic_from
   2 1.23 rwlock_guard_sync
   1 1.23 unit_from_iter
  20 1.24 ascii_ctype_on_intrinsics
   1 1.24 atomic_bool_from
   1 1.24 atomic_pointer
   3 1.24 mpsc_error_conversions
   1 1.24 mutex_from
   1 1.24 refcell_replace
   1 1.24 refcell_swap
   1 1.24 rw_lock_from
  12 1.24 shared_from_slice2
   1 1.24 spin_loop_hint
   1 1.25 cursor_mut_vec
  22 1.25 nonnull
   1 1.25 panic_col
   1 1.25 path_component_asref
   1 1.26 box_leak
   2 1.26 entry_and_modify
   4 1.26 env_unimpl_send_sync
   1 1.26 from_utf8_error_as_bytes
   1 1.26 fs_read_write
   2 1.26 fs_read_write_bytes
 101 1.26 fused
   1 1.26 getpid
  22 1.26 i128
  17 1.26 inclusive_range
   3 1.26 lossless_iusize_conv
   1 1.26 option_ref_mut_cloned
   2 1.26 panic_hook_display
  27 1.26 pointer_methods
   2 1.26 slice_rotate
   1 1.26 string_retain
   5 1.26 thread_local_try_with
   1 1.27 core_hint
   1 1.27 duration_debug_impl
   3 1.27 duration_extras
   1 1.27 duration_from_micros
   1 1.27 hash_map_remove_entry
   4 1.27 inclusive_range_methods
   1 1.27 iter_rfind
   1 1.27 iter_rfold
   3 1.27 iterator_try_fold
   1 1.27 nonnull_cast
   1 1.27 option_filter
   2 1.27 simd_arch
  15 1.27 slice_rsplit
   1 1.27 splice
   1 1.27 swap_nonoverlapping
   1 1.27 swap_with_slice
   1 1.27 take_set_limit
   2 1.27 unix_ppid
   1 1.27 unreachable
  10 1.28 alloc_layout
   2 1.28 alloc_module
   8 1.28 alloc_system_type
   4 1.28 any_send_sync_methods
   1 1.28 assoc_unix_epoch
  16 1.28 collections_range
   3 1.28 cow_from_cstr
   3 1.28 cow_from_osstr
   1 1.28 cow_from_pathbuf_ref
   1 1.28 cow_from_string_ref
   1 1.28 cow_from_vec_ref
   1 1.28 cstring_from_cow_cstr
   1 1.28 default_mut_str
   2 1.28 entry_or_default
   1 1.28 extend_for_unit
   6 1.28 fmt_flags_align
  12 1.28 from_bool
   3 1.28 from_ref
  11 1.28 global_alloc
   1 1.28 global_allocator
   5 1.28 iterator_repeat_with
   5 1.28 iterator_step_by
   7 1.28 nonzero
   1 1.28 osstring_from_cow_osstr
   4 1.28 path_ancestors
   1 1.28 pathbuf_from_cow_path
  11 1.28 slice_get_slice
   2 1.29 build_hasher_eq
   8 1.29 iterator_flatten
   2 1.29 joinhandle_impl_send_sync
   3 1.29 more_box_slice_clone
   1 1.29 never_hash
   2 1.29 os_str_str_ref_eq
  80 1.29 proc_macro_lib2
   2 1.29 rc_downcast
   2 1.30 core_c_void
   1 1.30 error_source
   5 1.30 ip_constructors
   1 1.30 iterator_find_map
   2 1.30 option_ref_from_ref_option
   2 1.30 slice_align_to
   2 1.30 token_stream_extend
   4 1.30 trim_direction
  18 1.31 chunks_exact
   1 1.31 from_nonzero
   1 1.31 option_replace
  33 1.31 rchunks
   1 1.31 symmetric_u32_duration_mul
   1 1.32 boxed_slice_from_iter
   1 1.32 dbg_macro
  12 1.32 int_to_from_bytes
   1 1.32 path_from_str
   1 1.33 convert_id
   3 1.33 duration_as_u128
  34 1.33 pin
   4 1.33 rw_exact_all_at
   2 1.33 transpose_result
   2 1.33 vec_resize_with
  10 1.34 convert_infallible
   1 1.34 get_type_id
   5 1.34 iter_from_fn
   6 1.34 iter_successors
   8 1.34 no_panic_pow
   2 1.34 process_pre_exec
   7 1.34 signed_nonzero
   1 1.34 slice_sort_by_cached_key
   6 1.34 split_ascii_whitespace
  10 1.34 str_escape
   4 1.34 time_checked_add
  26 1.34 try_from
   9 1.35 asraw_stdio_locks
   3 1.35 boxed_closure_impls
   2 1.35 copied
   2 1.35 copysign
   2 1.35 exact_size_case_mapping_iter
   1 1.35 from_ref_string
   1 1.35 nonzero_parse
   1 1.35 ptr_hash
   6 1.35 range_contains
   2 1.35 refcell_map_split
   1 1.35 refcell_replace_swap
   2 1.36 align_offset
   2 1.36 core_array
  45 1.36 futures_api
   1 1.36 hashbrown
  11 1.36 iovec
   8 1.36 iter_copied
   9 1.36 maybe_uninit
   1 1.36 str_as_mut_ptr
   1 1.36 string_borrow_mut
   1 1.36 try_from_slice_error
   2 1.36 vecdeque_rotate
   2 1.37 as_cell
   1 1.37 borrow_state
   2 1.37 bufreader_buffer
   1 1.37 copy_within
   2 1.37 iter_arith_traits_option
   1 1.37 iter_nth_back
   1 1.37 option_xor
   3 1.37 reverse_bits
   2 1.37 shared_from_iter
   2 1.37 vec_as_ptr
  18 1.38 builtin_macro_prelude
   1 1.38 chars_debug_impl
   1 1.38 double_ended_peek_iterator
   1 1.38 double_ended_step_by_iterator
   1 1.38 double_ended_take_iterator
   8 1.38 duration_float
  20 1.38 euclidean_division
   2 1.38 pin_raw
   2 1.38 ptr_cast
   1 1.38 type_name
   1 1.39 ascii_escape_display
   2 1.39 checked_duration_since
   2 1.39 pin_into_inner
   2 1.39 weak_ptr_eq
   4 1.39 wrapping_ref_ops
   8 1.40 array_value_iter_impls
  12 1.40 float_to_from_bytes
   2 1.40 map_get_key_value
   1 1.40 mem_take
   2 1.40 option_deref
   1 1.40 option_flattening
   1 1.40 repeat_generic_slice
   1 1.40 todo_macro
   1 1.40 udp_peer_addr
   1 1.41 maybe_uninit_debug
  35 1.41 nz_int_conv
   5 1.41 pin_trait_impls
   1 1.41 result_map_or
   1 1.41 result_map_or_else
   4 1.41 weak_counts
   2 1.42 debug_map_key_value
   2 1.42 integer_exp_format
   2 1.42 iter_empty_send_sync
   1 1.42 manually_drop_take
   1 1.42 matches_macro
   2 1.42 slice_from_raw_parts
   1 1.42 wait_timeout_until
   1 1.42 wait_until
  32 1.43 assoc_int_consts
   3 1.43 boxed_slice_try_from
  19 1.43 core_primitive
   1 1.43 cstring_from_vec_of_nonzerou8
   4 1.43 extra_log_consts
   8 1.43 iter_once_with
   1 1.43 once_is_completed
   1 1.43 string_as_mut
   1 1.44 convert_infallible_hash
   2 1.44 float_approx_unchecked_to
   1 1.44 from_mut_str_for_string
   4 1.44 iovec-send-sync
   2 1.44 mut_osstr
   2 1.44 proc_macro_lexerror_impls
   1 1.44 vec_from_array
1 Like

Total number of #[stable] items in the standard library:

1 Like

Number of new items added each version (once actual scale, once with 1.0.0 cut off):

And here's comparison between number of stabilized items and the number of unique feature flags that reached stable for the first time in each release:

Sadly, the data doesn't tell the whole story:

  • There were several features that were overcounted, e.g. box_from_c_str, box_from_os_str, box_from_path, box_from_slice are essentially the same minor change.

  • There were some features that needed lots of functions, e.g. Iterator.fused() touched a lot of code, even though for the user that's only one function. Similarly with anything related to integers, e.g. i128 or NonZero* have tons of standard integer functionality and conversions which count as new functions, but from user perspective it's nothing new.

  • And some features are way bigger than others. futures_api is 1 feature, but a major shift.

I've tried manually adding weight to features, but at this point it's totally subjective. Fudge-weighed amount of changes in each Rust release:

Notable changes:

  • 1.13 = ? operator
  • 1.15 = proc macros
  • 1.26 = i128
  • 1.27 = simd
  • 1.28 = global allocators
  • 1.31 = edition 2018
  • 1.33 = pin
  • 1.34 = TryFrom
  • 1.36 = futures
2 Likes