-
Notifications
You must be signed in to change notification settings - Fork 689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove sp_std
#2101
Comments
And just for reference, there are currently 1525 #!/usr/bin/ruby
require 'json'
require 'set'
ALLOC = Set.new [
"borrow",
"boxed",
"collections",
"format!",
"rc",
"vec",
"vec!"
]
CORE = Set.new [
"any",
"cell",
"cmp",
"convert",
"default",
"fmt",
"hash",
"iter",
"marker",
"mem",
"num",
"ops",
"result",
"slice",
"str",
"sync",
"time"
]
def classify mod
if CORE.include? mod
"core"
elsif ALLOC.include? mod
"alloc"
else
"sp_std"
end
end
paths = `rg -t rust sp_std --json`.each_line.map { |line| (JSON.parse(line)["data"]["path"] || {})["text"] }.select { |p| p != nil }.sort.uniq
paths.each do |path|
old_data = File.read(path)
new_data = old_data.gsub(/sp_std::([a-z_\!]+)(::|;|\[)/) do
"#{classify $1}::#{$1}#{$2}"
end.gsub(/use sp_std::\{([^\};]+)\};/) do
per_crate = {}
$1.strip.split(",").each do |path|
crate = classify(path.strip.split("::")[0])
per_crate[crate] ||= []
per_crate[crate] << path.strip
end
out = ""
per_crate.each do |crate, list|
if list.length == 1
out << "use #{crate}::#{list[0]};\n"
else
out << "use #{crate}::\{#{list.join(", ")}\};\n"
end
end
out.strip
end
next if old_data == new_data
File.write(path, new_data)
end |
Then we need to do this explicit I don't have a strong opinion, but maybe the EDIT: just for reference. We are not alone https://github.com/arkworks-rs/std |
I've no opinion here but.. Arkworks' ark-std exists largely to provide |
Seeing people have worked on this I would move forward and assist with merging them, but in general have mixed feeling about whether this is easier for esp. Junior Rust devs. |
I am in favour of that. One less special thing that people need to wrap their head around when using the substrate code base. To me this crate was always an annoyance. |
First in a series of PRs that reduces our use of sp-std with a view to deprecating it. This is just looking at /substrate and moving some of the references from `sp-std` to `core`. These particular changes should be uncontroversial. Where macros are used `::core` should be used to remove any ambiguity. part of #2101
First in a series of PRs that reduces our use of sp-std with a view to deprecating it. This is just looking at /substrate and moving some of the references from `sp-std` to `core`. These particular changes should be uncontroversial. Where macros are used `::core` should be used to remove any ambiguity. part of paritytech#2101
Following PR for #4941 that removes usage of `sp-std` on templates `sp-std` crate was proposed to deprecate on #2101 @kianenigma --------- Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Following PR for paritytech#4941 that removes usage of `sp-std` on templates `sp-std` crate was proposed to deprecate on paritytech#2101 @kianenigma --------- Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Following PR for paritytech#4941 that removes usage of `sp-std` on templates `sp-std` crate was proposed to deprecate on paritytech#2101 @kianenigma --------- Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
* remove unused deps * fix https://git.duniter.org/nodes/rust/duniter-v2s/-/issues/241 * remove sp_std dependency paritytech/polkadot-sdk#2101 This is the commit message #2: * update metadata * clean Cargo.toml * run benchmarks * update node * update crates
Historically having the
sp_std
crate might have had benefits, but nowadays I think there isn't much point in keeping it as the only thing it's doing is reexporting a few thing fromcore
/alloc
and being confusing to newcomers. We can get rid of it and just usecore
andalloc
directly like everyone else in the Rust ecosystem.For example:
This works in both
std
andno_std
contexts.The text was updated successfully, but these errors were encountered: