These traits represent abstract store objects than can store arbitrary data
blocks with store-generated indexes.
A NullStore implementation is provided which acts an always-empty StoreView.
jsgf | |
durham |
Restricted Project |
These traits represent abstract store objects than can store arbitrary data
blocks with store-generated indexes.
A NullStore implementation is provided which acts an always-empty StoreView.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
rust/treedirstate/src/store.rs | ||
---|---|---|
8 | Also usize isn't the right type to use for non-memory things. If the store is >4G then usize wouldn't be large enough on a 32 bit machine. |
rust/treedirstate/src/lib.rs | ||
---|---|---|
18–23 | They're used in vecmap. I couldn't really think of good properties to quickcheck for these traits. | |
rust/treedirstate/src/store.rs | ||
8 | I've changed BlockId to be pub struct BlockId(u64). I'm not sure if this is the right approach, though, as it means I need to use id.0 to pull out the number (e.g. to pass it to python code, or to write it out). Let me know what you think in the revised version. | |
20–24 | Yes, the blocks of data in the store are immutable once written. I'll highlight this in the comments. |
rust/treedirstate/src/errors.rs | ||
---|---|---|
12 | Is there any convention in rust for explaining what macro's do? For instance, if I have worked in rust, but never seen error_chain before, do I need to go read the error_chain documentation in order to understand this file? Or should we have comments that describe what these things are doing? Seems like this type of problem will only grow as we depend on more and more macros. | |
rust/treedirstate/src/store.rs | ||
12 | Assumed to be thread safe? Or no? Probably something we want to be explicit about if we're planning for a future where these things run in a daemon. | |
14 | Do we have line length lint rules for rust yet? |
rust/treedirstate/src/errors.rs | ||
---|---|---|
12 | There is a way to expand macros. Although sometimes it's not human-readable. I think we won't need too many external macros. error_chain! and quickcheck! might be the only worthwhile ones for now. | |
rust/treedirstate/src/store.rs | ||
12 | Structs using thread-unsafe primitives won't compile when being passed across thread boundary. | |
14 | rustfmt uses 100 characters by default. | |
56 | Maybe Boxed<[u8]> is better than Vec<u8> here to indicate the content is immutable. |
rust/treedirstate/src/store.rs | ||
---|---|---|
56 | It's for test code only, so I'm ok with it being mutable (a future test may want to do some underhanded mutations). |
Path | Packages | |||
---|---|---|---|---|
M | rust/treedirstate/Cargo.lock (63 lines) | |||
M | rust/treedirstate/Cargo.toml (3 lines) | |||
A | M | rust/treedirstate/src/errors.rs (16 lines) | ||
M | rust/treedirstate/src/lib.rs (7 lines) | |||
A | M | rust/treedirstate/src/store.rs (103 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | mbthomas | ||
Closed | mbthomas | ||
Closed | mbthomas | ||
Closed | mbthomas | ||
Closed | mbthomas | ||
Closed | mbthomas | ||
Closed | mbthomas | ||
Closed | mbthomas | ||
Closed | mbthomas | ||
Closed | mbthomas | ||
Closed | mbthomas | ||
Closed | mbthomas | ||
Closed | mbthomas | ||
Closed | mbthomas | ||
Closed | mbthomas | ||
Closed | mbthomas | ||
Closed | mbthomas | ||
Closed | mbthomas | ||
Closed | mbthomas | D1399 treedirstate: add Tree | |
Closed | mbthomas | ||
Closed | mbthomas | ||
Closed | mbthomas | ||
Closed | mbthomas |
[[package]] | [[package]] | ||||
name = "aho-corasick" | name = "aho-corasick" | ||||
version = "0.5.3" | version = "0.5.3" | ||||
source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
dependencies = [ | dependencies = [ | ||||
"memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", | "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", | ||||
] | ] | ||||
[[package]] | [[package]] | ||||
name = "backtrace" | |||||
version = "0.3.3" | |||||
source = "registry+https://github.com/rust-lang/crates.io-index" | |||||
dependencies = [ | |||||
"backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", | |||||
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", | |||||
"dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | |||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", | |||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", | |||||
"rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", | |||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", | |||||
] | |||||
[[package]] | |||||
name = "backtrace-sys" | |||||
version = "0.1.16" | |||||
source = "registry+https://github.com/rust-lang/crates.io-index" | |||||
dependencies = [ | |||||
"cc 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", | |||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", | |||||
] | |||||
[[package]] | |||||
name = "bitflags" | name = "bitflags" | ||||
version = "0.7.0" | version = "0.7.0" | ||||
source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
[[package]] | [[package]] | ||||
name = "cc" | |||||
version = "1.0.3" | |||||
source = "registry+https://github.com/rust-lang/crates.io-index" | |||||
[[package]] | |||||
name = "cfg-if" | |||||
version = "0.1.2" | |||||
source = "registry+https://github.com/rust-lang/crates.io-index" | |||||
[[package]] | |||||
name = "dbghelp-sys" | |||||
version = "0.2.0" | |||||
source = "registry+https://github.com/rust-lang/crates.io-index" | |||||
dependencies = [ | |||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", | |||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", | |||||
] | |||||
[[package]] | |||||
name = "either" | name = "either" | ||||
version = "1.4.0" | version = "1.4.0" | ||||
source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
[[package]] | [[package]] | ||||
name = "env_logger" | name = "env_logger" | ||||
version = "0.3.5" | version = "0.3.5" | ||||
source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
dependencies = [ | dependencies = [ | ||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", | "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", | ||||
"regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", | "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", | ||||
] | ] | ||||
[[package]] | [[package]] | ||||
name = "error-chain" | |||||
version = "0.11.0" | |||||
source = "registry+https://github.com/rust-lang/crates.io-index" | |||||
dependencies = [ | |||||
"backtrace 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", | |||||
] | |||||
[[package]] | |||||
name = "fuchsia-zircon" | name = "fuchsia-zircon" | ||||
version = "0.2.1" | version = "0.2.1" | ||||
source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
dependencies = [ | dependencies = [ | ||||
"fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | "fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||||
] | ] | ||||
[[package]] | [[package]] | ||||
] | ] | ||||
[[package]] | [[package]] | ||||
name = "regex-syntax" | name = "regex-syntax" | ||||
version = "0.3.9" | version = "0.3.9" | ||||
source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
[[package]] | [[package]] | ||||
name = "rustc-demangle" | |||||
version = "0.1.5" | |||||
source = "registry+https://github.com/rust-lang/crates.io-index" | |||||
[[package]] | |||||
name = "rusttreedirstate" | name = "rusttreedirstate" | ||||
version = "0.1.0" | version = "0.1.0" | ||||
dependencies = [ | dependencies = [ | ||||
"error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", | |||||
"itertools 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", | "itertools 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", | ||||
"quickcheck 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", | "quickcheck 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", | ||||
] | ] | ||||
[[package]] | [[package]] | ||||
name = "thread-id" | name = "thread-id" | ||||
version = "2.0.0" | version = "2.0.0" | ||||
source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
[[package]] | [[package]] | ||||
name = "winapi-build" | name = "winapi-build" | ||||
version = "0.1.1" | version = "0.1.1" | ||||
source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
[metadata] | [metadata] | ||||
"checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66" | "checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66" | ||||
"checksum backtrace 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "99f2ce94e22b8e664d95c57fff45b98a966c2252b60691d0b7aeeccd88d70983" | |||||
"checksum backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "44585761d6161b0f57afc49482ab6bd067e4edef48c12a152c237eb0203f7661" | |||||
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" | "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" | ||||
"checksum cc 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a9b13a57efd6b30ecd6598ebdb302cca617930b5470647570468a65d12ef9719" | |||||
"checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" | |||||
"checksum dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850" | |||||
"checksum either 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "740178ddf48b1a9e878e6d6509a1442a2d42fd2928aae8e7a6f8a36fb01981b3" | "checksum either 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "740178ddf48b1a9e878e6d6509a1442a2d42fd2928aae8e7a6f8a36fb01981b3" | ||||
"checksum env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f" | "checksum env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f" | ||||
"checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3" | |||||
"checksum fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f6c0581a4e363262e52b87f59ee2afe3415361c6ec35e665924eb08afe8ff159" | "checksum fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f6c0581a4e363262e52b87f59ee2afe3415361c6ec35e665924eb08afe8ff159" | ||||
"checksum fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "43f3795b4bae048dc6123a6b972cadde2e676f9ded08aef6bb77f5f157684a82" | "checksum fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "43f3795b4bae048dc6123a6b972cadde2e676f9ded08aef6bb77f5f157684a82" | ||||
"checksum itertools 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2c52051d3fd3b505796a0ee90f2e5ec43213808585e8adc4d0182492cf62751a" | "checksum itertools 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2c52051d3fd3b505796a0ee90f2e5ec43213808585e8adc4d0182492cf62751a" | ||||
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" | "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" | ||||
"checksum libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "5ba3df4dcb460b9dfbd070d41c94c19209620c191b0340b929ce748a2bcd42d2" | "checksum libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "5ba3df4dcb460b9dfbd070d41c94c19209620c191b0340b929ce748a2bcd42d2" | ||||
"checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b" | "checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b" | ||||
"checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" | "checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" | ||||
"checksum quickcheck 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "02c2411d418cea2364325b18a205664f9ef8252e06b2e911db97c0b0d98b1406" | "checksum quickcheck 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "02c2411d418cea2364325b18a205664f9ef8252e06b2e911db97c0b0d98b1406" | ||||
"checksum rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)" = "6475140dfd8655aeb72e1fd4b7a1cc1c202be65d71669476e392fe62532b9edd" | "checksum rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)" = "6475140dfd8655aeb72e1fd4b7a1cc1c202be65d71669476e392fe62532b9edd" | ||||
"checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" | "checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" | ||||
"checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" | "checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" | ||||
"checksum rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aee45432acc62f7b9a108cc054142dac51f979e69e71ddce7d6fc7adf29e817e" | |||||
"checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" | "checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" | ||||
"checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5" | "checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5" | ||||
"checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" | "checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" | ||||
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" | "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" | ||||
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" | "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" |
[package] | [package] | ||||
name = "rusttreedirstate" | name = "rusttreedirstate" | ||||
version = "0.1.0" | version = "0.1.0" | ||||
authors = ["Facebook Source Control Team <sourcecontrol-dev@fb.com>"] | authors = ["Facebook Source Control Team <sourcecontrol-dev@fb.com>"] | ||||
[profile.release] | [profile.release] | ||||
lto = true | lto = true | ||||
[lib] | [lib] | ||||
name = "rusttreedirstate" | name = "rusttreedirstate" | ||||
crate-type = ["cdylib"] | crate-type = ["cdylib"] | ||||
[dependencies] | |||||
error-chain = "*" | |||||
[dev-dependencies] | [dev-dependencies] | ||||
itertools = "0.7.2" | itertools = "0.7.2" | ||||
quickcheck = "*" | quickcheck = "*" |
// Copyright Facebook, Inc. 2017 | |||||
//! Errors. | |||||
error_chain! { | |||||
errors { | |||||
InvalidStoreId(id: u64) { | |||||
description("invalid store id"), | |||||
display("invalid store id: {}", id), | |||||
} | |||||
} | |||||
foreign_links { | |||||
Io(::std::io::Error); | |||||
durham: Is there any convention in rust for explaining what macro's do? For instance, if I have worked… | |||||
There is a way to expand macros. Although sometimes it's not human-readable. I think we won't need too many external macros. error_chain! and quickcheck! might be the only worthwhile ones for now. quark: There is [a way](https://github.com/dtolnay/cargo-expand) to expand macros. Although sometimes… | |||||
Utf8(::std::str::Utf8Error); | |||||
Utf8String(::std::string::FromUtf8Error); | |||||
} | |||||
} |
Is there any convention in rust for explaining what macro's do? For instance, if I have worked in rust, but never seen error_chain before, do I need to go read the error_chain documentation in order to understand this file? Or should we have comments that describe what these things are doing?
Seems like this type of problem will only grow as we depend on more and more macros.