9 changed files with 176 additions and 57 deletions
@ -0,0 +1,37 @@ |
|||||||
|
FROM rust:1.90.0 |
||||||
|
|
||||||
|
# Install basic development tools |
||||||
|
RUN apt-get update && apt-get install -y \ |
||||||
|
build-essential \ |
||||||
|
gdb \ |
||||||
|
git \ |
||||||
|
procps \ |
||||||
|
sudo \ |
||||||
|
&& rm -rf /var/lib/apt/lists/* |
||||||
|
|
||||||
|
# Create developer user with host UID/GID |
||||||
|
ARG USER_UID=1000 |
||||||
|
ARG USER_GID=1000 |
||||||
|
ENV USER_UID=${USER_UID:-1000} |
||||||
|
ENV USER_GID=${USER_GID:-1000} |
||||||
|
RUN groupadd -g $USER_GID developer \ |
||||||
|
&& useradd -u $USER_UID -g $USER_GID -m developer \ |
||||||
|
&& mkdir -p /workspace \ |
||||||
|
&& chown developer:developer /workspace |
||||||
|
|
||||||
|
RUN echo 'developer ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/developer \ |
||||||
|
&& chmod 0440 /etc/sudoers.d/developer |
||||||
|
|
||||||
|
RUN mkdir -p /home/developer/.vscode-server \ |
||||||
|
&& chown -R developer:developer /home/developer/.vscode-server |
||||||
|
|
||||||
|
# Switch to developer user |
||||||
|
USER developer |
||||||
|
|
||||||
|
RUN rustup component add rustfmt |
||||||
|
|
||||||
|
# Set up cargo path |
||||||
|
ENV PATH="/home/developer/.cargo/bin:${PATH}" |
||||||
|
|
||||||
|
# Set default workspace directory |
||||||
|
WORKDIR /workspace |
||||||
@ -0,0 +1,46 @@ |
|||||||
|
{ |
||||||
|
"name": "Rust Development", |
||||||
|
"build": { |
||||||
|
"dockerfile": "Dockerfile", |
||||||
|
"args": { |
||||||
|
"USER_UID": "${localEnv:UID:1000}", |
||||||
|
"USER_GID": "${localEnv:GID:1000}" |
||||||
|
} |
||||||
|
}, |
||||||
|
"remoteUser": "developer", |
||||||
|
"customizations": { |
||||||
|
"vscode": { |
||||||
|
"extensions": [ |
||||||
|
"rust-lang.rust-analyzer", |
||||||
|
"fill-labs.dependi", |
||||||
|
"jalalalizz.cargo-toolset", |
||||||
|
"tamasfe.even-better-toml", |
||||||
|
"vadimcn.vscode-lldb", |
||||||
|
"frosticless.monokai-one-darker", |
||||||
|
"ms-vscode.cpptools", |
||||||
|
"serayuzgur.crates" |
||||||
|
], |
||||||
|
"settings": { |
||||||
|
"workbench.colorTheme": "Monokai One Darker", |
||||||
|
"terminal.integrated.defaultProfile.linux": "bash", |
||||||
|
"rust-analyzer.checkOnSave": true, |
||||||
|
"rust-analyzer.cargo.loadOutDirsFromCheck": true, |
||||||
|
"rust-analyzer.procMacro.enable": true, |
||||||
|
"[rust]": { |
||||||
|
"editor.defaultFormatter": "rust-lang.rust-analyzer", |
||||||
|
"editor.formatOnSave": true |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
|
"forwardPorts": [8080, 3000], |
||||||
|
"runArgs": [ |
||||||
|
"--name", |
||||||
|
"${localEnv:USER}-${localWorkspaceFolderBasename}-rust-dev", |
||||||
|
"--mount", |
||||||
|
"type=volume,source=vscode-extensions,target=/home/developer/.vscode-server/extensions" |
||||||
|
], |
||||||
|
"postStartCommand": "sudo chown -R $(id -u):$(id -g) ~/.vscode-server || true", |
||||||
|
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind", |
||||||
|
"workspaceFolder": "/workspace" |
||||||
|
} |
||||||
@ -0,0 +1,23 @@ |
|||||||
|
use crate::core::SystemEncoder; |
||||||
|
|
||||||
|
pub struct MajorEncoder { |
||||||
|
dict: String, // TODO
|
||||||
|
} |
||||||
|
|
||||||
|
impl MajorEncoder { |
||||||
|
pub fn new(dict: &str) -> Self { |
||||||
|
MajorEncoder { |
||||||
|
dict: String::from(dict), |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
impl SystemEncoder for MajorEncoder { |
||||||
|
fn encode(&self, word: &str) -> String { |
||||||
|
let num_word: String = word |
||||||
|
.chars() |
||||||
|
.map(|c| c.to_digit(10).unwrap_or(0).to_string()) |
||||||
|
.collect(); |
||||||
|
format!("{}_{} -> {}", word, self.dict, num_word) |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,7 @@ |
|||||||
|
pub mod major_system_encoder; |
||||||
|
pub mod system; |
||||||
|
pub mod system_encoder; |
||||||
|
|
||||||
|
pub use self::major_system_encoder::*; |
||||||
|
pub use self::system::*; |
||||||
|
pub use self::system_encoder::*; |
||||||
@ -0,0 +1,15 @@ |
|||||||
|
use crate::core::MajorEncoder; |
||||||
|
use crate::core::SystemEncoder; |
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)] |
||||||
|
pub enum System { |
||||||
|
MajorEn, |
||||||
|
MajorPl, |
||||||
|
} |
||||||
|
|
||||||
|
pub fn create_encoder(system: &System) -> Box<dyn SystemEncoder> { |
||||||
|
match system { |
||||||
|
System::MajorPl => Box::new(MajorEncoder::new("dict-major-pl")), |
||||||
|
System::MajorEn => Box::new(MajorEncoder::new("dict-major-en")), |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,3 @@ |
|||||||
|
pub trait SystemEncoder { |
||||||
|
fn encode(&self, word: &str) -> String; |
||||||
|
} |
||||||
@ -1,28 +1,36 @@ |
|||||||
pub struct TextProcessor { |
// pub mod core;
|
||||||
prefix: String, |
|
||||||
} |
|
||||||
|
|
||||||
impl TextProcessor { |
mod core; |
||||||
/// Create a new processor with custom prefix
|
|
||||||
pub fn new(prefix: &str) -> Self { |
|
||||||
Self { |
|
||||||
prefix: prefix.to_string(), |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// Process input text by adding prefix and converting to uppercase
|
pub use self::core::System; |
||||||
pub fn process(&self, input: &str) -> String { |
pub use self::core::SystemEncoder; |
||||||
format!("{} {}", self.prefix, input.to_uppercase()) |
pub use self::core::create_encoder; |
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
#[cfg(test)] |
// pub struct TextProcessor {
|
||||||
mod tests { |
// prefix: String,
|
||||||
use super::*; |
// }
|
||||||
|
|
||||||
#[test] |
// impl TextProcessor {
|
||||||
fn test_processing() { |
// /// Create a new processor with custom prefix
|
||||||
let processor = TextProcessor::new(">> "); |
// pub fn new(prefix: &str) -> Self {
|
||||||
assert_eq!(processor.process("hello"), ">> HELLO"); |
// Self {
|
||||||
} |
// prefix: prefix.to_string(),
|
||||||
} |
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// /// Process input text by adding prefix and converting to uppercase
|
||||||
|
// pub fn process(&self, input: &str) -> String {
|
||||||
|
// format!("{} {}", self.prefix, input.to_uppercase())
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #[cfg(test)]
|
||||||
|
// mod tests {
|
||||||
|
// use super::*;
|
||||||
|
|
||||||
|
// #[test]
|
||||||
|
// fn test_processing() {
|
||||||
|
// let processor = TextProcessor::new(">> ");
|
||||||
|
// assert_eq!(processor.process("hello"), ">> HELLO");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|||||||
Loading…
Reference in new issue