From a1aea490ae8988ad58893b4c59a0c047c448be73 Mon Sep 17 00:00:00 2001 From: Chris Macklin Date: Wed, 6 Mar 2024 21:07:07 -0800 Subject: [PATCH] Remove all unnecessary uses of unsafe. --- Cargo.lock | 58 ++-- Cargo.toml | 62 ++--- enclone_help/src/help_utils.rs | 466 ++++++++++++++++----------------- enclone_main/src/setup.rs | 8 +- 4 files changed, 289 insertions(+), 305 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 36abe7a86..62df668c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -35,7 +35,7 @@ dependencies = [ [[package]] name = "align_tools" version = "0.1.12" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "bio_edit", "debruijn", @@ -47,7 +47,7 @@ dependencies = [ [[package]] name = "amino" version = "0.1.7" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "debruijn", "string_utils", @@ -56,7 +56,7 @@ dependencies = [ [[package]] name = "ansi_escape" version = "0.1.3" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "string_utils", "vector_utils", @@ -248,7 +248,7 @@ dependencies = [ [[package]] name = "bio_edit" version = "0.1.1" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "bio-types", "bit-set", @@ -624,7 +624,7 @@ dependencies = [ [[package]] name = "dna" version = "0.1.3" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" [[package]] name = "doc-comment" @@ -647,7 +647,7 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "enclone" version = "0.5.219" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "amino", "ansi_escape", @@ -672,7 +672,7 @@ dependencies = [ [[package]] name = "enclone_args" version = "0.5.219" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "debruijn", "enclone_core", @@ -708,7 +708,7 @@ dependencies = [ [[package]] name = "enclone_core" version = "0.5.219" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "amino", "ansi_escape", @@ -852,7 +852,7 @@ dependencies = [ [[package]] name = "enclone_print" version = "0.5.219" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "amino", "ansi_escape", @@ -884,7 +884,7 @@ dependencies = [ [[package]] name = "enclone_proto" version = "0.5.219" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "bio_edit", "byteorder", @@ -897,7 +897,7 @@ dependencies = [ [[package]] name = "enclone_ranger" version = "0.5.219" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "enclone", "enclone_args", @@ -913,7 +913,7 @@ dependencies = [ [[package]] name = "enclone_stuff" version = "0.5.219" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "amino", "debruijn", @@ -1018,7 +1018,7 @@ dependencies = [ [[package]] name = "enclone_vars" version = "0.5.219" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "io_utils", "itertools", @@ -1057,7 +1057,7 @@ dependencies = [ [[package]] name = "equiv" version = "0.1.3" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" [[package]] name = "errno" @@ -1099,7 +1099,7 @@ checksum = "1d4fd7bd9e32c1205549decf6f36772d7b606a579b26afaffa335ae148151a5d" [[package]] name = "exons" version = "0.1.5" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "io_utils", "string_utils", @@ -1109,7 +1109,7 @@ dependencies = [ [[package]] name = "expr_tools" version = "0.1.3" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "evalexpr", "statrs", @@ -1120,7 +1120,7 @@ dependencies = [ [[package]] name = "fasta_tools" version = "0.1.8" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "debruijn", "flate2", @@ -1284,7 +1284,7 @@ checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" [[package]] name = "graph_simple" version = "0.1.5" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "petgraph", "vector_utils", @@ -1329,7 +1329,7 @@ name = "hdf5-sys" version = "0.8.1" source = "git+https://github.com/10XGenomics/hdf5-rust.git?branch=conda_nov2021#2d4a40b7ef75de530bc53fd2eb0fe75047e083ad" dependencies = [ - "attohttpc 0.19.1", + "attohttpc 0.18.0", "bzip2", "libc", "libloading", @@ -1391,7 +1391,7 @@ dependencies = [ [[package]] name = "hyperbase" version = "0.1.8" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "debruijn", "equiv", @@ -1425,7 +1425,7 @@ dependencies = [ [[package]] name = "io_utils" version = "0.3.2" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "bincode", "flate2", @@ -1491,7 +1491,7 @@ dependencies = [ [[package]] name = "kmer_lookup" version = "0.1.5" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "debruijn", "rayon", @@ -2544,12 +2544,12 @@ dependencies = [ [[package]] name = "stats_utils" version = "0.1.3" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" [[package]] name = "string_utils" version = "0.1.4" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "vector_utils", ] @@ -2613,7 +2613,7 @@ dependencies = [ [[package]] name = "tables" version = "0.1.5" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "io_utils", "itertools", @@ -2903,7 +2903,7 @@ dependencies = [ [[package]] name = "vdj_ann" version = "0.4.4" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "align_tools", "amino", @@ -2925,7 +2925,7 @@ dependencies = [ [[package]] name = "vdj_ann_ref" version = "0.2.1" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "debruijn", "exons", @@ -2941,7 +2941,7 @@ dependencies = [ [[package]] name = "vdj_types" version = "0.2.0" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "serde", ] @@ -2958,7 +2958,7 @@ dependencies = [ [[package]] name = "vector_utils" version = "0.1.5" -source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/delete-custom-perf#62956d3179949a95d90ea84543c8d236414d8917" +source = "git+https://github.com/10XGenomics/enclone_ranger?branch=macklin/remove-unsafe#4d666b23fd9cbbbc32f58cc15f589e307ec01afa" dependencies = [ "permutation", "superslice", diff --git a/Cargo.toml b/Cargo.toml index 7c60ff1db..f574964ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,19 +63,19 @@ split-debuginfo = "unpacked" # improved. [workspace.dependencies] -align_tools = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } -amino = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } +align_tools = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } +amino = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } anyhow = "1" -ansi_escape = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } +ansi_escape = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } arboard = "2" assert_cmd = "2" async-trait = "0.1" attohttpc = { version = "0.18", default-features = false, features = ["compress", "tls-rustls"] } backtrace = "0.3" base64 = "0.13" -binary_vec_io = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } +binary_vec_io = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } bio = "0.39" -bio_edit = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } +bio_edit = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } byteorder = "1" bytes = "1" chrono = { version = "0.4", default-features = false, features = ["std", "clock"] } @@ -86,41 +86,41 @@ core-graphics = "0.22" crc = "2" debruijn = "0.3" dirs = "4" -dna = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } +dna = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } edit-distance = "2" -enclone_args = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } -enclone_core = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } +enclone_args = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } +enclone_core = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } enclone_denovo = { path = "../enclone_denovo" } enclone_help = { path = "../enclone_help" } -enclone = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } -enclone_print = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } -enclone_proto = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } -enclone_ranger = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } +enclone = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } +enclone_print = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } +enclone_proto = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } +enclone_ranger = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } enclone_server_proto = { path = "../enclone_server_proto" } -enclone_stuff = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } +enclone_stuff = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } enclone_tail = { path = "../enclone_tail" } -enclone_vars = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } +enclone_vars = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } enclone_version = { path = "../enclone_version" } -equiv = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } +equiv = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } evalexpr = "7" -expr_tools = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } -fasta_tools = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } +expr_tools = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } +fasta_tools = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } file-lock = "2" flate2 = "1" float-ord = "0.3" fontdb = "0.7" fs_extra = "1" git = "https://github.com/10xGenomics/hdf5-rust.git" -graph_simple = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } +graph_simple = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } hdf5 = { git = "https://github.com/10XGenomics/hdf5-rust.git", branch = "conda_nov2021", features = ["conda"], default-features = false } home = "0.5" -hyperbase = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } +hyperbase = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } image = { version = "0.23", features = ["jpeg", "png", "jpeg_rayon"], default-features = false } include_dir = { version = "0.6", features = ["search"] } -io_utils = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } +io_utils = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } itertools = "0.10" jpeg-decoder = "0.2" -kmer_lookup = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } +kmer_lookup = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } lazy_static = "1" libc = "0.2" log = "0.4" @@ -133,12 +133,12 @@ num-traits = "0.2" objc = "0.2" pager = "0.16" palette = "0.6" -perf_stats = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } +perf_stats = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } permutation = "0.4" petgraph = "0.6" plotters = { version = "0.3", default_features = false, features = ["svg_backend", "point_series"] } png-decoder = "0.1" -pretty_trace = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf", features = ["pprof"]} +pretty_trace = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe", features = ["pprof"]} procfs = { version = "0.12", default_features = false } # prost: enclone will compile without the std and prost-derive features, but other things # (such as enclone_proto) break. @@ -154,12 +154,12 @@ serde = "1" serde_derive = "1" serde_json = "1" sha2 = "0.10" -stats_utils = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } +stats_utils = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } statrs = "0.15" -stirling_numbers = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } -string_utils = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } +stirling_numbers = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } +string_utils = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } superslice = "1" -tables = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } +tables = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } tar = "0.4" thiserror = "1" tilde-expand = "0.1" @@ -171,9 +171,9 @@ tonic-build = { version = "0.6", default-features = false, features = ["transpor triple_accel = "0.4" users = "0.11" usvg = { version = "0.19", features = ["text"] } -vdj_types = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } -vdj_ann = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } -vdj_ann_ref = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } -vector_utils = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/delete-custom-perf" } +vdj_types = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } +vdj_ann = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } +vdj_ann_ref = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } +vector_utils = { git = "https://github.com/10XGenomics/enclone_ranger", branch = "macklin/remove-unsafe" } whoami = "1" yaml-rust = "0.4" diff --git a/enclone_help/src/help_utils.rs b/enclone_help/src/help_utils.rs index fe95d7e05..efc90cdc0 100644 --- a/enclone_help/src/help_utils.rs +++ b/enclone_help/src/help_utils.rs @@ -119,8 +119,11 @@ impl HelpDesk { self.rows.push(vec![x1.to_string(), x2.to_string()]); } pub fn doc3(&mut self, x1: &str, x2: &str, x3: &str) { - self.rows - .push(vec![print_to(x1), print_to(x2), print_to(x3)]); + self.rows.push(vec![ + self.print_to(x1), + self.print_to(x2), + self.print_to(x3), + ]); } pub fn ldoc3(&mut self, x1: &str, x2: &str, x3: &str) { self.rows.push(vec!["\\hline".to_string(); 3]); @@ -128,16 +131,19 @@ impl HelpDesk { .push(vec![x1.to_string(), x2.to_string(), x3.to_string()]); } pub fn docpr(&mut self, x1: &str, x2: &str) { - self.rows.push(vec![print_to(x1), print_to(x2)]); + self.rows.push(vec![self.print_to(x1), self.print_to(x2)]); } pub fn ldocpr(&mut self, x1: &str, x2: &str) { self.rows.push(vec!["\\hline".to_string(); 2]); - self.rows.push(vec![print_to(x1), print_to(x2)]); + self.rows.push(vec![self.print_to(x1), self.print_to(x2)]); } pub fn ldoc3pr(&mut self, x1: &str, x2: &str, x3: &str) { self.rows.push(vec!["\\hline".to_string(); 3]); - self.rows - .push(vec![print_to(x1), print_to(x2), print_to(x3)]); + self.rows.push(vec![ + self.print_to(x1), + self.print_to(x2), + self.print_to(x3), + ]); } pub fn doc_red(&mut self, x1: &str, x2: &str) { if !self.plain { @@ -270,7 +276,7 @@ impl HelpDesk { self.ok = true; } pub fn print_with_box(&mut self, x: &str, bold_box: bool) -> Result<(), String> { - let y = print_to(x); + let y = self.print_to(x); let mut rows = Vec::>::new(); let lines = y.split('\n').collect::>(); for z in lines { @@ -282,7 +288,7 @@ impl HelpDesk { Ok(()) } pub fn print(&mut self, x: &str) -> Result<(), String> { - self.print_plain(&print_to(x))?; + self.print_plain(&self.print_to(x))?; Ok(()) } pub fn print_plain_unchecked(&mut self, x: &str) { @@ -340,20 +346,6 @@ impl HelpDesk { } } -// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ - -pub fn stringify(rows: Vec>) -> Vec> { - let mut r = Vec::>::new(); - for i in 0..rows.len() { - let mut x = Vec::::new(); - for j in 0..rows[i].len() { - x.push(rows[i][j].to_string()); - } - r.push(x); - } - r -} - // This encodes the color codes for each possible codon of a given amino acid // that could be found in a BCR or TCR sequence. @@ -403,260 +395,254 @@ pub fn colored_codon_table(plainx: bool) -> String { stringme(&colored) } -pub static mut PLAIN: bool = false; -pub static mut HELP_ALL: bool = false; - -// Print a string, making the following conversions, the first three of which are governed -// by the state of PLAIN: -// • Change \bold{x} into a bolded string by issuing appropriate escape characters. -// • Change \red{x} into a red string by issuing appropriate escape characters. -// • Change \boldred{x} into a bold red string by issuing appropriate escape characters. -// • Fold at 99 characters. - -pub fn print(x: &str) { - print!("{}", print_to(x)); -} - -pub fn print_to(x: &str) -> String { - let mut y = Vec::::new(); - for c in x.chars() { - y.push(c); - } - let mut s = String::new(); - let mut i = 0; - while i < y.len() { - if y[i..].starts_with(&['\\', 'b', 'o', 'l', 'd', '{']) { - let mut j = i + 6; - while j < y.len() { - if y[j] == '}' { - break; +impl HelpDesk { + /// Print a string, making the following conversions, the first three of which are governed + /// by the state of self.plain: + /// • Change \bold{x} into a bolded string by issuing appropriate escape characters. + /// • Change \red{x} into a red string by issuing appropriate escape characters. + /// • Change \boldred{x} into a bold red string by issuing appropriate escape characters. + /// • Fold at 99 characters. + fn print_to(&self, x: &str) -> String { + let mut y = Vec::::new(); + for c in x.chars() { + y.push(c); + } + let mut s = String::new(); + let mut i = 0; + while i < y.len() { + if y[i..].starts_with(&['\\', 'b', 'o', 'l', 'd', '{']) { + let mut j = i + 6; + while j < y.len() { + if y[j] == '}' { + break; + } + j += 1; } - j += 1; - } - if j < y.len() { - let mut log = Vec::::new(); - unsafe { - if !PLAIN { + if j < y.len() { + let mut log = Vec::::new(); + + if !self.plain { emit_bold_escape(&mut log); } - } - s += strme(&log); - for k in i + 6..j { - s.push(y[k]); - } - let mut log = Vec::::new(); - unsafe { - if !PLAIN { + + s += strme(&log); + for k in i + 6..j { + s.push(y[k]); + } + let mut log = Vec::::new(); + + if !self.plain { emit_end_escape(&mut log); } + + s += strme(&log); + i = j + 1; } - s += strme(&log); - i = j + 1; - } - } else if y[i..].starts_with(&['\\', 'r', 'e', 'd', '{']) { - let mut j = i + 5; - while j < y.len() { - if y[j] == '}' { - break; + } else if y[i..].starts_with(&['\\', 'r', 'e', 'd', '{']) { + let mut j = i + 5; + while j < y.len() { + if y[j] == '}' { + break; + } + j += 1; } - j += 1; - } - if j < y.len() { - let mut log = Vec::::new(); - unsafe { - if !PLAIN { + if j < y.len() { + let mut log = Vec::::new(); + + if !self.plain { emit_red_escape(&mut log); } - } - s += strme(&log); - for k in i + 5..j { - s.push(y[k]); - } - let mut log = Vec::::new(); - unsafe { - if !PLAIN { + + s += strme(&log); + for k in i + 5..j { + s.push(y[k]); + } + let mut log = Vec::::new(); + + if !self.plain { emit_end_escape(&mut log); } + + s += strme(&log); + i = j + 1; + } else { + i += 1; } - s += strme(&log); - i = j + 1; - } else { - i += 1; - } - } else if y[i..].starts_with(&['\\', 'b', 'l', 'u', 'e', '{']) { - let mut j = i + 6; - while j < y.len() { - if y[j] == '}' { - break; + } else if y[i..].starts_with(&['\\', 'b', 'l', 'u', 'e', '{']) { + let mut j = i + 6; + while j < y.len() { + if y[j] == '}' { + break; + } + j += 1; } - j += 1; - } - if j < y.len() { - let mut log = Vec::::new(); - unsafe { - if !PLAIN { + if j < y.len() { + let mut log = Vec::::new(); + + if !self.plain { emit_blue_escape(&mut log); } - } - s += strme(&log); - for k in i + 6..j { - s.push(y[k]); - } - let mut log = Vec::::new(); - unsafe { - if !PLAIN { + + s += strme(&log); + for k in i + 6..j { + s.push(y[k]); + } + let mut log = Vec::::new(); + + if !self.plain { emit_end_escape(&mut log); } + + s += strme(&log); + i = j + 1; + } else { + i += 1; } - s += strme(&log); - i = j + 1; - } else { - i += 1; - } - } else if y[i..].starts_with(&['\\', 'g', 'r', 'e', 'e', 'n', '{']) { - let mut j = i + 7; - while j < y.len() { - if y[j] == '}' { - break; + } else if y[i..].starts_with(&['\\', 'g', 'r', 'e', 'e', 'n', '{']) { + let mut j = i + 7; + while j < y.len() { + if y[j] == '}' { + break; + } + j += 1; } - j += 1; - } - if j < y.len() { - let mut log = Vec::::new(); - unsafe { - if !PLAIN { + if j < y.len() { + let mut log = Vec::::new(); + + if !self.plain { emit_green_escape(&mut log); } - } - s += strme(&log); - for k in i + 7..j { - s.push(y[k]); - } - let mut log = Vec::::new(); - unsafe { - if !PLAIN { + + s += strme(&log); + for k in i + 7..j { + s.push(y[k]); + } + let mut log = Vec::::new(); + + if !self.plain { emit_end_escape(&mut log); } + + s += strme(&log); + i = j + 1; + } else { + i += 1; } - s += strme(&log); - i = j + 1; - } else { - i += 1; - } - } else if y[i..].starts_with(&['\\', 'b', 'o', 'l', 'd', 'r', 'e', 'd', '{']) { - let mut j = i + 9; - while j < y.len() { - if y[j] == '}' { - break; + } else if y[i..].starts_with(&['\\', 'b', 'o', 'l', 'd', 'r', 'e', 'd', '{']) { + let mut j = i + 9; + while j < y.len() { + if y[j] == '}' { + break; + } + j += 1; } - j += 1; - } - if j < y.len() { - let mut log = Vec::::new(); - unsafe { - if !PLAIN { + if j < y.len() { + let mut log = Vec::::new(); + + if !self.plain { emit_bold_escape(&mut log); emit_red_escape(&mut log); } - } - s += strme(&log); - for k in i + 9..j { - s.push(y[k]); - } - let mut log = Vec::::new(); - unsafe { - if !PLAIN { + + s += strme(&log); + for k in i + 9..j { + s.push(y[k]); + } + let mut log = Vec::::new(); + + if !self.plain { emit_end_escape(&mut log); } + + s += strme(&log); + i = j + 1; + } else { + i += 1; } - s += strme(&log); - i = j + 1; - } else { - i += 1; - } - } else if y[i..].starts_with(&['\\', 'b', 'o', 'l', 'd', 'b', 'l', 'u', 'e', '{']) { - let mut j = i + 10; - while j < y.len() { - if y[j] == '}' { - break; + } else if y[i..].starts_with(&['\\', 'b', 'o', 'l', 'd', 'b', 'l', 'u', 'e', '{']) { + let mut j = i + 10; + while j < y.len() { + if y[j] == '}' { + break; + } + j += 1; } - j += 1; - } - if j < y.len() { - let mut log = Vec::::new(); - unsafe { - if !PLAIN { + if j < y.len() { + let mut log = Vec::::new(); + + if !self.plain { emit_bold_escape(&mut log); emit_blue_escape(&mut log); } - } - s += strme(&log); - for k in i + 10..j { - s.push(y[k]); - } - let mut log = Vec::::new(); - unsafe { - if !PLAIN { + + s += strme(&log); + for k in i + 10..j { + s.push(y[k]); + } + let mut log = Vec::::new(); + + if !self.plain { emit_end_escape(&mut log); } + + s += strme(&log); + i = j + 1; + } else { + i += 1; } - s += strme(&log); - i = j + 1; } else { + s.push(y[i]); i += 1; } - } else { - s.push(y[i]); - i += 1; } - } - let mut x = Vec::::new(); - for c in s.chars() { - x.push(c); - } - let mut printed = 0; - let mut escaped = false; - let mut y = Vec::::new(); - let mut i = 0; - while i < x.len() { - if x[i] == '' { - escaped = true; + let mut x = Vec::::new(); + for c in s.chars() { + x.push(c); } - if escaped { - if x[i] == 'm' { - escaped = false; + let mut printed = 0; + let mut escaped = false; + let mut y = Vec::::new(); + let mut i = 0; + while i < x.len() { + if x[i] == '' { + escaped = true; } - y.push(x[i]); - i += 1; - continue; - } - if x[i] == ' ' { - let mut j = i + 1; - while j < x.len() { - if x[j] == ' ' || x[j] == '\n' || x[j] == '' { - break; + if escaped { + if x[i] == 'm' { + escaped = false; } - j += 1; - } - if printed + j - i >= 100 - 1 { - y.push('\n'); - printed = 0; + y.push(x[i]); i += 1; continue; } + if x[i] == ' ' { + let mut j = i + 1; + while j < x.len() { + if x[j] == ' ' || x[j] == '\n' || x[j] == '' { + break; + } + j += 1; + } + if printed + j - i >= 100 - 1 { + y.push('\n'); + printed = 0; + i += 1; + continue; + } + } + y.push(x[i]); + printed += 1; + if x[i] == '\n' { + printed = 0; + } + i += 1; } - y.push(x[i]); - printed += 1; - if x[i] == '\n' { - printed = 0; + let mut ans = String::new(); + for i in 0..y.len() { + ans.push(y[i]); } - i += 1; - } - let mut ans = String::new(); - for i in 0..y.len() { - ans.push(y[i]); + ans } - ans } pub fn print_tab2(rows: &Vec>) { @@ -667,13 +653,12 @@ pub fn print_tab2(rows: &Vec>) { // Given a string, preface every line in in by a gray left bar. -pub fn gray_left_bar(s: &str) -> String { +pub fn gray_left_bar(s: &str, plain: bool) -> String { let mut gray = "  ".to_string(); - unsafe { - if PLAIN { - gray = "┃ ".to_string(); - } + if plain { + gray = "┃ ".to_string(); } + let mut x = Vec::::new(); for c in s.chars() { x.push(c); @@ -691,12 +676,14 @@ pub fn gray_left_bar(s: &str) -> String { // Function that provides an explanation used for both enclone help lvars and // enclone help cvars. - pub fn explain_alt_versions(h: &mut HelpDesk) -> Result<(), String> { - h.print(&gray_left_bar(&print_to( - "\\red{●} These variables have some alternate versions, \ + h.print(&gray_left_bar( + &h.print_to( + "\\red{●} These variables have some alternate versions, \ as shown in the table below.\n\n", - )))?; + ), + h.plain, + ))?; let mut rows = Vec::>::new(); let row = vec![ "variable".to_string(), @@ -801,9 +788,10 @@ pub fn explain_alt_versions(h: &mut HelpDesk) -> Result<(), String> { rows.push(row); let mut log = String::new(); print_tabular_vbox(&mut log, &rows, 2, &b"l|l|l|l|l|l".to_vec(), false, false); - h.print_plain(&gray_left_bar(&log))?; - h.print_plain(&gray_left_bar(&print_to( - "Some explanation is required. If you use enclone without certain options, you \ + h.print_plain(&gray_left_bar(&log, h.plain))?; + h.print_plain(&gray_left_bar( + &h.print_to( + "Some explanation is required. If you use enclone without certain options, you \ get the \"visual\" column.\n\ • Add the option \\bold{PER_CELL} \ (see \"enclone help display\") and then you get visual output with extra lines for \ @@ -817,6 +805,8 @@ pub fn explain_alt_versions(h: &mut HelpDesk) -> Result<(), String> { line.\n\ \\green{▶} If you try out these features, you'll see exactly what happens! \ \\green{◀}\n", - )))?; + ), + h.plain, + ))?; Ok(()) } diff --git a/enclone_main/src/setup.rs b/enclone_main/src/setup.rs index 22af74488..0cc286a28 100644 --- a/enclone_main/src/setup.rs +++ b/enclone_main/src/setup.rs @@ -14,7 +14,7 @@ use enclone_help::help2::help2; use enclone_help::help3::help3; use enclone_help::help4::help4; use enclone_help::help5::help5; -use enclone_help::help_utils::{HelpDesk, HELP_ALL, PLAIN}; +use enclone_help::help_utils::HelpDesk; use enclone_testlist::TEST_FILES_VERSION; use io_utils::{open_for_read, path_exists}; use itertools::Itertools; @@ -262,9 +262,6 @@ pub fn setup( } else if args[i] == "PLAIN" { to_delete[i] = true; plain = true; - unsafe { - PLAIN = true; - } } else if args[i] == "SPLIT" { ctl.gen_opt.split = true; } else if args[i] == "BUG_REPORTS" { @@ -297,9 +294,6 @@ pub fn setup( } let mut help_all = false; if args.len() >= 3 && args[1] == "help" && args[2] == "all" { - unsafe { - HELP_ALL = true; - } help_all = true; } let mut argsx = Vec::::new();