Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump toolchain #44

Merged
merged 6 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/y-octo-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
fail-fast: false
matrix:
settings:
- target: x86_64-apple-darwin
host: macos-latest
# - target: aarch64-apple-darwin
# - target: x86_64-apple-darwin
# host: macos-latest
- target: aarch64-apple-darwin
host: macos-latest
- target: x86_64-pc-windows-msvc
host: windows-latest
# - target: aarch64-pc-windows-msvc
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
fail-fast: false
matrix:
settings:
- target: x86_64-apple-darwin
- target: aarch64-apple-darwin
host: macos-latest
- target: x86_64-unknown-linux-gnu
host: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/y-octo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches: [main]

env:
nightly: nightly-2023-08-19
nightly: nightly-2024-07-06

# Cancels all previous workflow runs for pull requests that have not completed.
# See https://docs.github.com/en/actions/using-jobs/using-concurrency
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ members = [
resolver = "2"

[workspace.dependencies]
y-octo = { workspace = true, path = "./y-octo" }
y-octo-utils = { workspace = true, path = "./y-octo-utils" }
y-octo = { path = "./y-octo" }
y-octo-utils = { path = "./y-octo-utils" }

[profile.release]
codegen-units = 1
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"format": "run-p format:toml format:prettier format:rs",
"format:toml": "taplo format",
"format:prettier": "prettier --write .",
"format:rs": "cargo +nightly-2023-08-19 fmt --all"
"format:rs": "cargo +nightly-2024-07-06 fmt --all"
},
"devDependencies": {
"@taplo/cli": "^0.5.2",
Expand All @@ -37,7 +37,7 @@
"taplo format"
],
"*.rs": [
"cargo +nightly-2023-08-19 fmt --"
"cargo +nightly-2024-07-06 fmt --"
]
},
"resolutions": {
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.71.1
1.79.0
8 changes: 8 additions & 0 deletions y-octo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ thiserror = "1.0"
bench = []
debug = []
large_refs = []
serde_json = []

[target.'cfg(fuzzing)'.dependencies]
arbitrary = { version = "1.3", features = ["derive"] }
Expand All @@ -57,6 +58,13 @@ proptest = "1.3"
proptest-derive = "0.4"
yrs = "=0.16.5"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(debug)',
'cfg(fuzzing)',
'cfg(loom)',
] }

[[bench]]
harness = false
name = "array_ops_benchmarks"
Expand Down
53 changes: 37 additions & 16 deletions y-octo/src/doc/codec/any.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use std::{fmt, ops::RangeInclusive};
use std::{
fmt::{self, Display},
ops::RangeInclusive,
};

use ordered_float::OrderedFloat;

Expand Down Expand Up @@ -363,9 +366,9 @@ impl From<serde_json::Value> for Any {
if n.is_f64() {
Self::Float64(n.as_f64().unwrap().into())
} else if n.is_i64() {
Self::Integer(n.as_i64().unwrap() as u64)
Self::Integer(n.as_i64().unwrap() as i32)
} else {
Self::Integer(n.as_u64().unwrap())
Self::Integer(n.as_u64().unwrap() as i32)
}
}
serde_json::Value::String(s) => Self::String(s),
Expand Down Expand Up @@ -515,21 +518,39 @@ impl serde::Serialize for Any {
}
}

impl ToString for Any {
fn to_string(&self) -> String {
impl Display for Any {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::True => "true".to_string(),
Self::False => "false".to_string(),
Self::String(s) => s.clone(),
Self::Integer(i) => i.to_string(),
Self::Float32(f) => f.to_string(),
Self::Float64(f) => f.to_string(),
Self::BigInt64(i) => i.to_string(),
// TODO: stringify other types
_ => {
debug!("any to string {:?}", self);
String::default()
Self::True => write!(f, "true"),
Self::False => write!(f, "false"),
Self::String(s) => write!(f, "\"{}\"", s),
Self::Integer(i) => write!(f, "{}", i),
Self::Float32(v) => write!(f, "{}", v),
Self::Float64(v) => write!(f, "{}", v),
Self::BigInt64(v) => write!(f, "{}", v),
Self::Object(map) => {
write!(f, "{{")?;
for (i, (key, value)) in map.iter().enumerate() {
if i > 0 {
write!(f, ", ")?;
}
write!(f, "{}: {}", key, value)?;
}
write!(f, "}}")
}
Self::Array(vec) => {
write!(f, "[")?;
for (i, value) in vec.iter().enumerate() {
if i > 0 {
write!(f, ", ")?;
}
write!(f, "{}", value)?;
}
write!(f, "]")
}
Self::Binary(buf) => write!(f, "{:?}", buf),
Self::Undefined => write!(f, "undefined"),
Self::Null => write!(f, "null"),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions y-octo/src/doc/common/somr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ impl<T> From<Option<Somr<T>>> for Somr<T> {
}

pub trait FlattenGet<T> {
#[allow(dead_code)]
fn flatten_get(&self) -> Option<&T>;
}

Expand Down
20 changes: 9 additions & 11 deletions y-octo/src/doc/types/text.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::fmt::Display;

use super::list::ListType;
use crate::{impl_type, Content, JwstCodecResult};

Expand Down Expand Up @@ -27,19 +29,15 @@ impl Text {
}
}

impl ToString for Text {
fn to_string(&self) -> String {
let mut ret = String::with_capacity(self.len() as usize);

self.iter_item().fold(&mut ret, |ret, item| {
impl Display for Text {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.iter_item().try_for_each(|item| {
if let Content::String(str) = &item.get().unwrap().content {
ret.push_str(str);
write!(f, "{}", str)
} else {
Ok(())
}

ret
});

ret
})
}
}

Expand Down
12 changes: 7 additions & 5 deletions y-octo/src/doc/types/value.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::fmt::Display;

use super::*;

#[derive(Debug, PartialEq)]
Expand Down Expand Up @@ -123,12 +125,12 @@ impl From<Doc> for Value {
}
}

impl ToString for Value {
fn to_string(&self) -> String {
impl Display for Value {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Value::Any(any) => any.to_string(),
Value::Text(text) => text.to_string(),
_ => String::default(),
Value::Any(any) => write!(f, "{}", any),
Value::Text(text) => write!(f, "{}", text),
_ => write!(f, ""),
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions y-octo/src/protocol/awareness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ pub fn write_awareness<W: Write>(buffer: &mut W, clients: &AwarenessStates) -> R
Ok(())
}

// TODO(@darkskygit): impl reader/writer
// awareness state message
#[allow(dead_code)]
#[derive(Debug, PartialEq)]
pub struct AwarenessMessage {
clients: AwarenessStates,
Expand Down
Loading