Merge branch 'improve-line'

* improve-line:
  publish: radicle-git-ext and radicle-surf
  surf: improve Line API

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
This commit is contained in:
Fintan Halpenny
2023-05-03 20:07:53 +01:00
3 changed files with 18 additions and 4 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "radicle-git-ext"
version = "0.3.0"
version = "0.4.0"
authors = [
"Alexis Sellier <alexis@radicle.xyz>",
"Kim Altintop <kim@eagain.st>",
+2 -2
View File
@@ -2,7 +2,7 @@
name = "radicle-surf"
description = "A code surfing library for Git repositories"
readme = "README.md"
version = "0.9.0"
version = "0.10.0"
authors = ["The Radicle Team <dev@radicle.xyz>"]
edition = "2021"
homepage = "https://github.com/radicle-dev/radicle-surf"
@@ -38,7 +38,7 @@ default-features = false
features = ["vendored-libgit2"]
[dependencies.radicle-git-ext]
version = "0.3.0"
version = "0.4.0"
path = "../radicle-git-ext"
features = ["serde"]
+15 -1
View File
@@ -17,7 +17,7 @@
//! Types that represent diff(s) in a Git repo.
use std::path::PathBuf;
use std::{borrow::Cow, path::PathBuf, string::FromUtf8Error};
#[cfg(feature = "serde")]
use serde::{ser, ser::SerializeStruct, Serialize, Serializer};
@@ -338,6 +338,20 @@ impl<T> From<Vec<Hunk<T>>> for Hunks<T> {
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Line(pub(crate) Vec<u8>);
impl Line {
pub fn as_bytes(&self) -> &[u8] {
self.0.as_slice()
}
pub fn from_utf8(self) -> Result<String, FromUtf8Error> {
String::from_utf8(self.0)
}
pub fn from_utf8_lossy(&self) -> Cow<str> {
String::from_utf8_lossy(&self.0)
}
}
impl From<Vec<u8>> for Line {
fn from(v: Vec<u8>) -> Self {
Self(v)