blob_id
stringlengths
40
40
language
stringclasses
1 value
repo_name
stringlengths
5
140
path
stringlengths
5
183
src_encoding
stringclasses
6 values
length_bytes
int64
12
5.32M
score
float64
2.52
4.94
int_score
int64
3
5
detected_licenses
listlengths
0
47
license_type
stringclasses
2 values
text
stringlengths
12
5.32M
download_success
bool
1 class
44bb158e7c0188caa7b80f95f11b4e11396db59e
Rust
NyxTo/Advent-of-Code
/2019/Code/day3_wire.rs
UTF-8
1,404
3.0625
3
[]
no_license
use std::fs::File; use std::io::{BufRead, BufReader}; use std::cmp::{min, max}; fn path(wire: Vec<(char, i32)>) -> (Vec<i32>, Vec<i32>) { let (mut coords, mut steps) = (vec![0, 0], vec![0]); for (dir, amt) in wire { coords.push(coords[coords.len() - 2] + match dir { 'U' | 'R' => amt, 'D' | 'L' => -a...
true
1b24bb939ae5aab8613451b5558f853040f10805
Rust
abr975/CISC3160
/Lab4/Rust/quicksort.rs
UTF-8
992
3.828125
4
[]
no_license
pub fn main () { let mut v = vec![1, 3 , 7 , 40, 120, 64, 5]; quicksort(&mut v); } pub fn quicksort(v: &mut [usize] ){ let mid = partition(v); // mid point of partition if v[..mid].len() > 1 { quicksort(&mut v[..mid]); } if v[mid+1..].len() > 1 { quicksort(&mut v...
true
f8d17c1d167ea22e76e8f7fcd8038e66f72d2db1
Rust
LEEDASILVA/rust
/types.rs
UTF-8
346
3.046875
3
[]
no_license
fn main() { let a = 45 // by default it is i32 -> signed 32 bit integer let b: i64 = 23421234253646 // now this is a i64 let c: u64 = 2342564 // if we now that the values will not be negative we just use an unsigned integer let d = 4.3 // float -> f32 let e: f64 = 4.3 // float -> f64 let ver: bo...
true
16ef7eca8a5f9874552d695225a9a599643d801f
Rust
PragyaTripathi/p2p3
/src/async_queue.rs
UTF-8
1,848
3.21875
3
[]
no_license
#![allow(dead_code)] use std::sync::{Condvar, Mutex}; use std::collections::VecDeque; pub struct AsyncQueue<T>{ pub queue: Mutex<VecDeque<T>>, condvar: Condvar, } impl<T> AsyncQueue<T>{ pub fn new() -> AsyncQueue<T>{ AsyncQueue::<T>{ queue: Mutex::new(VecDeque::new()), cond...
true
e1aa25c1c7ac87b09bdb8f1c89e139364f6e04ca
Rust
j6k1/simplenn
/src/function/activation.rs
UTF-8
5,752
2.625
3
[ "MIT" ]
permissive
use types::*; use std::marker::PhantomData; pub trait ActivateF<T>: AsActivateF<FxS8> + AsActivateF<FxS16> + Send + Sync + 'static where T: UnitValue<T> { fn apply(&self,u:T,v:&[T]) -> T; fn derive(&self,e:T) -> T; fn kind(&self) -> &str; } pub trait AsActivateF<T>: Send + Sync + 'static where T: Send...
true
81468edc21cb7daf5c9537f31069236982380573
Rust
mdcg/a-tour-of-rust
/5-propriedade-e-emprestimo-de-dados/6-emprestando-propriedade-com-referencias.rs
UTF-8
335
3.859375
4
[ "MIT" ]
permissive
// As referências nos permitem emprestar o acesso a um recurso com o operador &. // As referências também são descartadas do mesmo jeito que outros recursos. struct Foo { x: i32, } fn main() { let foo = Foo { x: 42 }; let f = &foo; println!("{}", f.x); // f é descartado aqui // foo é descarta...
true
7fb6a166101cf20bcc3438e55a95c0e897204dfa
Rust
K2Da/hrkk
/src/service/es/domain.rs
UTF-8
3,486
2.515625
3
[]
no_license
use crate::service::prelude::*; #[derive(Serialize)] pub(crate) struct Resource { info: Info, } pub(crate) fn new() -> Resource { Resource { info: Info { sub_command: Some(SubCommand::Es { command: Es::Domain }), key_attribute: Some("domain_name"), service_name: "es...
true
05122395ad84a5314f12d466388ddfe68b8af40f
Rust
jz4o/codingames
/rust/practice/classic_puzzle/easy/benfords-law.rs
UTF-8
1,815
3.203125
3
[]
no_license
use std::io; extern crate regex; use regex::Regex; macro_rules! parse_input { ($x:expr, $t:ident) => ($x.trim().parse::<$t>().unwrap()) } /** * Auto-generated code below aims at helping you parse * the standard input according to the problem statement. **/ fn main() { let mut input_line = String::new(); ...
true
3656d821b79211bea86e5f68123a6c660e9fc49d
Rust
SpecificProtagonist/cary
/src/lib.rs
UTF-8
26,935
2.546875
3
[]
no_license
mod textures; mod math; mod components; mod renderer; mod level; use std::collections::HashMap; use winit::{ event::{Event, WindowEvent, VirtualKeyCode, }, event_loop::{ControlFlow, EventLoop}, }; #[cfg(target_arch="wasm32")] use wasm_bindgen::prelude::wasm_bindgen; use hecs::Entity; use math::*; use component...
true
1070adc405b0deacd7c4234b428914846667540e
Rust
dobkeratops/thRustEngine
/array.rs
UTF-8
10,957
3.078125
3
[]
no_license
/* #![feature(collections_range)] #![feature(drain_filter)] #![feature(slice_rsplit)] #![feature(slice_get_slice)] #![feature(vec_resize_default)] #![feature(vec_remove_item)] #![feature(collections_range)] #![feature(slice_rotate)] #![feature(swap_with_slice)] */ foo bar baz use collections::range::RangeArgument; us...
true
683ee71af54b1ec68efcc65091665d22d6f363f8
Rust
kritzcreek/wallocate
/src/lib.rs
UTF-8
2,816
2.84375
3
[]
no_license
#![no_std] use core::arch::wasm32::unreachable; use core::mem; use core::panic::PanicInfo; use core::ptr; #[panic_handler] fn panic(_info: &PanicInfo) -> ! { unsafe { unreachable() } } #[repr(C)] pub struct BlockHeader { pub size: usize, // TODO: Move this information into the free space for unallocated b...
true
4dae89e637f68dd3101d694b94f95e5e62ed0c80
Rust
Turakar/osmgraphing
/src/parsing/pbf.rs
UTF-8
2,908
2.71875
3
[ "Apache-2.0" ]
permissive
use std::fs::File; use log::info; use crate::network::{geo, GraphBuilder, StreetType}; mod pbf { pub use osmpbfreader::reader::OsmPbfReader as Reader; pub use osmpbfreader::OsmObj; } //------------------------------------------------------------------------------------------------// pub struct Parser; impl...
true
9fed49f985e7f84a03f3b48fbc69de4ed6fb4062
Rust
pola-rs/polars
/crates/polars-plan/src/logical_plan/aexpr/hash.rs
UTF-8
785
2.828125
3
[ "MIT" ]
permissive
use std::hash::{Hash, Hasher}; use crate::prelude::AExpr; impl Hash for AExpr { // This hashes the variant, not the whole expression fn hash<H: Hasher>(&self, state: &mut H) { std::mem::discriminant(self).hash(state); match self { AExpr::Column(name) => name.hash(state), ...
true
04b3afc72f26cfd757ee33c5f55fde3037399a08
Rust
weirane/gadgets
/rust/read-utf8/src/main.rs
UTF-8
1,082
2.96875
3
[ "WTFPL" ]
permissive
use std::fs::File; use std::io::{self, Read, Seek, SeekFrom}; use std::{env, str}; const BUF_SIZE: usize = 1024; fn main() -> io::Result<()> { let path = env::args().nth(1).expect("argv[1] is the file to read"); let mut file = File::open(path)?; let mut buf = [0u8; BUF_SIZE]; loop { match fil...
true
e5672447ac9d4b8e4c9b925b95207e63b74c91a5
Rust
vegaluisjose/edifier
/tests/unit_tests.rs
UTF-8
5,564
3.0625
3
[ "MIT" ]
permissive
/* MIT License Copyright (c) 2021 Pedro M. Torruella N. */ //use std::process::Command; //use Edif; use edifier::ast::*; /* #[test] fn runs_without_arguments() { let mut cmd = Command::cargo_bin("ls").unwrap(); cmd.assert().success(); }*/ fn match_check(incoming: String) -> i32{ let mut counter: i32 = ...
true
760c06527663d594fb77c0d6a7a88edca90fc89e
Rust
superphunthyme/raytracer
/src/image_out.rs
UTF-8
1,402
3.265625
3
[ "Zlib" ]
permissive
use std::io::{stdout, Write}; use std::path::Path; extern crate image; pub fn write_image(output_path: Option<&str>, image: &Vec<u8>, imgx: u32, imgy: u32) { match output_path { Some(x) => { let output_image: image::ImageBuffer<image::Rgb<u8>, Vec<u8>> = create_image(image, im...
true
8921f9b3cdaab44c4276e46a4a0d33eab72b21f7
Rust
Ynstc/vertigo
/crates/vertigo/src/computed/value.rs
UTF-8
2,983
2.828125
3
[]
no_license
use std::rc::Rc; use std::cmp::PartialEq; use std::any::Any; use crate::computed::{ Dependencies, Computed, GraphId, }; use crate::utils::BoxRefCell; struct ValueInner<T: PartialEq + 'static> { id: GraphId, value: Rc<T>, deps: Dependencies, } impl<T: PartialEq + 'static> ValueInner<T> { f...
true
54c6506a188935556f8157cc7f65a190615380c9
Rust
vtsingaras/visafe
/src/main.rs
UTF-8
4,283
3.203125
3
[]
no_license
extern crate argparse; use argparse::ArgumentParser; use std::process::{Command, Stdio}; use std::{fs, io}; use std::io::Write; use std::path::{Path, PathBuf}; struct Options { editor: String, checker: String, filename: String, exit_success: i32, } impl Default for Options { fn default() -> Opti...
true
3e87b6d582bc11ff9e8ea44e50d5270d3444d329
Rust
acvcmaster/RSMISC
/rsmisc.rs
UTF-8
13,573
3.21875
3
[]
no_license
use std::fmt::Display; use arithmetic_operation::ArithmeticOperation; use instruction::Instruction; use operand::Operand; pub mod arithmetic_operation; pub mod instruction; pub mod operand; #[derive(Debug, Clone)] pub struct Rsmisc { memory: [u8; 0xffff], // 64 KiB ip: u16, registers: [u16; 0x4], // R1, ...
true
2302afe6a0209618446b0fd9f4610222abadfc16
Rust
jos61404/ffm
/src/filter.rs
UTF-8
3,962
2.765625
3
[ "MIT" ]
permissive
use crate::file::{isolation_extension, isolation_name}; use console::style; use indicatif::ProgressBar; use std::convert::TryInto; use std::path::*; #[derive(Debug)] pub struct FilterDataStruct { pub path: PathBuf, pub dir_name: String, pub file_name: String, } // 過濾名稱 pub fn name( pb_filter_name: Pro...
true
88aa2c18608997c161abe48d37bdf98ca3051f9b
Rust
irwineffect/mcp795xx-rs
/src/registers.rs
UTF-8
5,399
3.015625
3
[ "MIT" ]
permissive
#![allow(unused)] extern crate bitfield; use bitfield::{bitfield}; use core::convert::TryInto; // base year, change to 2100 when needed const BASE_YEAR: u16 = 2000; bitfield! { pub struct RTCHSEC(u8); impl Debug; ///bit 7-4 HSECTEN<3:0>: Binary-Coded Decimal Value of Hundredth of Second’s Tens Digit ///Con...
true
e81548b3d2d3e322a328358dc65b2d1e98db8e55
Rust
awesome-archive/pcap2socks
/src/packet/layer/udp.rs
UTF-8
4,285
3.046875
3
[ "MIT" ]
permissive
use super::ipv4::Ipv4; use super::{Layer, LayerType, LayerTypes}; use pnet::packet::udp::{self, MutableUdpPacket, UdpPacket}; use std::clone::Clone; use std::fmt::{self, Display, Formatter}; use std::io; use std::net::Ipv4Addr; /// Represents an UDP packet. #[derive(Clone, Debug)] pub struct Udp { pub layer: udp::...
true
72eabb266abf310c77e7e0bd911efbff46c533f0
Rust
comet-flare/bevy_tilemap
/src/chunk/mod.rs
UTF-8
11,217
3.671875
4
[ "MIT" ]
permissive
//! Tiles organised into chunks for efficiency and performance. //! //! Mostly everything in this module is private API and not intended to be used //! outside of this crate as a lot goes on under the hood that can cause issues. //! With that being said, everything that can be used with helping a chunk get //! created ...
true
a461d0d38da84441da2055d7b61c7b694073fd4a
Rust
Ace314159/GBC-Emulator
/src/gbc/io/apu/timer.rs
UTF-8
475
3.28125
3
[]
no_license
pub struct Timer { counter: u16, } impl Timer { pub fn new(reload: u16) -> Self { Timer { counter: reload, } } pub fn clock(&mut self, reload: u16) -> bool { self.counter = self.counter.wrapping_sub(1); if self.counter == 0 { self.counter = reloa...
true
6e99fcaf2deeb972f4228e4918e98a46a1f96078
Rust
TAKEDA-Takashi/rust-project-euler
/project-euler/src/bin/problem-104.rs
UTF-8
957
3.140625
3
[]
no_license
//! http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%20104 //! //! フィボナッチ数列は再帰的な関係によって定義される: //! //! Fn = Fn-1 + Fn-2 //! F541 (113桁)は, 下9桁に1から9までの数字をすべて含む初めてのフィボナッチ数である. そして, F2749 (575桁)は, 頭から9桁に1から9までの数字をすべて含む初めてのフィボナッチ数である. //! //! Fkが, 頭から9桁と下9桁のどちらも1から9までの数字をすべて含む初めてのフィボナッチ数とするとき, kを求めよ. use ...
true
6734d448379b15b817b60da0db79120381dd06b4
Rust
marcelbuesing/canutils-rs
/src/bin/candumprb.rs
UTF-8
5,889
2.53125
3
[]
no_license
use ansi_term::Color::{self, Cyan, Fixed, Green, Purple}; use anyhow::Result; use can_dbc::{ByteOrder, Signal}; use futures::StreamExt; use socketcan::CANFrame; use std::collections::HashMap; use std::convert::TryInto; use std::fmt::Write; use std::path::PathBuf; use structopt::StructOpt; use tokio::fs::File; use tokio...
true
4ca23395a686feaeed64bb816a407cddc2e6ce91
Rust
jaynus/game-metrics
/src/logging.rs
UTF-8
6,233
2.515625
3
[ "MIT" ]
permissive
#![allow(unused_variables, dead_code)] #[cfg(feature = "threads")] use crossbeam_channel::{Receiver, Sender}; #[cfg(feature = "threads")] use parking_lot::Mutex; #[cfg(feature = "threads")] use std::{ sync::{ atomic::{AtomicBool, Ordering}, Arc, }, thread::JoinHandle, }; #[cfg(not(feature = ...
true
0fece22ca18110410a1089cd7c064d60e8b3ba55
Rust
Veetaha/db-labs
/term3_1/lab2/src/models/traits/get_by_id.rs
UTF-8
611
2.578125
3
[ "MIT" ]
permissive
use anyhow::{Result, Context}; use super::{GetTableName, GetPgClient, EntityService}; pub trait GetById: EntityService { fn get_by_id(&self, id: i32) -> Result<Self::Entity>; } impl<T: EntityService> GetById for T where Self: GetTableName + GetPgClient { fn get_by_id(&self, id: i32) -> Result<Self::Enti...
true
dab60e4995d4738a9f56941ccc6af293e49c5364
Rust
Busy-Bob/rust_leetcode
/code_0381/src/lib.rs
UTF-8
1,688
3.46875
3
[]
no_license
use std::collections::{HashMap, HashSet}; use rand::seq::SliceRandom; #[derive(Default,Debug)] struct RandomizedCollection { vec: Vec<i32>, idx: HashMap<i32, HashSet<usize>>, } /** * `&self` means the method takes an immutable reference. * If you need a mutable reference, change it to `&mut self` instead. ...
true
55876446bf8aea324cd36331baf317383ee7dd0f
Rust
togglebyte/netlark
/client/src/account.rs
UTF-8
6,310
2.78125
3
[ "MIT" ]
permissive
use common::models::{Auth, Message}; use common::Tx; use legion::{system, Resources, Schedule}; use tinybit::events::{Event, KeyCode, KeyEvent}; use tinybit::widgets::{Border, Text}; use tinybit::{term_size, Color, ScreenPos, ScreenSize, Viewport}; use crate::state::{State, Transition}; use crate::ui::TextField; use c...
true
48cf6dc1d6d8b32b652e071242e9a5bac315db18
Rust
infinityb/surface
/src/unified/yuv422.rs
UTF-8
5,961
2.9375
3
[]
no_license
use std::ops::{Deref, DerefMut}; use super::{Format, PlanarFormat}; use super::super::Channel; use super::super::colorspace::ColorYUV as ColorYuv; /// Packed YUV 4:2:2 #[derive(Clone)] pub struct Yuv422; #[inline] fn get_yuv422_yuv<C>(data: &[C], (w, h): (u32, u32), (x, y): (u32, u32)) -> (&C, &C, &C) { assert!...
true
2244dbd1a1714f7875f9a0f2f2df118986155712
Rust
jcoglan/xdelta
/src/encoding/tests.rs
UTF-8
1,525
2.875
3
[ "Apache-2.0" ]
permissive
#![cfg(test)] use super::{copy, varint}; macro_rules! encode { ($mod:ident, ($( $value:expr ),+), [$( $byte:expr ),+]) => { assert_eq!($mod::encode($( $value ),+), vec![$( $byte ),+]); }; ($mod:ident, $value:expr, [$( $byte:expr ),+]) => { assert_eq!($mod::encode($value), vec![$( $byte ),+...
true
55068d0566ca1e540a9073de8a2f8d83322cbe1c
Rust
sitegui/cubique
/src/heuristic_cache.rs
UTF-8
1,269
3.21875
3
[ "MIT" ]
permissive
use crate::plan::Plan; use crate::State; use std::collections::HashMap; pub struct HeuristicCache<S> { cache: HashMap<State, f64>, solver: S, } impl<S: FnMut(State) -> Plan> HeuristicCache<S> { pub fn new(solver: S) -> Self { HeuristicCache { cache: Default::default(), solv...
true
c7843e60c0a71e2fa9f037e7d8a02b13548c542d
Rust
czyczk/LeetCode
/rust/lc-482/src/solution.rs
UTF-8
736
2.796875
3
[]
no_license
pub struct Solution {} impl Solution { pub fn license_key_formatting(s: String, k: i32) -> String { let mut ret_bytes = std::collections::VecDeque::new(); let n = s.len(); let s = s.as_bytes(); let mut count = 0; let mut is_first = true; for i in (0..n).rev() { ...
true
205b208f0be68293f5e3e65c739ceb8631970ca4
Rust
muntasirraihan/rust-algs4
/src/sorting/heapsort.rs
UTF-8
723
3.28125
3
[ "MIT" ]
permissive
// 1-based index to 0-based #[inline] fn less<T: PartialOrd>(a: &mut [T], i: usize, j: usize) -> bool { a[i-1] < a[j-1] } #[inline] fn sink<T: PartialOrd>(a: &mut [T], k: usize, n: usize) { let mut k = k; while 2*k <= n { let mut j = 2*k; if j < n && less(a, j, j+1) { j += 1; ...
true
ff06d0adb6cd4878db9c3dd3238679fda98b559e
Rust
yspace/begin_rust
/src/examples/hello_world.rs
UTF-8
8,941
4.03125
4
[ "MIT" ]
permissive
use std::fmt; use std::fmt::{Error, Formatter, Display}; pub fn Comments() { // This is an example of a line comment // There are two slashes at the beginning of the line // And nothing written inside these will be read by the compiler // println!("Hello, world!"); // Run it. See? Now try deletin...
true
10eeb8033f0cb5e396788a50bdd1920def08c7bb
Rust
Robinbux/rust-server
/src/controller/home_controller.rs
UTF-8
1,666
2.921875
3
[]
no_license
use crate::controller::base_controller::BaseController; use crate::controller::controller::Controller; use crate::enums::content_type::ContentType; use crate::enums::http_status_codes::HTTPStatusCodes; use crate::http::request::Request; use crate::http::response::Response; use crate::services::error_service::ErrorServi...
true
f9c0c63140dda5dbc6fbcf84e890f2e54423cfc7
Rust
nanpuyue/stratum
/src/util/sinkhook.rs
UTF-8
1,087
2.75
3
[]
no_license
use futures::{Poll, Sink, StartSend}; #[derive(Clone, Debug)] #[must_use = "sinks do nothing unless polled"] pub struct SinkHook<S, F> { sink: S, hook: F, started: Option<()>, } impl<S: Sink, F: Fn()> SinkHook<S, F> { pub fn new(sink: S, hook: F) -> Self { Self { sink, ...
true
77deb45ed9981a8655aad122a141c2e0b8e5f51b
Rust
coreylowman/projectEuler
/src/problems/problem004.rs
UTF-8
668
3.28125
3
[]
no_license
fn is_palindrome(mut n: u64) -> bool { let mut digits: Vec<i8> = Vec::new(); while n > 0 { digits.push((n % 10) as i8); n = (n / 10) as u64; } let length = digits.len(); let mut i = 0; let mut j = length - 1; while i <= j { if digits[i] != digits[j] { ret...
true
bf019d4531751754c2e68bb984bf63557fbd9a54
Rust
CBenoit/nushell
/crates/nu-command/src/database/expressions/over.rs
UTF-8
4,920
2.59375
3
[ "MIT" ]
permissive
use crate::database::values::dsl::ExprDb; use nu_engine::CallExt; use nu_protocol::{ ast::Call, engine::{Command, EngineState, Stack}, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, }; use sqlparser::ast::{Expr, WindowSpec}; #[derive(Clone)] pu...
true
0ae1d6681305fae99c2f206ec2d73d45f672c672
Rust
jTitor/leek2
/src/open-source/engine/modules/src/logging/log_listener/interface.rs
UTF-8
2,444
3.140625
3
[]
no_license
/*! Interface for things that display/respond to log entries. */ extern crate log; use std::cell::RefCell; use std::fmt; use std::io::Write; use std::sync::RwLock; use super::listener_error::ListenerError; use logging::{LogSeverity, LogElement}; /** Base class for log listeners. Has a connection to some output strea...
true
a3a2ddafb1659c04e96953f5259a4b9c093a9807
Rust
RichCzyzewski/rust_cribbage_core
/src/game/cards.rs
UTF-8
3,939
3.34375
3
[]
no_license
#![allow(dead_code)] use serde::{Deserialize, Serialize}; use serde_json::Result; use std::fmt; use strum::AsStaticRef; use strum::IntoEnumIterator; use strum_macros::AsStaticStr; use strum_macros::EnumIter; use strum_macros::EnumString; // // this module has the core abstraction of a card - ordinal, rank, suit, etc...
true
3589524b4ea5fdc2241acefce71dc91297f08a70
Rust
fuchsnj/validate
/src/rule.rs
UTF-8
1,697
3.109375
3
[]
no_license
use std::ops::Add; #[derive(Debug, PartialEq)] pub struct Error { message: String } impl Error { pub fn get_message(&self) -> String { self.message.clone() } } impl<S: Into<String>> From<S> for Error { fn from(msg: S) -> Self { Error { message: msg.into() } } } pub type ValidationResult = Result<(), Error...
true
f61efa095228dffdd715ca639e4050458aa8deff
Rust
eagletmt/misc
/rust/grpc-sample/src/bin/greeter_server.rs
UTF-8
1,779
2.65625
3
[ "CC0-1.0" ]
permissive
#[derive(Default)] struct MyGreeter {} #[tonic::async_trait] impl grpc_sample::hello::greeter_server::Greeter for MyGreeter { async fn say_hello( &self, request: tonic::Request<grpc_sample::hello::HelloRequest>, ) -> Result<tonic::Response<grpc_sample::hello::HelloReply>, tonic::Status> { ...
true
d29b5fe5bf59b9ce5e4a1e311c1b4e3f8851dd65
Rust
brooks-builds/cannon_game_rust
/src/target.rs
UTF-8
1,471
2.96875
3
[ "MIT" ]
permissive
use bbggez::{ color::random_dark_color, ggez::{ graphics::{Color, Mesh}, nalgebra::{Point2, Vector2}, Context, GameResult, }, mesh::create_rect, }; pub struct Target { location: Vector2<f32>, width: f32, height: f32, color: Color, speed: Vector2<f32>, } impl...
true
3429e3c56f11b8e7322a217da6c4d4dc3214cc4c
Rust
EFanZh/LeetCode
/src/problem_0412_fizz_buzz/iterative.rs
UTF-8
1,023
3.125
3
[]
no_license
pub struct Solution; // ------------------------------------------------------ snip ------------------------------------------------------ // impl Solution { pub fn fizz_buzz(n: i32) -> Vec<String> { (1..=n) .map(|i| { if i % 3 == 0 { if i % 5 == 0 { ...
true
c5721f09cb7f2abce1c124ca42b64f6a3c176edb
Rust
ByteHeathen/libsdp
/src/attributes/ty.rs
UTF-8
1,128
2.828125
3
[ "MIT" ]
permissive
use std::fmt; use nom::{ IResult, branch::alt, combinator::map, bytes::complete::tag_no_case }; #[derive(Debug, PartialEq, Clone)] pub enum SdpAttributeType { Rtpmap, RecvOnly, SendOnly, SendRecv, Fmtp } impl fmt::Display for SdpAttributeType { fn fmt(&self, f: &mut fmt::Forma...
true
20431f4e6fb954c8318ef3f83186b89f1bdffc19
Rust
tech6hutch/aoc2020-rust
/src/day3.rs
UTF-8
3,142
3.421875
3
[]
no_license
use std::{iter::FromIterator, convert::{TryFrom, TryInto}, ops::Index, str::FromStr}; use anyhow::{Context, Error, Result}; use itertools::Itertools; use crate::util::*; pub(crate) fn day3() { let map: Map = get_input("day3").parse().unwrap(); part1(&map); part2(&map); } fn part1(map: &Map) { let tree...
true
8a192fc14104b37ff21553130fb8dc25b688748f
Rust
mbelle-blackboard/futures-async-stream
/src/lib.rs
UTF-8
15,427
3.828125
4
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Async stream API experiment that may be introduced as a language feature in the future. //! //! This crate provides useful features for streams, using `async_await` and //! unstable [`generators`](https://github.com/rust-lang/rust/issues/43122). //! //! # `#[for_await]` //! //! Processes streams using a for loop. /...
true
e8cb4e0bdfa972157fe92be5c993d47622e676ea
Rust
PartyLich/advent_2018
/advent_2018/src/lib.rs
UTF-8
4,215
3.078125
3
[]
no_license
#![deny(missing_debug_implementations)] #![deny(missing_docs)] //! Advent of Code 2018 Solutions use std::{fmt, fs, ops::RangeInclusive, path::Path}; use parser::three::lib::{any_of, choice, keep_first, p_char, p_int, spaces}; pub mod day_07; /// read the specified file at `file_path` into a `String` /// /// Panic! ...
true
aa1295dca9c808702e3c547f2ccfe449d4f6dc1f
Rust
gbrls/rust-microc
/src/ast.rs
UTF-8
1,747
3.5
4
[]
no_license
#[derive(Debug, Clone)] pub enum AST { Number(i32), Bool(bool), Add(Box<AST>, Box<AST>), Sub(Box<AST>, Box<AST>), Mul(Box<AST>, Box<AST>), Div(Box<AST>, Box<AST>), Lesser(Box<AST>, Box<AST>), BoolAnd(Box<AST>, Box<AST>), BoolOr(Box<AST>, Box<AST>), AssignVar(String, Box<AST>...
true
81939b98c83f821ef029e501fb1960b34784f871
Rust
gaultier/kotlin-rs
/src/jvm_stack_map_frame.rs
UTF-8
2,059
2.75
3
[]
no_license
use crate::parse::Type; #[cfg(feature = "jvm_stack_map_frames")] use log::debug; #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub(crate) enum VerificationTypeInfo { Int, Object(u16), } #[derive(Debug, Clone, PartialEq, Eq)] pub(crate) enum StackMapFrame { Same { offset: u8, }, SameLocalsOn...
true
622795b642b8f6bc2049025e800395e0825f5221
Rust
clucompany/cluStrConcat
/src/macros/str_concat.rs
UTF-8
1,214
3.265625
3
[ "Apache-2.0" ]
permissive
extern crate cluConstData; /// A more advanced version of the concat macro from std, supports constants. ///``` ///const A: &'static str = "123"; ///const B: &'static str = "456"; ///const C: &'static str = "789"; /// ///let str = cluStrConcat::str_concat!(A, B, C, "."); ///assert_eq!(str, "123456789."); ///``` #[mac...
true
99cb48eabc23805e92739a753bb3b9399eb08575
Rust
mikispag/bitiodine
/src/transactions.rs
UTF-8
7,118
2.5625
3
[ "MIT" ]
permissive
use crypto::digest::Digest; use crypto::sha2::Sha256; use preamble::*; #[derive(PartialEq, Eq, Debug, Clone, Copy)] pub struct Transactions<'a> { pub count: u64, pub slice: &'a [u8], } #[derive(PartialEq, Eq, Debug, Clone, Copy)] pub struct Transaction<'a> { pub version: u32, pub txid: Hash, pub t...
true
492d7c547fec6389cf10352b3c62714f48fbddd2
Rust
Peter-L-SVK/Examples-Rust
/factorial.rs
UTF-8
889
3.265625
3
[]
no_license
use std::io; fn main() { println!("Faktorial cisla.\n"); println!("Zadaj cele kladne cislo do 20: "); let mut hodnota = String::new(); let mut pomocna: u64 = 1; io::stdin().read_line(&mut hodnota) .expect("Failed to read line"); let hodnota: u64 = match hodnota.trim().parse() { ...
true
aae0bb32c7d0d6ee9d0423bb916fc003942ce012
Rust
sogapalag/contest
/aizu/1604.rs
UTF-8
3,205
3
3
[]
no_license
#[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; use std::io::Read; #[allow(dead_code)] fn getline() -> String { let mut ret = String::new(); std::io::stdin().read_line(&mut ret).ok().unwrap(); ret } fn get_word() -> String { let mut stdin = std::io::stdin(); ...
true
e70303b57d4ff24e39e009d64f2e4b627e8c0e90
Rust
ifyouseewendy/exercisms
/rust/pascals-triangle/src/lib.rs
UTF-8
610
3.234375
3
[]
no_license
pub struct PascalsTriangle(u32); impl PascalsTriangle { pub fn new(row_count: u32) -> Self { Self(row_count) } pub fn rows(&self) -> Vec<Vec<u32>> { let mut v: Vec<Vec<u32>> = vec![]; for i in 0..self.0 { let mut row = vec![]; if i == 0 { r...
true
dcf8d813b0f0a1ebd6c71b6d2ebf1e64cc4e4381
Rust
tgfukuda/rust_tutorials
/advanced_feature/src/rust_macro.rs
UTF-8
1,172
3.34375
3
[]
no_license
pub fn macro_demo() { //macro doc https://veykril.github.io/tlborm/ declaretive(); procedual(); } //declaretive macro // macro definition is like match statement // but it tests the Rust code structure // valid macro syntax is https://doc.rust-lang.org/reference/macros-by-example.html #[macro_export] ma...
true
8e6dfc7e32ff4f4d6f0c44c4fbed6664171398b8
Rust
yzarubin/comp
/lib/rust/stats.rs
UTF-8
782
3.1875
3
[]
no_license
fn fact(n: i32) -> i32 { if (n == 0 || n == 1) {return 1} else {return n * fact(n-1)} } fn poisson_dist(lambda: f64, k: i32) -> f64 { return lambda.powi(k) * std::f64::consts::E.powf(-lambda) / fact(k) as f64; } fn cov(X: &Vec<f64>, Y: &Vec<f64>) -> f64 { let mut ans = 0.0; let uX = mean(&X); let uY...
true
7241e8c1c4aab4bd9210f151a890588f44f7d2d4
Rust
mkiael/iexc-rs
/src/lib.rs
UTF-8
840
2.9375
3
[ "MIT" ]
permissive
mod http; use std::error; type Result<T> = std::result::Result<T, Box<dyn error::Error>>; pub enum Endpoint { Production, Sandbox, } pub struct Client { http_client: http::Client, api_token: String, } impl Client { pub fn new(endpoint: Endpoint, api_token: String) -> Self { let domain =...
true
d9edea013e5fb2d97d0f1ee636af3d57821d41a4
Rust
luojia65/laji-protocols
/examples/discard-client-test.rs
UTF-8
521
2.890625
3
[]
no_license
use std::{thread, net::*}; fn main() { for i in 0..10000 { let addr = match i % 3 { 0 => "127.0.0.1:9", 1 => "127.0.0.1:999", 2 => "127.0.0.1:9999", _ => unreachable!(), }; thread::spawn(move || { // thread::sleep(std::time::Durati...
true
6a44f916dcde6817c3bf8410bb90ecba37e1221a
Rust
adowsky/rocket-microservice-template
/src/infrastructure/health.rs
UTF-8
1,000
3
3
[]
no_license
use std::sync::{Arc, Mutex}; use strum::IntoStaticStr; #[derive(Debug, Clone, Copy)] pub(crate) struct HealthStatus { pub(crate) health: Health, } #[derive(Debug, Clone, Copy, IntoStaticStr)] pub(crate) enum Health { STARTING_UP, HEALTHY, } pub(crate) trait HealthChecker { fn perform_heath_check(&self...
true
0b11329618ad66fb1b6464f540ec8514f2d55516
Rust
nickray/nrf5340-pac
/nrf5340-app-pac/src/clock_ns/hfclkaudiostat.rs
UTF-8
2,768
2.515625
3
[ "0BSD" ]
permissive
#[doc = "Reader of register HFCLKAUDIOSTAT"] pub type R = crate::R<u32, super::HFCLKAUDIOSTAT>; #[doc = "ALWAYSRUN activated\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq)] pub enum ALWAYSRUNNING_A { #[doc = "0: Automatic clock control enabled"] NOTRUNNING, #[doc = "1: Oscillator is always r...
true
01034d99a24b3b0d4ee117bea8f27c5303708572
Rust
PSeitz/lz4_flex
/src/lib.rs
UTF-8
4,069
2.828125
3
[ "MIT" ]
permissive
//! Pure Rust, high performance implementation of LZ4 compression. //! //! A detailed explanation of the algorithm can be found [here](http://ticki.github.io/blog/how-lz4-works/). //! //! # Overview //! //! This crate provides two ways to use lz4. The first way is through the //! [`frame::FrameDecoder`](frame/struct.Fr...
true
5b5a708271af05eb2502494ff4bcc449e32d1d69
Rust
hoodie/icalendar-rs
/examples/alarm.rs
UTF-8
2,333
2.734375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use chrono::*; use icalendar::*; fn main() { let mut calendar = Calendar::new(); let now = Utc::now(); let soon = Utc::now() + Duration::minutes(12); let tomorrow = Utc::now() + Duration::days(1); let todo_test_audio = Todo::new() .summary("TODO with audio alarm -15min") .sequence...
true
f87053ea3cde74d4058541e203a8253cbb5b7d06
Rust
lidavidm/rehack
/src/info_view.rs
UTF-8
4,590
3.109375
3
[]
no_license
use voodoo::color::ColorValue; use voodoo::window::{FormattedString, Point, Window}; use program::{Ability, Program, Team}; pub struct ChoiceList<T> { y: u16, list: Vec<(String, T)>, selected: Option<u16>, } impl<T> ChoiceList<T> { pub fn new(y: u16) -> ChoiceList<T> { ChoiceList { ...
true
7645854fe1a15bb424b70e9c40237cb5c91b9989
Rust
gwy15/leetcode
/src/914.卡牌分组.rs
UTF-8
1,774
3.296875
3
[]
no_license
/* * @lc app=leetcode.cn id=914 lang=rust * * [914] 卡牌分组 */ struct Solution; // @lc code=start impl Solution { fn gcd(mut a: i32, mut b: i32) -> i32 { while a != 0 { // (a, b) => (b % a, a) let tmp = b % a; b = a; a = tmp; } b } p...
true
bc3941b93a6ec13c2c6601e8533f9aa326f721e0
Rust
gahag/MayaStor
/mayastor/src/bdev/nexus/nexus_label.rs
UTF-8
12,129
2.828125
3
[ "Apache-2.0" ]
permissive
//! GPT labeling for Nexus devices. The primary partition //! (/dev/x1) will be used for meta data during, rebuild. The second //! partition contains the file system. //! //! The nexus will adjust internal data structures to offset the IO to the //! right partition. put differently, when connecting to this device via /...
true
3cd1f89639b22e71f583c4053228c7750dce5f76
Rust
leviathanbeak/blockchain_sample
/blockchain/src/block.rs
UTF-8
891
2.71875
3
[]
no_license
use std::time::SystemTime; use serde::{Deserialize, Serialize}; use crate::transaction::Transaction; pub type BlockNumber = u64; pub type NonceNumber = u64; pub type Hash = String; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Block { pub index: BlockNumber, pub timestamp: SystemTime, pub t...
true
62cc10923aefad6d764ad99e03369856a4d9b4be
Rust
cedrickchee/bitcask
/rust/building-blocks/bb-1-exercise/src/main.rs
UTF-8
1,688
3.328125
3
[ "MIT", "CC-BY-4.0" ]
permissive
// This example demonstrates clap's building from YAML style of creating arguments which is far // more clean, but takes a very small performance hit compared to the other two methods. // // How to test in terminal. Run these commands: // $ cargo run -- --help // $ cargo run -- myfile.txt use std::env; use std::fmt; u...
true
ecd1a84146cfa9a25213411adcdada6d395e5767
Rust
detro/srvzio
/src/manager.rs
UTF-8
4,576
3.78125
4
[ "BSD-3-Clause" ]
permissive
//! Where you have services, you need managers use crate::service::Service; use crate::utils; use log::*; /// Manages an internal collection of Services /// /// This implements a simple [Composite Pattern](https://en.wikipedia.org/wiki/Composite_pattern) /// that allows to manages a group of Service in a coordinated...
true
06bdc51de1ffc199c34ae28479900556d583d2b7
Rust
ZiyanWu93/chocolate_milk
/kernel/src/mm.rs
UTF-8
20,042
2.703125
3
[ "MIT" ]
permissive
//! The virtual and physical memory manager for the kernel use core::marker::PhantomData; use core::mem::size_of; use core::mem::MaybeUninit; use core::ops::{Deref, DerefMut}; use core::alloc::{Layout, GlobalAlloc}; use core::sync::atomic::{AtomicU64, AtomicPtr, Ordering}; use alloc::boxed::Box; use alloc::collections...
true
ecede38b54e077111d8d3a5b133ab70809fbdbf3
Rust
arjandepooter/advent-of-code-2020
/shared/src/iterators.rs
UTF-8
185
2.515625
3
[]
no_license
use std::str::Split; pub trait BlockSplit { fn blocks(&self) -> Split<&str>; } impl BlockSplit for &str { fn blocks(&self) -> Split<&str> { self.split("\n\n") } }
true
4ede00945c50d508dfa27f8ee96a1f592ffff4dc
Rust
erglabs/arti
/crates/tor-netdoc/src/parse.rs
UTF-8
1,764
3.109375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Parsing support for the network document meta-format //! //! The meta-format used by Tor network documents evolved over time //! from a legacy line-oriented format. It's described more fully //! in Tor's //! [dir-spec.txt](https://spec.torproject.org/dir-spec). //! //! In brief, a network document is a sequence of...
true
0388ff7d0afc29c0b4b2fbacd137fabebc76aaf9
Rust
sjoshid/exercism
/rust/pangram/src/lib.rs
UTF-8
397
3.5
4
[]
no_license
use std::collections::{HashSet, BTreeSet}; struct AsciiChars(String); //String::from("abcdefghijklmnopqrstuvwxyz"); /// Determine whether a sentence is a pangram. pub fn is_pangram(sentence: &str) -> bool { let letters: HashSet<_> = sentence .chars() .filter(char::is_ascii_alphabetic) .ma...
true
93e446643b35e4fcf55a6f42470687880eef503f
Rust
lord/markov
/src/main.rs
UTF-8
349
2.84375
3
[]
no_license
use std::io::prelude::*; use std::fs::File; fn get_corpus() -> String { let mut file = match File::open("./corpus.txt") { Ok(file) => file, Err(..) => panic!("can't open corpus file"), }; let mut contents = String::new(); file.read_to_string(&mut contents).unwrap(); contents } fn main() { pri...
true
64c39c9fc14b774e2fce8c7cf89c2165f7bd3f59
Rust
lalrpop/lalrpop
/lalrpop/src/parser/test.rs
UTF-8
5,649
3.328125
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::grammar::parse_tree::{GrammarItem, MatchItem}; use crate::parser; #[test] fn match_block() { let blocks = vec![ r#"grammar; match { _ }"#, // Minimal r#"grammar; match { _ } else { _ }"#, // Doesn't really make sense, but should be allowed r#"grammar; match { ...
true
add1b975d4e0e22a35930f882fde21bd65cffc90
Rust
dato/advent
/2015/src/day3.rs
UTF-8
957
3.171875
3
[]
no_license
// https://adventofcode.com/2015/day/3 use std::collections::HashMap; type Pos = (i32, i32); pub fn day3(filename: Option<&str>) -> (String, String) { let line = crate::readline(filename.unwrap_or("input/03")); // Part 1 let mut pos = (0, 0); let mut map = HashMap::new(); map.insert(pos, ()); ...
true
4af6609f834b5cc79fc40912d7124203f147a0ad
Rust
Nercury/little-rs
/src/error/build.rs
UTF-8
622
2.875
3
[]
no_license
use std::error; use std::fmt; /// Error while performing seek. #[derive(Debug)] pub enum BuildError { /// Out of bound operation on container. FunctionNotFound { required: String }, } impl fmt::Display for BuildError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { ...
true
d2f9f9a9d82bbca9a63d17c1cd335784a4d26579
Rust
ricmzn/rust-typescript-gen
/src/lib.rs
UTF-8
4,266
2.796875
3
[]
no_license
extern crate proc_macro; use std::io::Write; use std::fs::File; use proc_macro::TokenStream; use syn::PathArguments::AngleBracketed; use syn::Data::Struct; use syn::*; trait UnwrapOrErr<T> { fn unwrap_or_err(self) -> T; } impl<T1, T2, T> UnwrapOrErr<T> for std::result::Result<T1, T2> where T1: Into<T>, T...
true
62480e8a35147e2578e8db983c9212f65f55e620
Rust
librallu/dogs-color
/src/bin/cgshop_checker.rs
UTF-8
1,312
2.59375
3
[]
no_license
use std::rc::Rc; use clap::{App, load_yaml}; use dogs_color::{ cgshop::{CGSHOPInstance, CGSHOPSolution}, color::{ColoringInstance, checker, CheckerResult} }; /** solves a coloring instance using a DSATUR greedy */ pub fn main() { // parse arguments let yaml = load_yaml!("cgshop_checker.yml"); let...
true
7b44637485084948a707966cf14fdd4d8c2d6c5b
Rust
galacticfungus/Egg
/egg/src/storage/mod.rs
UTF-8
462
2.796875
3
[ "MIT", "Apache-2.0" ]
permissive
use std::path; // Contains types that persist user data data to disk, ie the files being placed in the repository pub(crate) mod local; // Reads and writes user data to the repository pub(crate) mod stream; // Provides extensions to Read Write traits to allow easier reading and writing a basic egg ...
true
5e2d64182acb09267147f8f24144e47c4a161979
Rust
joechrisellis/picky-rs
/picky-server/src/addressing.rs
UTF-8
2,442
3.125
3
[ "Apache-2.0", "MIT" ]
permissive
use multibase::Base; use multihash::{Code as Hash, Multihash}; pub const CANONICAL_HASH: Hash = Hash::Sha2_256; pub const CANONICAL_BASE: Base = Base::Base64Url; pub fn encode_to_canonical_address(data: &[u8]) -> String { let hash = CANONICAL_HASH.digest(data); multibase::encode(CANONICAL_BASE, hash.as_bytes(...
true
1b782b6771e98615ec7e1ef1e39ba9a697277b27
Rust
tejasag/hackchain-rs
/src/hash.rs
UTF-8
397
2.59375
3
[]
no_license
use super::crypto::{hmac::Hmac, mac::Mac, sha2::Sha256}; use crate::itertools::Itertools; const SALT: &[u8] = b"some"; pub fn hash(thing: String) -> String { let mut algo = Hmac::new(Sha256::new(), SALT); algo.input(thing.as_str().as_bytes()); algo.result() .code() .iter() .format...
true
70cfd21f23f506f3e96345998e3b0f3bbb2af94b
Rust
prakhar1989/exercism
/rust/matching-brackets/src/lib.rs
UTF-8
536
3.59375
4
[]
no_license
pub fn brackets_are_balanced(string: &str) -> bool { let mut stack: Vec<char> = Vec::new(); for c in string.chars() { match c { '[' | '{' | '(' => stack.push(c), ']' | '}' | ')' => { if !stack.pop().eq(&Some(matching(c))) { return false; ...
true
abe7198ec8a787b5bbd3d9342afc019108f24b88
Rust
Alaa5090/Rust_training
/primitive type copied.rs
UTF-8
137
3.140625
3
[]
no_license
fn main() { let a = [1,2,3]; let b = a; // copy of 'a' is created println!("a:{:?} , b:{:?}", a, b); // print 'a' and 'b' }
true
24d92e7ff6092de940a3bbbbc4e5940b1862953c
Rust
TangliziGit/leetcode
/rust/20.valid-parentheses.97901130.ac.rs
UTF-8
766
3.3125
3
[]
no_license
use std::collections::HashMap; impl Solution { pub fn is_valid(s: String) -> bool { let begins = ['(', '[', '{']; let map = { let mut map = HashMap::new(); map.insert('(', ')'); map.insert('[', ']'); map.insert('{', '}'); map }; ...
true
11b8fdda70abac710568f6b55a408093fab36831
Rust
luckychacha/async_demo
/examples/test.rs
UTF-8
1,992
3.265625
3
[]
no_license
extern crate redis; use redis::{Client, Commands, ControlFlow, PubSubCommands}; use std::sync::Arc; use std::thread; use std::time::Duration; // 创建一个应用程序 trait trait AppState { fn client(&self) -> &Arc<Client>; } // 创建一个上下文结构,用于保存异步的 redis 客户端实例 struct Ctx { pub client: Arc<Client>, } // 实现 new 方法返回一个上下文 im...
true
4c6259c0f8956ece164e2d40fdf9f8774fc8ad59
Rust
NangiDev/AdventOfCode2020
/tests/day08.rs
UTF-8
2,161
3.015625
3
[]
no_license
#[cfg(test)] mod day_8 { use adventofcode_2020::day08::{convert_exec, exec_1, exec_2}; use std::vec; #[test] fn convert_instructoins_to_list() { let instructions: Vec<String> = vec![ "nop +0".to_string(), "acc +1".to_string(), "jmp +4".to_string(), ...
true
0fefd7d9a2270341b615df795429fba3db8df457
Rust
dave-nachman/bytelang
/src/semantic_analysis.rs
UTF-8
5,192
3.21875
3
[]
no_license
use std::collections::HashMap; use ast::{Expr, Identifier}; #[derive(Debug, PartialEq, Clone)] pub enum Type { Let, Const, } #[derive(Debug, Default, Clone)] pub struct SymbolTable { table: HashMap<String, Type>, } impl SymbolTable { pub fn new() -> SymbolTable { SymbolTable::default() }...
true
4cc853e699338e6bb8289a01d00add3def8dbbbe
Rust
Kerollmops/reustmann
/examples/execute.rs
UTF-8
1,029
2.765625
3
[]
no_license
extern crate reustmann; extern crate bstr; use std::io::Write; use std::{fs, io}; use reustmann::instruction::op_codes; use reustmann::{Program, Interpreter, Statement}; const ARCH_LENGTH: usize = 100; // memory length const ARCH_WIDTH: usize = 8; // word size const CYCLE_LIMIT: usize = 200; fn main() { let fil...
true
4cb6f2c5fa092a8ee405342a5cd372c8bc3d8a2b
Rust
MatrixWeb/rust-learning
/3-1/exercise-data-type/src/main.rs
UTF-8
2,715
3.953125
4
[]
no_license
#[derive(PartialEq, Debug)] // Declare Car struct to describe vehicle with four named fields struct Car { color: String, motor: Transmission, roof: bool, age: (Age, u32), // todo!("Move `mileage: u32` field into `age` field - a tuple with two fields: an `Age` enum, u32"); } #[derive(PartialEq, Debug)] ...
true
1ea1009ab7d706e2551f0e17849413e61aa41164
Rust
Drops-of-Diamond/diamond_drops
/env/src/config.rs
UTF-8
1,155
2.8125
3
[ "Unlicense", "LicenseRef-scancode-public-domain" ]
permissive
extern crate error_chain; //use errors; use std::env; pub fn get_env() -> String { let key = "RUST_ENV"; match env::var(key) { Ok(val) => { debug!("Found environment variable key {}: {:?}", key, val); val.to_string() }, Err(e) => { error!("Error inte...
true
1e2ce3af839df5a3d8669058b52c29d6afd09b2b
Rust
JulianSchmid/etherparse
/etherparse/src/transport/icmpv4/time_exceeded_code.rs
UTF-8
2,462
3.421875
3
[ "Apache-2.0", "MIT" ]
permissive
use super::*; /// Code values for ICMPv4 time exceeded message. #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum TimeExceededCode { /// Time-to-live exceeded in transit. TtlExceededInTransit = 0, /// Fragment reassembly time exceeded. FragmentReassemblyTimeExceeded = 1, } impl TimeExceededCode { ...
true
f3ef1c32a5445b98c3a4526ca42a00ce216c8ada
Rust
dunmatt/can-utils
/src/interface.rs
UTF-8
2,456
3.078125
3
[ "MIT" ]
permissive
//! The `interface` module holds various types for modeling parts of a CAN interface. /// The intended behavior of a CAN filter. pub enum MessageFilterType { /// Signifies a filter that includes traffic it matches. MatchMeansAccept, /// Signifies a filter that excludes traffic it matches. MatchMeansIgnore, } ...
true
c62924f5d8300c0ca568e1f64ed68fefd0cbe057
Rust
Little-Captain/dive-into-rust-of-fcc
/src/ch07/second.rs
UTF-8
10,565
4.46875
4
[]
no_license
#![allow(dead_code)] // match pub fn first() { // #[non_exhaustive] enum Direction { East, West, South, North, } fn print(x: Direction) { // 当一个类型有多种取值可能性的时候,特别适合使用 match 表达式 match x { Direction::East => { println!("East"); ...
true
cf01a5a0f889e07080c1ae581aab234178690219
Rust
Evergreenn/jdrp
/src/repository/mainlib.rs
UTF-8
3,624
2.84375
3
[]
no_license
use crate::repository::models::{ Caracter, NewCaracter, // Inventory, InventoryItemsGenerated, ItemGenerated, NewCaracter, NewPlayer, Player, }; use crate::resources::models::CaracterStats; // use crate::route::models::NewUserInput; use diesel::prelude::*; use diesel::sqlite::SqliteConnection; use dotenv::doten...
true
823118f829d12801b15395e537925ab1175c81db
Rust
iCodeIN/zzp-rs
/tools/src/bin/uurlog/invoice.rs
UTF-8
8,037
2.5625
3
[ "BSD-2-Clause" ]
permissive
use std::path::{Path, PathBuf}; use structopt::StructOpt; use structopt::clap; use super::read_uurlog; use zzp::gregorian::{Date, Month}; use zzp::partial_date::PartialDate; use zzp_tools::{CustomerConfig, ZzpConfig}; #[derive(StructOpt)] #[structopt(setting = clap::AppSettings::DeriveDisplayOrder)] #[structopt(setti...
true
b7105e3783310062f2917c043742b0fe95befb62
Rust
Orca-bit/DataStructureAndAlgorithm
/src/dp/_837_new_21_game.rs
UTF-8
971
3.140625
3
[]
no_license
struct Solution; impl Solution { pub fn new21_game(n: i32, k: i32, max_pts: i32) -> f64 { let (n, k, max_pts) = (n as usize, k as usize, max_pts as usize); let dp_size = k + max_pts; let mut dp = vec![0.; dp_size]; for i in k..dp_size.min(n + 1) { dp[i] = 1.; } ...
true
86593062f3e4c7951bc8b89c1ebc15e7dda2af6e
Rust
kildevaeld/value-rs
/value-validate/src/validations/oneof.rs
UTF-8
906
2.84375
3
[]
no_license
use crate::{types::ValidationList, Validation, ValidationBox, ValidationError}; use core::any::Any; use value::Value; #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Debug)] pub struct OneOf(pub Vec<ValidationBox>); #[cfg_attr(feature = "serde", typetag::serde(name = "one_of"))] ...
true