1#![forbid(unsafe_code)]
7
8mod relation;
9mod remote;
10mod scalar;
11mod urls;
12mod version;
13
14pub use relation::{
15 InvalidRelationPackage, PositionedRelationParseError, Relation, RelationList,
16 RelationParseError, RequirementVersion, RequirementVersionParseError, Revision,
17 RevisionParseError, VersionRequirement,
18};
19pub use remote::{
20 BioconductorCredentials, BioconductorRemote, CranRemote, GenericGitRemote, HostedGitRemote,
21 LocalRemote, PositionedRemoteParseError, Remote, RemoteList, RemoteParseError, RemoteSource,
22 SvnRemote, UnknownRemote, UrlRemote,
23};
24pub use scalar::{
25 Logical, LogicalParseError, OsType, OsTypeParseError, Priority, PriorityParseError,
26};
27pub use url::Url;
28pub use urls::{
29 AdditionalRepositories, PositionedUrlParseError, SpannedUrl, UrlList, UrlParseError,
30};
31pub use version::{Version, VersionParseError};
32
33#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
35pub struct Span {
36 start: usize,
37 end: usize,
38}
39
40impl Span {
41 pub const fn new(start: usize, end: usize) -> Self {
43 Self { start, end }
44 }
45
46 pub const fn start(self) -> usize {
48 self.start
49 }
50
51 pub const fn end(self) -> usize {
53 self.end
54 }
55
56 pub const fn is_empty(self) -> bool {
58 self.start == self.end
59 }
60
61 pub const fn len(self) -> usize {
63 self.end - self.start
64 }
65}
66
67#[derive(Debug, Clone, PartialEq, Eq, Hash)]
69pub struct Spanned<T> {
70 pub value: T,
72 pub span: Span,
74}
75
76impl<T> Spanned<T> {
77 pub const fn value(&self) -> &T {
79 &self.value
80 }
81
82 pub const fn span(&self) -> Span {
84 self.span
85 }
86}