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
edb38fe255f15dc94a8f5b97388b898ed3a4105a
Rust
slinkydeveloper/json-fuse-fs
/src/lib.rs
UTF-8
5,217
2.875
3
[]
no_license
pub mod raw; pub mod local; pub mod http; use std::error::Error; use std::fmt::{Display, Formatter, Debug}; use std::{fmt, iter, io}; use std::path::{Path, Component}; use std::ffi::OsStr; use raw::RawFSFileType; use local::LocalFSFileType; use fuse::FileAttr; use std::rc::{Rc, Weak}; use std::cell::RefCell; use std::...
true
8f5747a00a16688d3a7f4a0cca2c884339308f8a
Rust
AldanTanneo/simple-raytracer
/src/materials/dielectric.rs
UTF-8
1,606
2.984375
3
[]
no_license
use rand::Rng; use super::{Material, ScatterResult}; use crate::hittable::HitRecord; use crate::ray::{Ray, ScatteredRay}; use crate::vec3::color::Colour; use crate::FastRng; #[derive(Debug, Clone)] pub struct Dielectric { pub attenuation: Colour, pub refraction_index: f64, } impl Material for Dielectric { ...
true
a4dac59d67c329cdb3f37449b006eb098a4a5483
Rust
karencfv/syssim-archive
/src/network.rs
UTF-8
475
2.796875
3
[]
no_license
use std::time::Duration; use rand_distr::{Distribution, Normal}; pub struct Network { rng: Normal<f64>, } impl Network { pub fn new() -> Self { Self { rng: Normal::new(1_000.0, 100.0).unwrap(), } } /// Simulate network delay. pub async fn traverse(&self) { let...
true
50631dca74cb5908362d7a21a03b795a5f030530
Rust
cobalt-org/cobalt.rs
/crates/file-serve/src/lib.rs
UTF-8
6,826
3.296875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! > An HTTP Static File Server //! //! `file-serve` focuses on augmenting development of your site. It prioritizes //! small size and compile times over speed, scalability, or security. //! //! # Example //! //! ```rust,no_run //! let path = std::env::current_dir().unwrap(); //! let server = file_serve::Server::new(...
true
9f3862b18934c84fc920ab697f391f98469fa668
Rust
danielbuechele/formatter
/src/parsers/strong.rs
UTF-8
2,031
3.296875
3
[]
no_license
use crate::parsers::Format; use crate::utils::{ContentRange, Formatting, Parser, Range}; use lazy_static::lazy_static; use regex::Regex; #[derive(Debug, PartialEq)] pub struct Strong {} impl Parser for Strong { fn parse(text: &str) -> Vec<Formatting> { lazy_static! { static ref RE: Regex = Regex::new(r"(?...
true
61e6cce4d33231244dbd4be5a17075735e5e4b9f
Rust
garro95/pcp-rs
/src/types/payloads/map_response.rs
UTF-8
3,749
3.015625
3
[]
no_license
/* 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | Mapping Nonce (96 b...
true
57af888a9dda3a7e2483c1728b2e1295a79e03c5
Rust
sbstp/merovingian-old
/src/rename.rs
UTF-8
4,221
2.84375
3
[]
no_license
use std::collections::HashSet; use std::fs::{self, DirBuilder}; use std::io; use std::ops::Deref; use std::path::{Path, PathBuf}; use same_file::is_same_file; use same_file::Handle; use scan::ScanEntry; use util::PathExt; use vfs::File; pub struct Rename { pub orig: File, pub renamed: PathBuf, } impl Rename...
true
446e0f25257b49b53bcca43d078341aa35309ada
Rust
marceljay/rust_playground
/src/enums.rs
UTF-8
3,125
3.78125
4
[]
no_license
// Enums or enumerations are another custom data type in rust // Example here is based on the rust book/docs // In rust each enum variant can have data to go along with it. #![allow(unused_variables)] // An empty enum enum EmptyEnum { } // An enum containing different variants // variants of the enum are namespaced...
true
50cbf21e2b65fe0c246da0e220d45fd015c9d915
Rust
EmilNorden/rust-rt
/src/content/material_builder.rs
UTF-8
1,652
3.015625
3
[]
no_license
use crate::content::material::{Texture, Material}; pub struct MaterialBuilder { diffuse_map: Option<Texture>, diffuse_color: Option<glm::Vec3>, emissive_color: Option<glm::Vec3>, reflectivity: f32, transparency: bool, refractive_index : f32, } impl MaterialBuilder { pub fn new() -> Self { ...
true
2210acb74eb0b0483e1c6d3dedf7aa42731fd5f2
Rust
lxlyh/treehouse
/程序员喜欢玩的life game是个什么游戏?/rust_life/src/main.rs
UTF-8
4,158
2.890625
3
[]
no_license
use rand::distributions::{Distribution, Uniform}; use piston_window::*; // 代表细胞的矩形的长度和宽度 const CELL_SIZE: i32 = 20; // 二维矩形的行数 const CELL_ROWS: i32 = 30; // 二维矩形的列数 const CELL_COLS: i32 = 40; // 活着的细胞的颜色,黑色 const ALIVE_COLOR: [f32; 4] = [0.0, 0.0, 0.0, 1.0]; // 死亡细胞的颜色,我用了浅灰色,因为没有画边框,白色的太不明显 const DEAD_COLOR: [f32; ...
true
fd0f01cce9b4b66c4c91fbdbeb7a645b3254e6c6
Rust
zachkrall/rc-nannou
/perlin/src/main.rs
UTF-8
1,676
2.640625
3
[]
no_license
use nannou::prelude::*; use nannou::noise::{Perlin,Worley,NoiseFn}; use palette::Rgb; fn main() { nannou::app(model) .update(update) .view(view) .run(); } struct Model { } fn model(_app: &App) -> Model { let width = 900 as u32; let height = 900 as u32; _app.new_window() ...
true
2732f3019140533c4c9b1f9db5e0784266b0a62d
Rust
lightning-project/lightning
/src/types/chunk.rs
UTF-8
4,510
2.71875
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use lightning_core::util::array; use serde::{Deserialize, Serialize}; use std::fmt::{self, Debug}; use std::num::NonZeroU64; use crate::types::{DataType, Dim, MemoryKind, Strides, WorkerId, MAX_DIMS}; const PREFERRED_ALIGNMENT: usize = 256; #[derive(Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Hash, PartialOr...
true
97a9e7736db0bb7122c37851250a45f877d1b0be
Rust
Norgannon1028/natrium
/crates/r0codegen/src/ty.rs
UTF-8
1,570
3.125
3
[]
no_license
use r0syntax::util::P; #[derive(Debug, Clone, Eq, PartialEq)] pub enum Ty { Int, Double, Bool, Addr, Func(FuncTy), Void, } #[derive(Debug, Clone, Eq, PartialEq)] pub struct FuncTy { pub params: Vec<P<Ty>>, pub ret: P<Ty>, } impl Ty { pub fn size(&self) -> usize { match sel...
true
cb51513da328ff0a1e0b8b0d63fcfcc3238503a4
Rust
errordeveloper/mindtree_utils
/src/channel.rs
UTF-8
12,178
3.421875
3
[]
no_license
//! //! channel.rs //! //! Created by Mitchell Nordine at 02:00PM on March 25, 2015. //! //! /// A module for a channel that acts exactly as std::sync::mpsc::channel does, but rather than /// storing messages in an underlyhing queue, it only stores the latest message. pub mod last { use std::cell::UnsafeCell; ...
true
6fc814702a2a76dc28da2fc6334089ea4009004e
Rust
jxnu-liguobin/cs-summary-reflection
/rust-leetcode/src/leetcode_1385.rs
UTF-8
557
2.984375
3
[ "Apache-2.0" ]
permissive
use crate::pre_structs::Solution; ///两个数组间的距离值 impl Solution { //暴力解 pub fn find_the_distance_value(arr1: Vec<i32>, arr2: Vec<i32>, d: i32) -> i32 { let mut c = 0; let _ret = arr1.iter().for_each(|&x| { let mut flag = false; arr2.iter().for_each(|&y| { if...
true
9eb88f5037fdea577a4e66c84e246796084e9938
Rust
gremlin/shiplift
/examples/containerexec.rs
UTF-8
776
2.609375
3
[ "MIT" ]
permissive
extern crate shiplift; use shiplift::{Docker, ExecContainerOptions}; use std::env; fn main() { let docker = Docker::new(); let options = ExecContainerOptions::builder() .cmd(vec![ "bash", "-c", "echo -n \"echo VAR=$VAR on stdout\"; echo -n \"echo VAR=$VAR on stderr\...
true
ef0b37b90f57e6ff6be1bf6b15cfeb7d7a11deb0
Rust
F0903/rust_tcp_chat
/rust_tcp_client/src/main.rs
UTF-8
995
2.765625
3
[]
no_license
mod client; mod console; use console::{standard_console::StandardConsole, Console}; use std::sync::{Arc, Mutex}; const SERVER_ADDR: &str = "83.221.156.57:2"; fn main() { let input_client = Arc::new(Mutex::new( client::Client::start(SERVER_ADDR).expect("Couldnt start client."), )); let read_client = input_client...
true
fa44659e69d5a7a8b8db7c4f08b11da8a44ae8d8
Rust
ritobanrc/aoc2019
/src/day24.rs
UTF-8
6,273
3.328125
3
[]
no_license
use std::ops::Index; use std::fmt; use std::iter::FromIterator; use std::collections::{HashSet, VecDeque}; #[derive(PartialEq, Eq, Hash, Debug, Copy, Clone)] enum Tile { Bug, Empty } #[derive(PartialEq, Eq, Hash, Clone)] struct ErisMap { map: Vec<Tile>, width: usize, height: usize, } struct Eris...
true
6a4bd2010261f1fd47230c92ff34617dc0d34dda
Rust
xavierhamel/rack
/src/token/cmp.rs
UTF-8
836
3.015625
3
[ "MIT" ]
permissive
use crate::compiler::{asm::*, err}; #[derive(Debug, PartialEq, Clone)] pub enum Token { Eq, NotEq, Gt, Lt, Le, Ge, } impl Token { pub fn compile(&self) -> Result<Vec<Inst>, err::Err> { let mut output = vec![ Inst::Xor(Op::Rcx, Op::Rcx), Inst::Mov(Op::Rdx, Op...
true
7171fc64ca7ab5c06708dae9829b0c6464f70ebe
Rust
insomnimus/fsgc
/src/dur/parser.rs
UTF-8
3,377
3.375
3
[ "MIT" ]
permissive
use std::{ iter::Peekable, str::Chars, time::Duration, }; use super::Error; type TokenResult = Result<(Token, (usize, usize)), Error>; enum Unit { Nanos, Micros, Millis, Sec, Min, Hour, Day, Week, Year, } enum Token { Unit(Unit), Int(u64), } impl Token { fn kind(&self) -> &'static str { match self...
true
79c847def14b7281e963189578a8c45e7903ff20
Rust
rustwasm/weedle
/src/attribute.rs
UTF-8
3,473
3.296875
3
[ "MIT" ]
permissive
use crate::argument::ArgumentList; use crate::common::{Bracketed, Identifier, Parenthesized, Punctuated}; use crate::literal::StringLit; /// Parses a list of attributes. Ex: `[ attribute1, attribute2 ]` pub type ExtendedAttributeList<'a> = Bracketed<Punctuated<ExtendedAttribute<'a>, term!(,)>>; /// Matches comma sepa...
true
b9f3c81ef27e5ab2e1c9d3bdf6445e9e8acf59df
Rust
sjinno/exercism
/high-scores/src/lib.rs
UTF-8
995
3.21875
3
[]
no_license
#[derive(Debug)] pub struct HighScores<'a> { scores: &'a [u32], } impl<'a> HighScores<'a> { pub fn new(scores: &'a [u32]) -> Self { HighScores { scores } } pub fn scores(&self) -> &[u32] { self.scores } pub fn latest(&self) -> Option<u32> { // What the heck? se...
true
17a5236b262f9c6da3db9eddccfc7e8e88ac7977
Rust
ffhan/rustracer
/src/lighting/directional.rs
UTF-8
850
3.265625
3
[]
no_license
use crate::vector::Vector; use crate::base::{Color, Colorable}; use crate::lighting::Lighting; pub struct DirectionalLight { direction: Vector, color: Color, intensity: f64, } impl DirectionalLight { pub fn new(direction: Vector, color: Color, intensity: f64) -> DirectionalLight { DirectionalL...
true
0534f79e4cbd2352431a44838212c6042ff02e75
Rust
ryoppippi/ProjectEuler
/01to09/7.rs
UTF-8
853
3.15625
3
[]
no_license
/* 10001th prime is: 104759 ________________________________________________________ Executed in 134.10 millis fish external usr time 128.25 millis 79.00 micros 128.17 millis sys time 3.05 millis 475.00 micros 2.58 millis */ fn main() { let mut prime = 2; let mut count = 0; let...
true
2065cdbab7b77db251caaf925952e73aa0c720d8
Rust
howarddierking/smu-cs7350
/module2_HW1/q1/src/main.rs
UTF-8
561
3.265625
3
[]
no_license
use std::time::{Duration, Instant}; fn main() { let min = 100_000; let max = 1_000_000; let step = 100_000; let mut durations = Vec::new(); for n in (min..=max).step_by(step){ durations.push(hello_n(n)); } println!("\nRunning times for hello_n"); for d in durations{ ...
true
24d1046721001111faf87831929c4c88b3327841
Rust
fiji-flo/v2conv
/src/loader.rs
UTF-8
4,197
2.6875
3
[]
no_license
use std::collections::HashMap; use std::fs::File; use std::io::prelude::*; use std::path::PathBuf; use serde_json::Value; #[derive(Default)] pub struct Data { pub hris: Value, pub ldap: Value, pub mozillians: Value, } pub fn load_json(path: impl Into<PathBuf>) -> Result<Value, String> { let mut s = S...
true
705671b673be8747e522978dc1b764eaa62d8d71
Rust
adrien-ben/gltf-viewer-rs
/crates/viewer/src/controls.rs
UTF-8
2,882
3
3
[]
no_license
use vulkan::winit::event::{ DeviceEvent, ElementState, Event, MouseButton, MouseScrollDelta, WindowEvent, }; #[derive(Copy, Clone, Debug)] pub struct InputState { is_left_clicked: bool, is_right_clicked: bool, cursor_delta: [f32; 2], wheel_delta: f32, } impl InputState { pub fn update(self, ev...
true
54e8ce665bbc2e42867cab2eb9f5dafe47e9c3ee
Rust
oashtari/rust_http_server
/server_2/src/server.rs
UTF-8
5,465
3.578125
4
[ "MIT" ]
permissive
use std::io::{Write, Read}; use std::net::TcpListener; use crate::http::{Request, Response, StatusCode, ParseError}; // crate takes you back to the root folder use std::convert::TryFrom; // in order to code the trait into our code, must also pull it in here, as we did in the request.rs file use std::convert::TryInto; ...
true
5afe1b0f569242e6757a22e1fd6d833fb5cad23d
Rust
appaquet/exocore
/chain/src/chain/mod.rs
UTF-8
3,572
3.171875
3
[ "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
use std::ops::Range; use crate::{ block::{Block, BlockOffset, DataBlock}, operation::OperationId, }; #[cfg(feature = "directory-chain")] pub mod directory; pub mod error; pub use error::Error; pub mod data; pub use data::ChainData; /// Persistence for the chain pub trait ChainStore: Send + Sync + 'static { ...
true
1435c551365893be8ba6ed64e4e4edcc1680ab5f
Rust
gvassallo/rust-x11-window-manager
/assignment/src/e_fullscreen_windows.rs
UTF-8
38,887
3.390625
3
[]
no_license
//! Optional: Fullscreen Windows //! //! Extend your window manager with support for fullscreen windows, i.e. the //! ability to temporarily make a window take up the whole screen, thereby //! obscuring all other windows. See the documentation of the //! [`FullscreenSupport`] trait for the precise requirements. Don't c...
true
c9be3db50476de4be98989eb113bf2b6c1fc1b0d
Rust
offscale/liboffsetup
/src/lib.rs
UTF-8
29,219
2.671875
3
[ "CC0-1.0", "MIT", "Apache-2.0" ]
permissive
#[macro_use] extern crate validator_derive; mod scanning; use std::path::PathBuf; use std::{ collections::HashMap, env, process::Command as SystemCommand, string::{ParseError, ToString}, }; use config::{Config, ConfigError, Environment, File, FileFormat}; use scanning::platform::{Platform as CurrentP...
true
2c5b68c320f7e9f0d8cf8257397f2add37986a5f
Rust
nakakura/stun
/src/message/mod.rs
UTF-8
11,743
2.640625
3
[]
no_license
pub mod attributes; use byteorder::{BigEndian, WriteBytesExt}; use nom::*; use rand::prelude::*; #[cfg(test)] use hex; use super::error; #[derive(Debug)] pub struct StunMessage { pub header: StunHeader, pub attributes: Vec<Attribute>, } impl StunMessage { pub fn new(header: StunHeader, attributes: Vec<...
true
5c1338d1487147215ea776ea0c5cab55af51cda3
Rust
weclaw1/liquid_os
/src/memory/heap_allocator.rs
UTF-8
1,198
2.65625
3
[ "MIT" ]
permissive
use core::alloc::{GlobalAlloc, Layout}; use core::ptr::NonNull; use spin::Mutex; use slab_allocator::Heap; pub const HEAP_START: usize = 0o_000_001_000_000_0000; pub const HEAP_SIZE: usize = 80 * 4096; // 320 KiB static HEAP: Mutex<Option<Heap>> = Mutex::new(None); pub unsafe fn init(offset: usize, size: usize) { ...
true
cc74d2b7b408e96b4bd50e6c1b7634b6501fcf46
Rust
h4hany/leetcode
/python_solutions/1394.find-lucky-integer-in-an-array.rs
UTF-8
3,473
3.46875
3
[]
no_license
/* * @lc app=leetcode id=1394 lang=rust * * [1394] Find Lucky Integer in an Array * * https://leetcode.com/problems/find-lucky-integer-in-an-array/description/ * * algorithms * Easy (74.24%) * Total Accepted: 9.1K * Total Submissions: 12.5K * Testcase Example: '[2,2,3,4]' * * Given an array of integers...
true
89396d68aa435b3524c4ac0ca39ffebbffab0128
Rust
timmywheels/rust
/main/src/control_flow.rs
UTF-8
2,657
3.984375
4
[]
no_license
use std::io::stdin; fn if_statement() { let temp = 100; if temp == 75 { println!("it's the perfect temp") } else if temp < 75 { println!("it's not bad outside") } else if temp > 75 { println!("it's warm outside") } else if temp > 90 { println!("it's hot outside") ...
true
a18ddc43ce424b445ded948d14a4ee335053eb06
Rust
MyLordAngus/cryptopals-rust
/src/bin/set1_challenge6.rs
UTF-8
3,452
3.03125
3
[]
no_license
extern crate cryptopals; use std::env; use std::error::Error; use std::fs::File; use std::io::Read; use std::process; use cryptopals::ascii; use cryptopals::base64; use cryptopals::bit_utils; use cryptopals::cryptography::xor; fn main() { let filename_args_os = env::args_os().nth(1).unwrap_or_else(|| { println!("...
true
b0596d02d8b6aa6e727c32ecbf5cc937faa01511
Rust
dam4rus/msoffice-shared-rs
/src/xsdtypes.rs
UTF-8
928
2.9375
3
[ "MIT" ]
permissive
use super::{error::NotGroupMemberError, xml::XmlNode}; type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; pub trait XsdType where Self: Sized, { fn from_xml_element(xml_node: &XmlNode) -> Result<Self>; } pub trait XsdChoice: XsdType { fn is_choice_member<T: AsRef<str>>(node_name: T) -> ...
true
f7a99aacb8018c57053ee4163726174e33fd0202
Rust
arvo/arvo
/src/air/mod.rs
UTF-8
8,970
3.125
3
[ "MIT" ]
permissive
//! # Abstract Intermediate Representation //! //! The abstract intermediate representation (AIR) is resolved from an AST. //! Resolution checks that symbols are brought into scope before they are //! used, and are not used after they exit scope. At this stage, types have //! not necessarily been resolved. use super::...
true
48584795cf1e1e9b78b98ffc891bb89a2d414803
Rust
mvanotti/fuchsia-mirror
/src/testing/sl4f/src/modular/types.rs
UTF-8
2,234
2.875
3
[ "BSD-2-Clause" ]
permissive
// Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use serde::{Deserialize, Serialize}; /// Enum for supported Modular commands. pub enum ModularMethod { RestartSession, StartBasemgr, KillBasemg...
true
1b77fe144ad9f121d343f65b56037c619194df6f
Rust
fbegyn/AoC2018
/day02/src/main.rs
UTF-8
1,188
3.46875
3
[ "Unlicense" ]
permissive
const PUZZLE: &str = include_str!("./input.txt"); fn main() { let ids: Vec<&str> = PUZZLE.lines().collect::<Vec<_>>(); prob1(ids.clone()); prob2(ids); } fn prob1(ids: Vec<&str>) { let mut twos = 0; let mut threes = 0; for id in ids { if id.chars().any(|ch| id.matches(ch).count() == 2) ...
true
a726be7bb69a444188ad01e9d0cd5fe5b4145c6e
Rust
CPSSD/cerberus
/libcerberus/src/emitter.rs
UTF-8
4,697
3.890625
4
[ "MIT" ]
permissive
use errors::*; use serde::Serialize; /// The `EmitIntermediate` trait specifies structs which can send key-value pairs to an in-memory /// data structure. /// /// `EmitIntermediate` is intended for use in `Map` operations, for emitting an intermediate /// key-value pair. Since these in-memory data structures will even...
true
cc3a1ed6fb698a4b00bed9ce3de858401e39889d
Rust
ousbots/AdventOfCode
/archive/2021/day7/src/main.rs
UTF-8
2,797
3.609375
4
[]
no_license
use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::collections::HashMap; use std::fs::File; use std::io::{self, BufRead}; fn main() { let positions = parse_input("assets/input.txt"); let (min_position, min_moves) = calculate_minimal_position(positions.clone()); println!( "minimal ...
true
9ed83e4ef880224953fb9d29a760c9f52fa9eef1
Rust
kuwana-kb/ddd-in-rust
/chapter08_sample_application/src/usecase/user.rs
UTF-8
2,728
2.84375
3
[]
no_license
use anyhow::Result; use common::MyError; use crate::{ domain::{exists, HaveUserRepository, Name, User, UserRepository}, usecase::{CreateUserCommand, DeleteUserCommand, UpdateUserCommand, UserData}, }; // Cake Patternによる実装 // c6ではApplicationServiceをstructで表現したが、今回のパターンではtraitで表現している // このパターンだとtrait上のデフォルト実装に...
true
b47b675df6ab1f8ea29b94ce6cca0a149cfd3a07
Rust
ihalila/pancurses
/src/colorpair.rs
UTF-8
1,991
3.4375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::ops::BitOr; use super::{chtype, COLOR_PAIR}; use crate::attributes::{Attribute, Attributes}; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] pub struct ColorPair(pub u8); impl From<ColorPair> for chtype { fn from(color_pair: ColorPair) -> chtype { COLOR_PAIR(chtype::from(color_pair.0)) } }...
true
948cf100f777ff8389f602c82f10c4c97ae65403
Rust
MacTuitui/nannou
/nannou/src/mesh/channel.rs
UTF-8
2,684
3.09375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::borrow::{Borrow, Cow}; /// Types that may be used as a data channel within a mesh. pub trait Channel { /// The type contained within the channel. type Element; /// Borrow the data channel. fn channel(&self) -> &[Self::Element]; } /// Types that may be used as a data channel within a mesh. pub...
true
d70c2590f111eb41198684e2de08128c502f718b
Rust
KrekBuk/chess-rs
/src/discord/bot.rs
UTF-8
4,093
2.53125
3
[]
no_license
use std::collections::HashSet; use std::sync::Arc; use once_cell::sync::Lazy; use regex::Regex; use serenity::async_trait; use serenity::framework::standard::{ help_commands, macros::{help, hook}, Args, CommandGroup, CommandResult, Delimiter, DispatchError, HelpOptions, StandardFramework, }; use serenity::...
true
2ee111c1647f0ea2720223d9a7da32cb875aca2a
Rust
phyber/jail_exporter
/src/cli/validator.rs
UTF-8
7,611
3.0625
3
[ "MIT" ]
permissive
// Command line interface parsing validators #![forbid(unsafe_code)] #![deny(missing_docs)] use crate::file::FileExporterOutput; use std::net::SocketAddr; use std::path::Path; use std::str::FromStr; use tracing::debug; #[cfg(feature = "auth")] use std::path::PathBuf; #[cfg(feature = "auth")] // Basic checks for valid...
true
8c4ab7fbb8eafe765c51265d0e03023a8ca46f38
Rust
termapps/plotter
/src/hello.rs
UTF-8
439
3.328125
3
[ "MIT" ]
permissive
use std::io::{stdout, Write}; use crate::error::{Error, Result}; use clap::Parser; /// Say hello to someone #[derive(Debug, Parser)] pub struct Hello { /// The name of the person to greet name: String, } impl Hello { pub fn run(self) -> Result { if self.name == "world" { return Err(E...
true
c8c54d9bea5c45ffb7219903c1640e20d05525dd
Rust
Weasy666/rocket_auth
/src/authenticator.rs
UTF-8
824
2.875
3
[ "MIT" ]
permissive
use std::fmt::Debug; use crate::login::Login; use crate::logout::Logout; use rocket::request::FormItems; use rocket::request::Request; /// This trait needs to be implemented by the type which will be used in [`Login`] /// /// [`Login`]: crate::login::Login pub trait Authenticator { type Error: Debug; /// Can...
true
48703e95aaa33802e6e34221e762d49fd33df7a9
Rust
lmashraf/badboy-emu
/src/core/cpu.rs
UTF-8
9,737
3.25
3
[]
no_license
pub mod flags_register; pub mod instructions; pub mod registers; use self::instruction::{ ArithmeticTarget, ADDHLTarget, JumpTest, LoadByteSource, LoadByteTarget, LoadType, StackTarget, }; use self::registers::Registers; pub struct CPU { pub registers: Registers, pub bus: MemoryBu...
true
2f22fef9e9d2cbbcdb78bc72ecd459cc620efd8d
Rust
Ryman/Comparison-Programming-Languages-Economics
/RBC_rust/src/main.rs
UTF-8
5,559
2.515625
3
[ "MIT" ]
permissive
#![allow(non_snake_case, non_upper_case_globals)] extern crate time; use time::precise_time_s; /////////////////////////////////////////////////////////////////////////////// // 1. Calibration /////////////////////////////////////////////////////////////////////////////// const aalpha:f64 = 0.33333333333; // Elastici...
true
dc08ed6fc8d65495f94250d5d5676e486a53481c
Rust
yury-fedorov/AoC
/AoC17/rust/src/day19.rs
UTF-8
2,915
3.328125
3
[ "MIT" ]
permissive
#[derive(PartialEq, Copy, Clone)] enum Direction { Down, Up, Left, Right } #[derive(PartialEq, Copy, Clone)] enum Part { Cable, Letter, Space } type Point = (i32,i32); type Map = Vec<String>; fn next( p : &Point, d : &Direction ) -> Point { let (x,y) = p; match d { Direction::Down => ( *x, *...
true
337037b5a4bc2e8b6cfbb02a094e808b902b8891
Rust
abnerkaizer/rpc
/client/src/lib.rs
UTF-8
2,973
2.921875
3
[ "MIT" ]
permissive
use clap::{App, Arg}; use service::WorldClient; use std::{io, net::SocketAddr}; use tarpc::{client, context, tokio_serde::formats::Json}; #[tokio::main] async fn main() -> io::Result<()> { env_logger::init(); let flags = App::new("Client") .version("0.1") .author("Abner Kaizer <abnerkaizer@pro...
true
500386981bb7baba00148a829eabfef83ec99ec9
Rust
EFanZh/LeetCode
/src/problem_0904_fruit_into_baskets/mod.rs
UTF-8
593
3.171875
3
[]
no_license
pub mod iterative; pub trait Solution { fn total_fruit(fruits: Vec<i32>) -> i32; } #[cfg(test)] mod tests { use super::Solution; pub fn run<S: Solution>() { let test_cases = [ (&[1, 2, 1] as &[_], 3), (&[0, 1, 2, 2], 3), (&[1, 2, 3, 2, 2], 4), (&[3,...
true
e4e2758f25ec3ef62d5349e224b12fc53308fa21
Rust
ginryuoku/rv64gc-disasm
/src/main.rs
UTF-8
610
2.8125
3
[ "MIT" ]
permissive
enum InstFormat { R, I, S, U, } struct InstR { opcode: u8, funct3: u8, funct7: u8, rs1: u8, rs2: u8, rd: u8, } struct InstI { opcode: u8, funct3: u8, rs1: u8, rd: u8, immediate: i32, } struct InstS { opcode: u8, funct3: u8, rs1: u8, rs2: u8, immedia...
true
5596f3cf0796fd8718b856fd43bbec8c5be95b67
Rust
MostafaEissa/onehour
/src/main.rs
UTF-8
7,508
3.703125
4
[ "MIT" ]
permissive
use std::collections::HashMap; enum Command { SetVar(String, Value), GetVar(String), PushVar(String), Push(Value), Pop, Add, } #[derive(Clone, PartialEq, Debug)] enum Value { Nothing, Int(i64), String(String), } #[derive(Clone, PartialEq, Debug)] enum Type { Int, String, ...
true
9a514defbaf9fa0ebbcdc58bda574f6ae4806e71
Rust
maidsafe/sn_messaging
/src/node/section/peer.rs
UTF-8
1,460
2.75
3
[ "BSD-3-Clause", "MIT" ]
permissive
// Copyright 2020 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under The General Public License (GPL), version 3. // Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed // under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTI...
true
1ac6679d1a39ed2eb796a257c8b0b51ecf4ec02a
Rust
AngryLawyer/uo-rust-libs
/src/color.rs
UTF-8
1,005
3.46875
3
[ "MIT" ]
permissive
pub trait Color { fn to_rgba(&self) -> (u8, u8, u8, u8); fn from_rgba(r: u8, g: u8, b: u8, a: u8) -> Self; } pub type Color16 = u16; pub type Color32 = u32; impl Color for Color16 { fn to_rgba(&self) -> (u8, u8, u8, u8) { let r = (((*self >> 10) & 0x1F) * 0xFF / 0x1F) as u8; let g = (((*se...
true
3aa8745f280237c521490f840c79ed09d52ec848
Rust
random-ham/drand-rs
/src/client.rs
UTF-8
3,365
2.828125
3
[ "MIT" ]
permissive
//! Module implement client interface to drand-group. use std::{ cell::RefCell, sync::{Arc, Mutex}, }; use crate::{endpoints::Endpoints, Config, Error, Info, Random, Result}; /// List of available endpoints. #[derive(Clone)] pub enum Endpoint { /// https://api.drand.sh HttpDrandApi, /// https://a...
true
c50d2bbb2d5ff339ade556ce8832fb39783e7e82
Rust
tommyjl/tmux-sessions
/src/main.rs
UTF-8
2,086
3.015625
3
[ "MIT" ]
permissive
mod config; mod tmux; use anyhow::{anyhow, Result}; use clap::{crate_authors, crate_version, Clap}; use config::get_config; use tmux::{list_sessions, Session}; #[derive(Clap)] #[clap(version = crate_version!(), author = crate_authors!())] struct TmuxSessionsOpts { #[clap(subcommand)] subcmd: Command, } #[der...
true
7d0d2df81446660554f6563298debc003ef74402
Rust
60ke/wasm_contract_gen
/wasm2ct/src/types.rs
UTF-8
3,328
3.1875
3
[ "BSD-3-Clause" ]
permissive
pub use wasm_std::Vec; pub use wasm_std::String; pub use wasm_std::types::*; pub use crate::codec::Codec; #[derive(Debug, PartialEq, Eq)] pub enum Error { /// Invalid bool for provided input InvalidBool, /// Invalid u32 for provided input InvalidU32, /// Invalid u64 for provided input InvalidU64, /// The unexp...
true
743218693c92a46eb79ac2b2794dbb72fac48731
Rust
TENX-S/Rust-Algorithms
/src/bin/algorithms/sort_methods.rs
UTF-8
1,405
3.5
4
[]
no_license
/// Insertion sort algorithm const USIZE_MAX:usize = std::usize::MAX; pub fn insertion_sort(arr: &mut Vec<i32>) { for j in 1..arr.len() { let key = arr[j]; let mut i = j-1; while i != USIZE_MAX && arr[i] > key { arr[i+1] = arr[i]; // Or write code like follows ⬇️...
true
bf094cf45007909f102eb668df18f7e233779aca
Rust
scylladb/scylla-code-samples
/Rust_Scylla_Driver/ps-logger/src/duration.rs
UTF-8
705
2.625
3
[ "Apache-2.0" ]
permissive
use scylla::frame::response::result::CqlValue; use scylla::frame::value::{Value, ValueTooBig}; use scylla::frame::{ response::cql_to_rust::{FromCqlVal, FromCqlValError}, value::Timestamp, }; #[derive(Debug)] pub struct Duration(chrono::Duration); impl Duration { pub fn seconds(secs: i64) -> Self { ...
true
6fa2abd460850f1161c2acb63594e72509238e51
Rust
utilForever/BOJ
/Rust/17475 - Sequence and Query 27.rs
UTF-8
20,020
3.015625
3
[ "MIT" ]
permissive
use io::Write; use std::{io, str}; pub struct UnsafeScanner<R> { reader: R, buf_str: Vec<u8>, buf_iter: str::SplitAsciiWhitespace<'static>, } impl<R: io::BufRead> UnsafeScanner<R> { pub fn new(reader: R) -> Self { Self { reader, buf_str: vec![], buf_iter: ""...
true
29e9766e835e815cebb6ead20cd225099794e1bd
Rust
thulyatech/tantivy
/src/fastfield/multivalued/writer.rs
UTF-8
15,915
2.765625
3
[ "MIT" ]
permissive
use std::io; use fastfield_codecs::{ Column, MonotonicallyMappableToU128, MonotonicallyMappableToU64, VecColumn, }; use rustc_hash::FxHashMap; use super::get_fastfield_codecs_for_multivalue; use crate::fastfield::writer::unexpected_value; use crate::fastfield::{value_to_u64, CompositeFastFieldSerializer, FastFiel...
true
55e7080dd1c877e3c82eb30f5560462d6562c0ff
Rust
richwandell/rustjs
/src/vm/tests/objects.rs
UTF-8
1,163
2.609375
3
[]
no_license
use std::fs; use crate::lexer::lexer::Lexer; use crate::parser::parser::Parser; use crate::compiler::compiler::Compiler; use crate::vm::vm::Vm; use crate::parser::symbols::JSItem; #[test] fn test_object_new_property() { let file = fs::read_to_string("js/objects/object_new_property.js"); let mut lex = Lexer::n...
true
e9ee865a922cfd97e3d26c4d48a90e165da0d9a9
Rust
evolvedmicrobe/enclone
/enclone_core/src/linear_condition.rs
UTF-8
5,668
2.84375
3
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
// Copyright (c) 2021 10X Genomics, Inc. All rights reserved. use crate::defs::EncloneControl; use string_utils::*; #[derive(Clone)] pub struct LinearCondition { pub coeff: Vec<f64>, // left hand side (lhs) coefficients pub var: Vec<String>, // left hand side variables (parallel to coefficients) pub rhs:...
true
56e5d6ad4cfd3de9d4bf06f9157b9c880fc4ff69
Rust
gnieto/rs_proxy
/src/proxy/mod.rs
UTF-8
3,450
3.125
3
[]
no_license
use connection::Connection; use connection::Role; use mio::Token; use std::collections::HashMap; use std::rc::Rc; use std::cell::RefCell; pub struct Proxy { downstream: Rc<RefCell<Connection>>, upstream: Rc<RefCell<Connection>>, upstream_closed: bool, } impl Proxy { pub fn new(downstream: Rc<RefCell<C...
true
886750a095f11df16272560f0cfa2e795d73eb61
Rust
atraber/rust-riscv-sim
/src/elf.rs
UTF-8
1,015
2.75
3
[]
no_license
extern crate elf; use memory::*; use std::path::PathBuf; pub fn load<'out, T: Memory>(filename: &str, mem: &'out mut T) -> Result<u64, &'out str> { let path = PathBuf::from(filename); let file = match elf::File::open_path(&path) { Ok(f) => f, Err(e) => panic!("Error: {:?}", e), }; if ...
true
f1d07790cdcd7a078029be765f447d61ef47f1f0
Rust
heyrutvik/pikelet
/crates/pikelet-concrete/tests/infer.rs
UTF-8
24,310
2.59375
3
[ "Apache-2.0" ]
permissive
use codespan::{ByteIndex, ByteSpan, CodeMap}; use moniker::{assert_term_eq, FreeVar, Var}; use pretty_assertions::assert_eq; use pikelet_concrete::desugar::{Desugar, DesugarEnv}; use pikelet_concrete::elaborate::{self, Context, TypeError}; use pikelet_concrete::syntax::{concrete, raw}; mod support; #[test] fn undefi...
true
d52613f36532468da12182d3575f0494bc347ddb
Rust
d-z-h/rust-guide
/examples/datetime/duration/examples/checked.rs
UTF-8
840
3.28125
3
[ "MIT", "Apache-2.0" ]
permissive
use chrono::{DateTime, Duration, Utc}; fn day_earlier(date_time: DateTime<Utc>) -> Option<DateTime<Utc>> { date_time.checked_sub_signed(Duration::days(1)) } fn main() { let now = Utc::now(); println!("{}", now); let almost_three_weeks_from_now = now.checked_add_signed(Duration::weeks(2)) ...
true
9745ccc7a97d4af48229f565318403f2f7d885dd
Rust
futile/enet-rs
/src/packet.rs
UTF-8
3,347
3.1875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use enet_sys::{ enet_packet_create, enet_packet_destroy, ENetPacket, _ENetPacketFlag_ENET_PACKET_FLAG_RELIABLE, _ENetPacketFlag_ENET_PACKET_FLAG_UNSEQUENCED, }; use crate::Error; /// A packet that can be sent or retrieved on an ENet-connection. #[derive(Debug)] pub struct Packet { inner: *mut ENetPacket, ...
true
17e6b5a5fcb5f777120403e9eb6d1b37efc5dd46
Rust
usmanzaheer1995/piaic-assignments
/6/q1/src/main.rs
UTF-8
1,102
4.15625
4
[]
no_license
#[derive(Debug)] // 1. define a custom datatype using Struct struct Person { name: String, age: u8, email: String, } // 3. define user defined function fn return_instance(name: &str, age: u8, email: &str) -> Person { Person { name: String::from(name), age, email: String::from(e...
true
00c09626b3fa317a01356e7e21694cd47f13fee1
Rust
rosofo/rsynth
/src/chain.rs
UTF-8
979
2.765625
3
[]
no_license
use crate::config::{Config, ConfigReceiver}; pub trait Effect<Signal>: ConfigReceiver { fn process(&mut self, signal: Signal) -> Signal; } pub trait Voice<Signal>: ConfigReceiver { fn generate(&mut self) -> Signal; } pub struct Chain<Signal> { pub chain: Vec<Box<dyn Effect<Signal> + Send + 'static>>, } ...
true
005dc871c30d2e587f8531b0d29d4ef536052795
Rust
mrnix/rust_d3_geo
/src/circle/generator.rs
UTF-8
3,012
3.03125
3
[]
no_license
use std::cell::RefCell; use std::fmt::Debug; use std::fmt::Display; use std::ops::AddAssign; use std::rc::Rc; use geo::{CoordFloat, Coordinate}; use num_traits::AsPrimitive; use num_traits::FloatConst; use crate::rotation::rotate_radians; use crate::rotation::rotate_radians::RotateRadians; use crate::rotation::rotati...
true
2707ab35cedc75a5bd5d77c07973999ff1a15d0d
Rust
Thomasdezeeuw/gaea
/src/os/mod.rs
UTF-8
17,039
3.234375
3
[ "MIT" ]
permissive
//! Operating System backed readiness event queue. //! //! [`OsQueue`] provides an abstraction over platform specific Operating System //! backed readiness event queues, such as kqueue or epoll. //! //! [`OsQueue`]: crate::os::OsQueue //! //! # Portability //! //! Using [`OsQueue`] provides a portable interface across ...
true
a7dc702cc5f47bf6813bfde479dd7af4a0abc168
Rust
RicoGit/rust-alg
/src/leetcode/short_encoding_of_words.rs
UTF-8
670
3.296875
3
[]
no_license
//! 820. Short Encoding of Words impl Solution { pub fn minimum_length_encoding(words: Vec<String>) -> i32 { let mut reversed: Vec<String> = words .into_iter() .map(|w| w.chars().rev().collect()) .collect(); reversed.sort(); let mut result = reversed[0].l...
true
f81311087c2af31a3aaf837a97f8f115a53f83e6
Rust
Microsvuln/binexp-practice
/fuzzing/naive-fuzzer/src/main.rs
UTF-8
4,664
3
3
[]
no_license
use std::io; use std::fs; use std::time::{Duration, Instant}; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; use std::path::Path; use std::collections::BTreeSet; use std::process::{Command, ExitStatus}; use std::os::unix::process::ExitStatusExt; use std::collections::hash_map::DefaultHasher; use st...
true
bd96f09ab85933295d10513f26bc78bfe72a1fa4
Rust
iwonasado/chamkho
/src/edge.rs
UTF-8
387
3.0625
3
[ "BSD-2-Clause" ]
permissive
#[derive(Clone, PartialEq, Eq, Copy, Debug)] pub enum EdgeType { Init, Dict, Unk, InSpace, Space } #[derive(Clone, Copy, Debug)] pub struct Edge { pub w: usize, pub unk: usize, pub p: usize, pub etype: EdgeType } impl Edge { pub fn better_than(&self, o: &Edge) -> bool { ...
true
64ba999d7602110a38c41a6348bbfea5dfb769fe
Rust
Guang1234567/minigrep
/src/rc/mod.rs
UTF-8
2,299
3.453125
3
[]
no_license
use std::cell::RefCell; use std::rc::Rc; #[derive(Debug)] enum ListRefVersion<'a, T> { Cons(T, &'a Box<ListRefVersion<'a, T>>), Nil, } #[derive(Debug)] enum ListRcVersion<T> { Cons(T, Rc<ListRcVersion<T>>), Nil, } #[derive(Debug)] enum ListRcRefVersion<T> { Cons(Rc<RefCell<T>>, Rc<ListRcRefVersio...
true
3847a89b128b19c0e967ef4377f957fc83abbb9e
Rust
parkerziegler/rust-book
/patterns_and_refutability/src/main.rs
UTF-8
1,887
4.21875
4
[]
no_license
// Patterns come in two forms — refutable and irrefutable. // // Refutable patterns are distinguished by their ability _not_ to match. // For example, in the pattern: // if let Some(x) = a_value { // the pattern will fail to match if a_value is None. // if let and while let accept refutable and irrefutable patterns, al...
true
3683cd7ab051bb37787914d14d252b18afe36ce0
Rust
exphp-share/hex-sols
/rust/numtheory/src/lib.rs
UTF-8
13,137
3.203125
3
[]
no_license
#![allow(non_snake_case)] #![cfg_attr(test, feature(test))] extern crate num_integer; extern crate num_traits; use num_integer::Integer; use num_traits::{PrimInt,Signed,One,NumCast}; use ::std::collections::HashMap; use ::std::hash::Hash; #[cfg(test)] extern crate test; #[cfg(test)] extern crate rand; #[derive(Copy...
true
2a0dcc37ccc95b3c4f9db2edb7333d1482062bd5
Rust
EYEFOUREYE/rrvm
/src/memory.rs
UTF-8
1,972
3.4375
3
[ "MIT" ]
permissive
use elf::Elf; #[derive(Debug)] pub struct Memory<'a> { map: &'a mut Vec<u8>, elf: &'a Elf, entry_point_address: u64, entry_point_offset: u64, } impl<'a> Memory<'a> { pub fn new(vec: &'a mut Vec<u8>, elf: &'a Elf) -> Memory<'a> { Memory { map: vec, elf: elf, ...
true
fe70910594cc2fe991c54df478a28db291b61740
Rust
napi-rs/napi-rs
/crates/napi/src/js_values/function.rs
UTF-8
4,571
2.71875
3
[ "MIT" ]
permissive
use std::ptr; use super::Value; #[cfg(feature = "napi4")] use crate::{ bindgen_runtime::ToNapiValue, threadsafe_function::{ThreadSafeCallContext, ThreadsafeFunction}, }; use crate::{bindgen_runtime::TypeName, JsString}; use crate::{check_pending_exception, ValueType}; use crate::{sys, Env, Error, JsObject, JsUnkno...
true
6176512acdc85161b63fcae162d51cb9ba3f02f6
Rust
tom-james-watson/converter
/src/units/mass.rs
UTF-8
477
2.6875
3
[]
no_license
use crate::units::{Unit, UnitType}; pub fn init() -> UnitType { UnitType { name: String::from("Mass"), units: vec![ Unit { name: String::from("Grams"), abbreviation: String::from("g"), factor: 0.001, }, Unit { ...
true
7d039f54eaac49dd28b76cab97dcaf719d6a0251
Rust
TylerReid/advent-2020
/src/two.rs
UTF-8
1,424
3.421875
3
[]
no_license
extern crate regex; use regex::Regex; use std::fs::File; use std::io::{self, BufRead}; lazy_static! { static ref R: Regex = Regex::new("^(\\d*)-(\\d*) (.): (.*)$").unwrap(); } pub fn day_two() { let file = File::open("input/day2.txt").unwrap(); let raw_passwords = io::BufReader::new(file) .lines...
true
c0ea4dd941a0ba426b9af8536d8195261f6aa9d0
Rust
plantvsbirds/mpc
/src/protocol/digest/mod.rs
UTF-8
4,031
2.703125
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use bn::Fr; use std::io::Read; use rustc_serialize::{Encodable, Encoder, Decodable, Decoder}; use bincode::SizeLimit::Infinite; use bincode::rustc_serialize::encode; use blake2_rfc::blake2b::blake2b; use blake2_rfc::blake2s::blake2s; mod base58; use self::base58::{ToBase58, FromBase58}; #[macro_export] macro_rules! ...
true
6ec265a206252434c0d5f6eb83452857df8192ca
Rust
mdcg/a-tour-of-rust
/codewars/dia-6/lightsabers.rs
UTF-8
264
2.71875
3
[ "MIT" ]
permissive
// https://www.codewars.com/kata/51f9d93b4095e0a7200001b8/train/rust // Minha solução fn how_many_lightsabers_do_you_own(name: &str) -> u8 { match name { "Zach" => 18, _ => 0, } } // Melhor solução // A minha solução foi a melhor!!!
true
f17b2ed111bee941835df5971db41d1efb3d6751
Rust
Desmonddai583/Notes
/Rust/cxyjt/Rocket/demo/mysql/02. 取出多条数据、映射实体类集合/main.rs
UTF-8
407
2.8125
3
[]
no_license
use mysql::prelude::*; mod util; use util::*; #[derive(Debug)] struct UserModel { user_id: i32, user_name: String, } fn main() { init_db(5, 10); let mut conn = db().unwrap(); let sql = "select user_id,user_name from users"; let users = conn.query_map(sql, |(uid, uname)| UserModel { us...
true
7a48184cd0737df04b21c3332fc3fc22e88c1821
Rust
ChooChooShoe/rust-cardgame
/src/server/ws_server_handle.rs
UTF-8
7,044
2.671875
3
[ "MIT" ]
permissive
use crate::game::stage::NetRelay; use crate::game::{Action, NetPlayerId}; use crate::net::{Codec, Connection}; use crate::net::{PROTOCOL, VERSION_HEADER}; use crate::server::ws_server::Role; use std::error::Error as StdError; use std::sync::mpsc::Sender as TSender; use ws::util::Timeout; use ws::util::Token; use ws::{ ...
true
afdb0e5f9b2505d6dbd03ad0cfb8da1d27ffbaa1
Rust
cuviper/teloxide
/src/dispatching/dialogue/dialogue_stage.rs
UTF-8
745
3.1875
3
[ "MIT" ]
permissive
/// Continue or terminate a dialogue. /// /// See [the module-level documentation for the design /// overview](crate::dispatching::dialogue). #[derive(Debug, Copy, Clone, Eq, Hash, PartialEq)] pub enum DialogueStage<D> { Next(D), Exit, } /// A shortcut for `Ok(DialogueStage::Next(dialogue))`. /// /// See [the ...
true
1a9ca22ee73c9b06a90fc9c07a58e2858e114e40
Rust
xuedong/leet-code
/Problems/Algorithms/201. Bitwise AND of Numbers Range/bitwise_range.rs
UTF-8
287
2.734375
3
[ "MIT" ]
permissive
impl Solution { pub fn range_bitwise_and(left: i32, right: i32) -> i32 { let mut i = 0; let (mut left, mut right) = (left, right); while left != right { left >>= 1; right >>= 1; i += 1; } left << i } }
true
116bf15804084f844cb52a49f8bf517015b538e0
Rust
JusungLee0601/snakeriver-server
/src/operators/operation.rs
UTF-8
2,110
2.59375
3
[]
no_license
use super::aggregation::Aggregation; use super::innerjoin::InnerJoin; use super::projection::Projection; use super::leaf::Leaf; use super::root::Root; use super::selection::Selection; use crate::units::change::Change; use petgraph::graph::NodeIndex; use crate::operators::Operator; use crate::viewsandgraphs::dfg::DataFl...
true
faac0e71c9be2ad533d9e010fa1dd9be3bfd9d39
Rust
yuemenglong/rust-sample
/src/main.rs
UTF-8
2,507
2.859375
3
[]
no_license
#[macro_use] extern crate orm; use orm::*; entity!{struct Person{ age:i32, name:String, updatetime:DateTime, }} entity!{struct A{ bid: u64, value: i32, }} entity!{struct B{ value: i32, }} macro_rules! anno { (struct $ENTITY:ident{ $($(#[$META:meta]),* $FIELD:ident:$TYPE:...
true
e46f2c8a0b9d81290db7c949b9016e71967cca42
Rust
peap/exercism-rust
/allergies/src/lib.rs
UTF-8
1,450
3.265625
3
[ "MIT" ]
permissive
use std::slice::Iter; pub type Score = u8; // u8 generates one warning due to a test, but still compiles #[derive(Clone, Copy, Debug, PartialEq)] pub enum Allergen { Eggs = 0b00000001, Peanuts = 0b00000010, Shellfish = 0b00000100, Strawberries = 0b00001000, Tomatoes = 0b00010...
true
5b2dbea822a92b3c1af69d95a4e8a6ff795a894d
Rust
FloydATC/rlox
/src/lox/vm/test/classes.rs
UTF-8
10,552
2.9375
3
[]
no_license
use super::compile_and_execute; // Classes #[test] fn vm_class_empty() { let code = "class c {} exit 1;"; let res = compile_and_execute(code); assert_eq!(res.is_ok(), true); assert_eq!(res.unwrap(), 1); } #[test] fn vm_class_setproperty() { let code = "class cx {} var ix=cx(); ix.field=123; exi...
true
455f0b35ad3279db19e597d3bd514741e2495ab6
Rust
iCodeIN/simple-sysf-tyck
/src/exhibit.rs
UTF-8
6,303
2.984375
3
[]
no_license
use crate::ast::{Tm, TmExpr, TmRef, Ty, TyExpr, TyRef, DBI}; pub struct TyExhibit { pub exhibit: Vec<Ty>, } impl TyExhibit { pub fn new() -> Self { Self { exhibit: vec![] } } pub fn var(&mut self, dbi: DBI) -> TyRef { self.exhibit.push(Ty::Var(dbi)); self.exhibit.len() - 1 ...
true
8dce7cf26b77409a94b16f92523bf59b676e6cfa
Rust
Manishearth/euclid
/src/scale_factor.rs
UTF-8
5,379
3.140625
3
[ "MIT", "Apache-2.0" ]
permissive
// Copyright 2014 The Servo Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at ...
true
81263dc46722856f8e19cf8fccdcfbcabb02d6ca
Rust
jimberlage/stl_parser
/src/main.rs
UTF-8
1,953
2.65625
3
[]
no_license
extern crate clap; extern crate nom; use parser::error::SolidError; use std::process::exit; pub mod bounding_box; pub mod coordinate; pub mod facet; pub mod parser; pub mod solid; fn handle_parse_error(error: SolidError) { match error { SolidError::Unparsable => { println!("The solid file is ...
true
d9e934818a3d867ae78353b9679da2cf6c9f2788
Rust
Luffbee/talent-kvs
/src/client.rs
UTF-8
3,855
2.578125
3
[]
no_license
extern crate bytes; extern crate tokio; use slog::Logger; use tokio::codec::Framed; use tokio::net::TcpStream; use tokio::prelude::*; use std::net::SocketAddr; use std::str; use crate::get_logger; use crate::protocol::{Proto, ProtoCodec}; pub struct KvsClient { addr: SocketAddr, log: Logger, } impl KvsClie...
true