diff --git a/core/src/render/svg.rs b/core/src/render/svg.rs index 9288572..ad1fd92 100644 --- a/core/src/render/svg.rs +++ b/core/src/render/svg.rs @@ -58,7 +58,7 @@ pub fn render_svg(qr: &QrCode, logo: Option<&[u8]>) -> String { /// 简易 base64 编码(无外部依赖) fn base64_encode(data: &[u8]) -> String { const CHARS: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - let mut result = String::with_capacity((data.len() + 2) / 3 * 4); + let mut result = String::with_capacity(data.len().div_ceil(3) * 4); for chunk in data.chunks(3) { let b0 = chunk[0] as u32; let b1 = if chunk.len() > 1 { chunk[1] as u32 } else { 0 };