Skip to content

Commit

Permalink
Small tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Mar 4, 2024
1 parent e6007a8 commit affe910
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
16 changes: 8 additions & 8 deletions crates/uv-client/src/registry_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::str::FromStr;

use async_http_range_reader::AsyncHttpRangeReader;
use futures::{FutureExt, TryStreamExt};

use http::HeaderMap;
use reqwest::{Client, ClientBuilder, Response, StatusCode};
use reqwest_retry::policies::ExponentialBackoff;
Expand All @@ -17,12 +16,6 @@ use tokio_util::compat::FuturesAsyncReadCompatExt;
use tracing::{debug, info_span, instrument, trace, warn, Instrument};
use url::Url;

use crate::cached_client::CacheControl;
use crate::html::SimpleHtml;
use crate::middleware::OfflineMiddleware;
use crate::remote_metadata::wheel_metadata_from_remote_zip;
use crate::rkyvutil::OwnedArchive;
use crate::{CachedClient, CachedClientError, Error, ErrorKind};
use distribution_filename::{DistFilename, SourceDistFilename, WheelFilename};
use distribution_types::{BuiltDist, File, FileLocation, IndexUrl, IndexUrls, Name};
use install_wheel_rs::{find_dist_info, is_metadata_entry};
Expand All @@ -34,6 +27,13 @@ use uv_normalize::PackageName;
use uv_version::version;
use uv_warnings::warn_user_once;

use crate::cached_client::CacheControl;
use crate::html::SimpleHtml;
use crate::middleware::OfflineMiddleware;
use crate::remote_metadata::wheel_metadata_from_remote_zip;
use crate::rkyvutil::OwnedArchive;
use crate::{CachedClient, CachedClientError, Error, ErrorKind};

/// A builder for an [`RegistryClient`].
#[derive(Debug, Clone)]
pub struct RegistryClientBuilder {
Expand Down Expand Up @@ -88,7 +88,7 @@ impl RegistryClientBuilder {
}

pub fn build(self) -> RegistryClient {
// Create user agent
// Create user agent.
let user_agent_string = format!("uv/{}", version());

// Timeout options, matching https://doc.rust-lang.org/nightly/cargo/reference/config.html#httptimeout
Expand Down
12 changes: 6 additions & 6 deletions crates/uv-version/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/// Represents the application version.
/// This should be in sync with uv's version based on the crate version.
pub fn version() -> String {
env!("CARGO_PKG_VERSION").to_string()
/// Return the application version.
///
/// This should be in sync with uv's version based on the Crate version.
pub fn version() -> &'static str {

This comment has been minimized.

Copy link
@samypr100

samypr100 Mar 4, 2024

Collaborator

Thanks @charliermarsh , I did the post feedback change quickly and didn't think about this memory optimization to avoid allocating new strings each time.

env!("CARGO_PKG_VERSION")
}

#[cfg(test)]
Expand All @@ -10,7 +11,6 @@ mod tests {

#[test]
fn test_get_version() {
// Check Version Value
assert_eq!(version(), env!("CARGO_PKG_VERSION").to_string());
assert_eq!(version().to_string(), env!("CARGO_PKG_VERSION").to_string());
}
}

0 comments on commit affe910

Please sign in to comment.