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
0ba189482d14740cfb0316564eda59aadd067096
Rust
lcy03406/ds
/src/streamer/memcached/streamer.rs
UTF-8
4,026
2.578125
3
[]
no_license
use std::io; use std::io::{Write, BufRead, Read}; use byteorder::{ByteOrder, BigEndian, ReadBytesExt, WriteBytesExt}; use service::ServiceStreamer; use ::super::protocol::*; use ::super::err::Error; pub struct MemcachedStreamer; impl ServiceStreamer for MemcachedStreamer { type Packet = Packet; type Error ...
true
73abe56c3425f879997b80b5ceb0c8cf51b0f7af
Rust
nbittich/subutext
/src/transposition/feature.rs
UTF-8
4,837
3.046875
3
[]
no_license
use std::collections::BTreeSet; use super::cell::CellKey; use super::{ cell::{ACell, Cell}, matrix::Matrix, }; impl Matrix { pub fn slice_at(&mut self, cell: Box<dyn ACell>) -> Matrix { let right_slice: String = self .cells .split_off(&CellKey::from_cell_key(cell)) ...
true
bfdc119e5d138499ec853783750a910fabb3b9c5
Rust
laverrer/extremedb-rs
/extremedb/src/sql/allocator.rs
UTF-8
1,647
2.609375
3
[]
no_license
// alloc.rs // // This file is a part of the eXtremeDB source code // Copyright (c) 2020 McObject LLC // All Rights Reserved //! Internal SQL allocators. //! //! The *e*X*treme*DB SQL subsystem uses custom allocators to optimize //! performance. These allocators are used to produce SQL values, data sources, //! record...
true
8e1bf43af1fe53e306bf20f2a88ff4db14add90a
Rust
jfrikker/minebot
/nbt/src/codec.rs
UTF-8
3,346
2.875
3
[]
no_license
use bytes::{BufMut, BytesMut}; use crate::{NbtDecode, NbtEncode, NbtEncoder, VarNum}; use std::io::{ErrorKind, Read, Result, Write}; use std::net::TcpStream; use std::time::Instant; #[derive(Clone)] pub struct NbtCodec { incoming: BytesMut, outgoing: BytesMut } impl NbtCodec { pub fn new() -> Self { ...
true
da6950b69926baea9d9b19921acf6ca2abaa45de
Rust
jingfee/advent-of-code-rust
/src/y2020/day13.rs
UTF-8
5,439
3.15625
3
[]
no_license
use crate::solver::Solver; use std::collections::HashMap; use std::fs::File; use std::io::prelude::*; use std::io::BufReader; pub struct Timetable { earliest_departure: usize, departures: Vec<usize>, departures_with_index: HashMap<usize, usize>, } pub struct Problem; impl Solver for Problem { type In...
true
447f5661fffe0c2b1a9d54ba7b0f362b8f98adbe
Rust
Xulder/the-foo-bar
/tests/posts.rs
UTF-8
976
2.84375
3
[]
no_license
mod helpers; use helpers::*; use rocket::http::ContentType; const POST_TITLE: &str = "Test post"; const POST_BODY: &str = "This is a test post!"; #[test] fn test_create_post() { let client = test_client(); let response = &mut client .post(format!("/api/posts")) .header(ContentType::JSON) ...
true
44cd577b00c3d59e07ae680efe496eca090461bd
Rust
RustCrypto/elliptic-curves
/k256/src/arithmetic/scalar.rs
UTF-8
33,720
2.734375
3
[ "LicenseRef-scancode-warranty-disclaimer", "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Scalar field arithmetic. #[cfg_attr(not(target_pointer_width = "64"), path = "scalar/wide32.rs")] #[cfg_attr(target_pointer_width = "64", path = "scalar/wide64.rs")] mod wide; pub(crate) use self::wide::WideScalar; use crate::{FieldBytes, Secp256k1, WideBytes, ORDER, ORDER_HEX}; use core::{ iter::{Product, S...
true
89a8becfd82e3828e013771e097d4c8778e83d96
Rust
gcao/spacelox
/spacelox_lib/src/builtin/nil.rs
UTF-8
1,039
2.578125
3
[]
no_license
use spacelox_core::managed::{Managed}; use spacelox_core::native::{NativeMeta, NativeMethod, NativeResult}; use spacelox_core::{hooks::Hooks, value::{ArityKind, Class, Value}}; pub const NIL_CLASS_NAME: &'static str = "Nil"; const NIL_STR: NativeMeta = NativeMeta::new("str", ArityKind::Fixed(0)); pub fn create_nil_cl...
true
bf22de68d3e654105e0bea7fc78951f9e9d8efa5
Rust
whackashoe/plause
/src/settings.rs
UTF-8
688
2.65625
3
[ "BSD-3-Clause" ]
permissive
static DEFAULT_PREFIX_SALT: &'static str = "@7@llc05754261933$uFf3r"; static DEFAULT_POSTFIX_SALT: &'static str = "11419523LIMin@73pRiv@cY"; #[deriving(Clone,Show)] pub struct Settings { pub blocksize: u32, pub salt: Vec<u8>, pub salt_prefix: Vec<u8>, pub salt_postfix: Vec<u8>, } impl Set...
true
7cba1567e606ed6f0c463d2f7edcf26c37e4a5a9
Rust
TumTum23/Rust-Design-Patterns
/structural/decorator/pizza/src/mozzarella.rs
UTF-8
547
3.390625
3
[ "MIT" ]
permissive
use Pizza; pub struct Mozzarella<'a> { base: &'a Pizza, description: String, cost: f32 } impl<'a> Mozzarella<'a> { pub fn new<T: Pizza>(base:&'a T) -> Mozzarella<'a> { Mozzarella { base, description: "Mozzarella".to_string(), cost: 2.49 } } } im...
true
ac529262941a4e181026cb320810d4e2d1db3913
Rust
nushell/nushell
/crates/nu-command/tests/commands/wrap.rs
UTF-8
1,569
2.6875
3
[ "MIT" ]
permissive
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed; use nu_test_support::playground::Playground; use nu_test_support::{nu, pipeline}; #[test] fn wrap_rows_into_a_row() { Playground::setup("wrap_test_1", |dirs, sandbox| { sandbox.with_files(vec![FileWithContentToBeTrimmed( "los_tres_cabal...
true
b6ad6fe15293371eb13dc15e513d3a9ee3def394
Rust
andreaskurth/moore
/src/vhdl/pass/lower.rs
UTF-8
6,549
2.75
3
[ "MIT" ]
permissive
// Copyright (c) 2017 Fabian Schuiki #![allow(unused_imports)] #![allow(unused_mut)] #![allow(unused_variables)] #![allow(dead_code)] //! This module implements the renumbering pass for the VHDL AST. This pass //! allocates node IDs, builds a hierarchy of scopes, and adds a definition to //! them for every item in the...
true
9be43a5510a6b7ff0314d379a69fe9d14ffd9c95
Rust
tcr/paxconsola
/paxforth/src/bin/paxforth.rs
UTF-8
5,081
2.5625
3
[ "MIT" ]
permissive
use maplit::{hashmap, hashset}; use paxforth::*; use std::collections::HashMap; use std::path::PathBuf; use structopt::StructOpt; use crate::check::*; use crate::debug::*; use crate::program::optimize; use crate::program::*; use crate::runner::wasm::run_wasm; use crate::targets::c64::*; use crate::targets::dos::*; use...
true
062db0980b4b8c823b0fc15baf6845832ce6a1cb
Rust
SeniorMars/week3_rs
/linked_list/src/linked_list.rs
UTF-8
2,523
3.53125
4
[]
no_license
use std::fmt::{self, Display}; use std::option::Option; pub trait ComputeNorm { fn compute_norm(&self) -> f64 { 0.0 } } #[derive(Debug, Default, Clone, PartialEq)] struct Node<T> { value: T, next: Option<Box<Node<T>>>, } impl<T> Node<T> { pub fn new(value: T, next: Option<Box<Node<T>>>) -...
true
634bf5e50b161d5ae618ae0b50ef6643c2b11189
Rust
robojeb/pcg_rand
/tests/advance_tests.rs
UTF-8
2,045
2.859375
3
[ "Apache-2.0" ]
permissive
extern crate pcg_rand; extern crate rand; use pcg_rand::{Pcg32, Pcg64}; use rand::RngCore; #[test] fn pcg32_short_advance() { // Test that advancing a short distance is equal to going the long way round let mut ra: Pcg32 = Pcg32::new_unseeded(); let mut rb: Pcg32 = Pcg32::new_unseeded(); ra.advance(...
true
f61868447bbe701095e64a02fab1f3122be617d1
Rust
pum-purum-pum-pum/red
/src/data.rs
UTF-8
3,968
2.609375
3
[]
no_license
use super::GL; use crate::shader::Program; use glow::Context; use std::os::raw::{c_int, c_uint}; #[derive(Copy, Clone, Debug)] #[repr(C, packed)] pub struct f32_ { pub d0: f32, } impl f32_ { pub fn new(d0: f32) -> f32_ { f32_ { d0 } } pub unsafe fn vertex_attrib_pointer( gl: &GL, ...
true
d532659bafaa4c7b71b39d6cfd315a3a2f24c0fc
Rust
xanahopper/leetcode
/src/leetcode/editor/cn/solution_1.rs
UTF-8
1,031
3.65625
4
[]
no_license
//Two Sum //Given an array of integers, return indices of the two numbers such that they a //dd up to a specific target. // // You may assume that each input would have exactly one solution, and you may n //ot use the same element twice. // // Example: // // //Given nums = [2, 7, 11, 15], target = 9, // //Because n...
true
94e1e4a0772ac53591ed20fe101e830a4e2ca167
Rust
accusitive/rbar2
/src/widgets/weather.rs
UTF-8
706
2.765625
3
[ "MIT" ]
permissive
use crate::{utils::bash, TXType, Widget, WidgetType}; pub struct Weather(pub TXType); impl<'a> Widget<'a> for Weather { type WState = (); fn update(_: &mut Self::WState) -> Option<String> { // bash::exec(r#"curl -s "wttr.in/?format=1" | grep -o ".[0-9].*""#.to_string()); let weather = bash::ex...
true
05dd854edc87ad03ebbf8f17064c695ac4301e86
Rust
steadylearner/Rust-Full-Stack
/unsafe/syscall/src/main.rs
UTF-8
621
2.703125
3
[ "MIT" ]
permissive
use std::io; // Read http://man7.org/linux/man-pages/man2/write.2.html #[cfg(not(target_os = "windows"))] #[link(name = "c")] extern "C" { fn write(fd: u32, buf: *const u8, count: usize) -> i32; } #[cfg(not(target_os = "windows"))] fn syscall(message: String) -> io::Result<()> { let msg_ptr = message.as_ptr()...
true
ed3553eb56edf259d27be0b05adc725e7037347e
Rust
xuewenchen/learnrust
/rust-vec/src/main.rs
UTF-8
1,062
3.71875
4
[]
no_license
fn main() { // new empty vector let my_vec: Vec<i32> = Vec::new(); // new mut empty vector let mut my_vec2: Vec<i32> = Vec::new(); my_vec2.push(1); my_vec2.push(2); my_vec2.push(3); // use 宏 init vector let my_vec3 = vec![1, 2, 3]; let a: &i32 = &my_vec3[0]; println...
true
ecb127ddb4e04661c98c6fc8056f03b4ab00504a
Rust
soarlab/rust-verification-tools
/verification-annotations/src/verifier/seahorn.rs
UTF-8
4,250
2.578125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright 2021 The Propverify authors // // 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 your // option. This file may not be copied, modified, or distributed // except ac...
true
f5fa4b5c0c92f85095eac2afd526c0e8cc2ac8e8
Rust
DzmitryFil/imgui-rs
/src/window/content_region.rs
UTF-8
1,069
2.609375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::sys; use crate::Ui; /// # Content region impl<'ui> Ui<'ui> { /// Returns the current content boundaries (in *window coordinates*) pub fn content_region_max(&self) -> [f32; 2] { unsafe { sys::igGetContentRegionMax_nonUDT2().into() } } /// Equal to `ui.content_region_max()` - `ui.curso...
true
34e015515c211d856479cf516f1324a7839db5ba
Rust
hbertoduarte/hilbert_2d
/examples/hilbert_continuous.rs
UTF-8
1,600
2.859375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use hilbert_2d::{h2xy_continuous_f64, Variant}; use plotlib::page::Page; use plotlib::repr::Plot; use plotlib::style::{LineStyle, PointStyle}; use plotlib::view::ContinuousView; /// Plots the lines for slices of the limiting Hilbert curve, for different step lenghts fn main() { let variant = Variant::Hilbert; ...
true
9246a8efba83ac482356233fc91916d98fccb69d
Rust
snorrwe/xenos
/src/collections/flaggrid/trait_impl.rs
UTF-8
4,962
2.96875
3
[ "MIT" ]
permissive
use super::*; use serde::de::{self, Deserialize, Deserializer, Visitor}; use serde::ser::{self, Serialize, Serializer}; use std::fmt::{self, Debug, Formatter}; macro_rules! implement_serde_for_bitgrid { ($name: ident) => { impl Serialize for $name { fn serialize<S>(&self, serializer: S) -> Resu...
true
1f1fd6e01bcfe979683935715d6d4bd3420381aa
Rust
ajmwagar/putt
/src/parser.rs
UTF-8
9,256
2.875
3
[]
no_license
use smaz::{decompress}; use std::io::prelude::*; use nom::{ branch::alt, bytes::complete::{is_not, tag}, character::complete::{alpha1, char as ch, digit1, multispace0, multispace1, one_of}, number::complete::{double}, combinator::{cut, map, map_res, opt}, error::{context, VerboseError}, mult...
true
28725fb43d713cb03829ac234ce294c6ecce9976
Rust
meraymond2/casql
/tests/integration_test.rs
UTF-8
9,367
2.65625
3
[]
no_license
use casql::args; use casql::cas_err::CasErr; use casql::postgres; use casql::postgres::connection::Conn; // Requires local test database to be running. /* bool | int2 | int4 | int8 ------+-------+----------+-------------- t | 12345 | 12345678 | 123456790123 */ #[test] fn test_integers() -> Result<(), Ca...
true
1ff8e05febcf87319920ae1b74a0856096cc108f
Rust
valdemarceccon/jq-shell
/src/main.rs
UTF-8
1,251
3.046875
3
[]
no_license
use rustyline::error::ReadlineError; use rustyline::Editor; fn main() { let mut rl = Editor::<()>::new(); if rl.load_history("history.txt").is_err() { println!("No previous history."); } loop { let readline = rl.readline("jqs> "); match readline { Ok(line) => { ...
true
bac65483dd2ec81571b7c8566185b1d596e31399
Rust
Cldfire/nvml-wrapper
/nvml-wrapper/src/struct_wrappers/nv_link.rs
UTF-8
1,600
2.71875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use crate::bitmasks::nv_link::PacketTypes; use crate::enum_wrappers::nv_link::UtilizationCountUnit; use crate::error::NvmlError; use crate::ffi::bindings::*; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use std::convert::TryFrom; /// Defines NvLink counter controls. // TODO: Write a test going to / f...
true
d9b20378071f792ea51040606a59ac8707250736
Rust
utilForever/BOJ
/Rust/28698 - Streak and Query.rs
UTF-8
14,683
3.03125
3
[ "MIT" ]
permissive
use io::Write; use std::borrow::Borrow; use std::collections::{btree_map, BTreeMap}; use std::{cmp::Ordering, io, str}; use Ordering::Less; pub struct UnsafeScanner<R> { reader: R, buf_str: Vec<u8>, buf_iter: str::SplitAsciiWhitespace<'static>, } impl<R: io::BufRead> UnsafeScanner<R> { pub fn new(read...
true
c3ed372122f32a020d2ff16525a997de077a65a1
Rust
ives9638/parquet2
/src/statistics/mod.rs
UTF-8
5,648
3.03125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
mod binary; mod boolean; mod fixed_len_binary; mod primitive; use std::{any::Any, sync::Arc}; pub use parquet_format_async_temp::Statistics as ParquetStatistics; use crate::error::Result; use crate::metadata::ColumnDescriptor; use crate::schema::types::PhysicalType; pub use binary::BinaryStatistics; pub use boolean...
true
21fcf4ffad528f59da031670325fa19ed29e5c03
Rust
nislim/transaction-processor
/src/main.rs
UTF-8
3,085
2.78125
3
[]
no_license
use std::{env::args, fmt::Display}; use tokio::{fs::File, io::{self, AsyncBufReadExt, AsyncWriteExt, BufReader, BufWriter}, sync::mpsc::channel}; mod account; mod account_manager; mod error; mod processor; mod transaction; mod fp_isize; use processor::parse_line; use fp_isize::FpIsize; use account_manager::AccountMa...
true
97f34e90bb2fbf6ac19558a9b87543cb4e1db8c7
Rust
CrazyTibor/wooting-double-movement
/src/native/src/controller.rs
UTF-8
3,318
2.90625
3
[ "MIT" ]
permissive
#[cfg(windows)] use vigem::XUSBReport; pub enum JoystickDirection { Up, Down, Left, Right, } pub struct JoystickState { up: bool, down: bool, left: bool, right: bool, } mod utils { /// Accepts x,y as values between -1 -> 1 pub fn process_circular_direction(x: f32, y: f32, d_pa...
true
032b61055d669808c57f9f40809c05d329cbe5d3
Rust
iCodeIN/flapy-bird-bevy
/src/player/camera.rs
UTF-8
1,528
2.65625
3
[]
no_license
use crate::prelude::*; use super::Player; pub struct CameraPlugin; impl Plugin for CameraPlugin { fn build(&self, app: &mut AppBuilder) { app .add_startup_system(setup_system.system()) .add_system(camera_follow_system.system()); } } #[derive(Debug, Default)] pub struct Camera;...
true
53831b414085734754c3b7e5d9ae1b82f921f630
Rust
sunnysingh97g/CtCI-rust
/src/linked_list/refcell_singly.rs
UTF-8
9,681
3.546875
4
[]
no_license
use std::cell::RefCell; use std::collections::HashSet; use std::convert::From; use std::fmt; use std::fmt::Display; use std::hash::{Hash, Hasher}; use std::ptr; use std::rc::Rc; pub type NodeRef<T> = Rc<RefCell<Node<T>>>; // Used specifically for hashing needs, like HashSet: pub struct HashedNode<T>(NodeRef<T>); #[d...
true
2a4871361e281c211dab2d6e75894d2344921cae
Rust
xxg1413/CS110L
/Assignments/week1/warmup/src/main.rs
UTF-8
2,245
4.0625
4
[ "Apache-2.0" ]
permissive
use std::collections::HashSet; //练习 fn add_n(v: Vec<i32>, n: i32) -> Vec<i32> { let mut result: Vec<i32> = Vec::new(); for i in v.iter() { result.push(i+n) } result } fn add_n_inplace(v: &mut Vec<i32>, n: i32) { let mut i = 0; while i < v.len() { v[i] = v[i] + n; ...
true
5170033f3fadeaf7fbb01e37b589e0f882723fb0
Rust
elipsitz/gm_reader
/src/decoder/detect.rs
UTF-8
3,434
2.5625
3
[ "MIT", "Apache-2.0" ]
permissive
use super::decrypt; use super::gmstream::GmStream; use crate::game::Version; use std::io::{Read, Result, Seek, SeekFrom}; pub struct GameData { pub data: Vec<u8>, pub version: Version, } fn read_rest<T: Read + Seek>(stream: &mut T) -> Result<Vec<u8>> { let mut data = vec![]; stream.read_to_end(&mut da...
true
6adc71d01b5827ae8948ff4c6c8069ed5e3f6674
Rust
ericgumba/chip_8
/src/keyboard.rs
UTF-8
3,014
3.125
3
[]
no_license
extern crate sdl2; use std::{collections::HashSet, time::Duration}; use sdl2::{Sdl, event::Event, keyboard::{KeyboardUtil, Keycode}}; use sdl2::EventPump; pub(crate) struct Keyboard{ pub keyboard: KeyboardUtil, pub event_pump: EventPump, pub p: bool, pub keys_pressed: [bool; 16], pub quit: bool } imp...
true
b5de82f6e268f0759fdfde4356dbe42299d4c0d6
Rust
lnds/exercism_rust_track
/rna-transcription/src/lib.rs
UTF-8
1,162
3.3125
3
[]
no_license
use std::collections::HashMap; #[derive(Debug, PartialEq)] pub struct DNA { string: Vec<char>, } #[derive(Debug, PartialEq)] pub struct RNA { string: Vec<char>, } const VALID_DNA_NUCLEOTID: &str = "GCTA"; const VALID_RNA_NUCLEOTID: &str = "CGAU"; fn construct_string(seq: &str, valid: &str) -> Result<Vec<ch...
true
64faed6186fb75af822bf49fafb8b3416f493ed0
Rust
Shalimov/ecluster
/src/estimator.rs
UTF-8
4,300
3.046875
3
[]
no_license
use ndarray::{array, Array, Array1, Array2, ArrayView1, ArrayView2, Zip}; pub struct ECluster<'a> { alpha: f64, beta: f64, edge_divider: u8, mid_clusters: ArrayView2<'a, i16>, estimated_clusters: Vec<(f64, Array1<i16>)>, } impl<'a> ECluster<'a> { pub fn euclidean_distance(zh: ArrayView1<i16>, ...
true
55a56c39dd2c9725c891d4367954dac1a966dc73
Rust
lipanski/mockito
/tests/lib.rs
UTF-8
60,690
2.65625
3
[ "MIT" ]
permissive
#[macro_use] extern crate serde_json; use mockito::{Matcher, Server}; use rand::distributions::Alphanumeric; use rand::Rng; use std::fmt::Display; use std::fs; use std::io::{BufRead, BufReader, Read, Write}; use std::net::TcpStream; use std::path::Path; use std::str::FromStr; use std::sync::{Arc, Mutex}; use std::thre...
true
c9a7426bf37d1832d72d244eee5eb3bcd21ac565
Rust
jpeterson1823/AdventOfCode
/2021/rust/day2/src/common/position.rs
UTF-8
463
3.890625
4
[]
no_license
pub struct Position { pub x: i32, pub y: i32, } impl Position { pub fn default() -> Position { Position { x: 0, y: 0 } } pub fn new(x: i32, y: i32) -> Position { Position { x, y } } pub fn print(&self, label: Option<&String>) { if let Some(s) = label { ...
true
e9743b6aaedf1e5b0359e2c514d065bd2fbe33fe
Rust
satylogin/leetcode
/hard/1755. Closest Subsequence Sum.rs
UTF-8
1,548
3.203125
3
[]
no_license
use std::cmp::min; impl Solution { fn get_sum(nums: Vec<i32>) -> Vec<i32> { let n: usize = nums.len(); let mut ans: Vec<i32> = Vec::with_capacity(1<<n); for x in 0..(1<<n) { let mut s: i32 = 0; for i in 0..n { if (x>>i) & 1 == 1 { ...
true
181844ce2bd1e0343eb28f11bba7e03b40f890bb
Rust
sagiegurari/duckscript
/duckscript/src/types/runtime_test.rs
UTF-8
551
2.59375
3
[ "Apache-2.0", "LicenseRef-scancode-free-unknown" ]
permissive
use super::*; #[test] fn context_new() { let mut context = Context::new(); assert!(context.variables.is_empty()); assert!(context.state.is_empty()); assert!(context.commands.get_for_use("test").is_none()); } #[test] fn runtime_new() { let mut context = Context::new(); context.variables.insert...
true
7a334d155f5cac360d7810be1591b473c38f0782
Rust
jfschaefer/declaration-spotter
/src/spotter.rs
UTF-8
14,473
2.53125
3
[]
no_license
use llamapun::patterns::Pattern as P; use llamapun::data::{Document}; use senna::phrase::Phrase; use libxml::tree::Node; use libxml::xpath::Context; // use std::io::stdout; // use std::io::Write; use mathanalyzer::*; pub struct DeclarationSpotter<'t> { pattern: P<'t, &'t str, &'t str>, } #[derive(Clone, Copy)...
true
0c4ba3e8e07c3a452a075549e00d34422e1cbe16
Rust
c0llision/rust
/demos/addab.rs
UTF-8
4,020
3.328125
3
[]
no_license
use std::io::stdin; use std::io::stdout; use std::io::Write; fn sum_numbers() { print!("Enter numbers to add seperated by spaces: "); let _= stdout().flush(); let mut s = String::new(); stdin().read_line(&mut s).expect(""); let mut sum: i64 = 0; for word in s.split_whitespace() { su...
true
6b6c045bdee1acaecfb7c96e96d3312e4435bd0b
Rust
rick68/Cplusplus-Primer-Plus-6thE-Code-Example-With-Rust
/Chapter 6/more_and.rs
UTF-8
1,020
2.90625
3
[]
no_license
// more_and.rs -- using continue and break #![allow(unused_assignments)] use std::io; use std::io::prelude::*; use std::string::String; const QUALITY: [&'static str; 4] = [ // an array of &str "10,000-meter race.\n", "mud tug-of-war.\n", "masters canoe jousting.\n", "pie-throwing festival.\n", ]; ...
true
e2812fe2b874cdf65dba4990d4b06abb210de27f
Rust
kkiyama117/myskk
/crates/ruskk_keys/src/event/key.rs
UTF-8
475
2.84375
3
[]
no_license
/// Main element of `KeyEvent`. /// This trait should implement `PartialEq` ,`Clone`, and Debug since `KeyEvent` /// requires. pub trait Key: PartialEq + Eq + std::fmt::Debug + Clone {} // some type can be used as `Key`. impl<'a> Key for &'a str {} impl Key for String {} impl Key for usize {} impl Key for u8 {} impl K...
true
ef49bc0d309da7c62e6beb56728fd971692e16e1
Rust
Mika-Lahtinen/poem
/src/middlewares/strip_prefix.rs
UTF-8
1,254
2.796875
3
[ "Apache-2.0", "MIT" ]
permissive
use std::sync::Arc; use crate::error::{Error, ErrorNotFound}; use crate::uri::Uri; use crate::{Endpoint, Middleware, Request, Response, Result}; pub struct StripPrefix { prefix: Arc<str>, } impl StripPrefix { pub fn new(prefix: impl AsRef<str>) -> Self { Self { prefix: prefix.as_ref().int...
true
e14dc812f6e3c4dd083c67a9be4ea5c694a72d87
Rust
habitat-sh/habitat
/components/core/src/os/signals/unix.rs
UTF-8
5,214
3.0625
3
[ "Apache-2.0" ]
permissive
//! Traps and notifies UNIX signals. use crate::os::process::SignalCode; use log::debug; use std::{io, mem, ptr, sync::{atomic::{AtomicBool, Ordering}, Once}, thread}; static INIT: Once = Once::new(); static PENDING_HUP: AtomicBool = At...
true
e1206910a27422383635d9c72057ed2a816cd3c4
Rust
Napokue/chip-8
/src/drivers/graphics.rs
UTF-8
3,829
3.6875
4
[]
no_license
//! Implementation of the low level building blocks of the driver, //! such as the VRAM allocation and other requirements of the emulator. const SCREEN_WIDTH: usize = 64; const SCREEN_HEIGHT: usize = 32; const SPRITE_WIDTH: usize = 8; pub struct Driver { vram: [[u8; SCREEN_WIDTH]; SCREEN_HEIGHT] } impl Driver {...
true
fc169e651ccb0c6ee1cf1fc9c88326119e2d77e2
Rust
Byron/gitoxide
/gix-sec/src/identity.rs
UTF-8
7,180
2.84375
3
[ "Apache-2.0", "MIT" ]
permissive
use std::path::Path; #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] /// An account based identity pub struct Account { /// The user's name pub username: String, /// The user's password pub password: String, } /...
true
f0084d965d4f2254fcc0b75f94af94404f0c8d97
Rust
SilanSurfer/advent_of_code_2020
/day_07/src/main.rs
UTF-8
448
2.75
3
[ "MIT" ]
permissive
use std::fs; mod solutions; fn main() { let file_path = "inputs/day_07.txt"; let contents = fs::read_to_string(file_path) .unwrap_or_else(|_| panic!("Couldn't open file {}", file_path)); let input_vec = utils::get_lines_from_input(&contents); println!( "Bag colors that can eventually c...
true
1a3fcf0a6b4e2ae39f5beab7cc2680fe1b2e093d
Rust
bytesonus/juno
/src/service/mod.rs
UTF-8
1,909
2.640625
3
[]
no_license
use crate::utils::{constants, logger}; use async_std::{fs::remove_file, io::Result, net::TcpListener}; use fslock::LockFile; pub mod data_handler; pub mod socket_server; pub async fn start(socket_path: &str) -> Result<()> { // Make sure no other instances of the application is running if crate::get_connection_typ...
true
47e1a857177fd3c7292f16647496f76484ff395d
Rust
benediktwerner/AdventOfCode
/2020/optimized/src/days/day06.rs
UTF-8
1,747
2.984375
3
[ "CC0-1.0", "MIT", "LicenseRef-scancode-public-domain" ]
permissive
use anyhow::ensure; pub struct Solver(()); impl Solver { pub fn new() -> Self { let solver = Self(()); assert_solver_day!(solver); solver } } impl crate::Solver for Solver { fn day(&self) -> u8 { 6 } fn is_input_safe(&self, input: &str) -> anyhow::Result<()> { ...
true
4c67191da2da4b3de66f971c0031cb1af19e443d
Rust
Eaglestrike/robot-code
/c2019/src/subsystems/controller/edge_detect.rs
UTF-8
1,668
3.390625
3
[]
no_license
#[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum Edge { Falling, Rising, Flat, } impl Edge { #[allow(dead_code)] pub fn falling(self) -> bool { self == Edge::Falling } pub fn rising(self) -> bool { self == Edge::Rising } #[allow(dead_code)] pub fn flat(self)...
true
05dc43c280af587879c9633cb6790024293146e1
Rust
guangie88/vlog-rs
/src/macros.rs
UTF-8
3,040
3.140625
3
[ "MIT" ]
permissive
/// Common macro for verbose `stdout` logs. /// This is meant to be used internally only. #[macro_export] macro_rules! verbose_log { ($v:expr, $fmt:expr) => { if $v <= $crate::get_verbosity_level() { println!($fmt); } }; ($v:expr, $fmt:expr, $($arg:tt)*) => { if $v <= $cr...
true
ed760bf52bf06cd299ff6fcfb4140ee085abf808
Rust
Sollimann/rust_grpc
/src/client.rs
UTF-8
1,032
2.890625
3
[]
no_license
use::futures::stream::iter; use hello::say_client::SayClient; use hello::SayRequest; mod hello; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>>{ // creating a channel i.e connection to server let channel = tonic::transport::Channel::from_static("http://[::1]:50051") .connect() ...
true
d40e7d42815c827b15a2ea72008539c982466b4b
Rust
blacktemplar/lighthouse
/lcli/src/helpers.rs
UTF-8
3,447
3.03125
3
[ "Apache-2.0" ]
permissive
use clap::ArgMatches; use hex; use std::path::PathBuf; use std::time::{SystemTime, UNIX_EPOCH}; use types::Address; pub fn time_now() -> Result<u64, String> { SystemTime::now() .duration_since(UNIX_EPOCH) .map(|duration| duration.as_secs()) .map_err(|e| format!("Unable to get time: {:?}", e...
true
21803dd002d740a5b066160903795adfc15be9a3
Rust
luksan/lm4flash-rs
/src/icdi_cmd.rs
UTF-8
530
2.53125
3
[]
no_license
use crate::IcdiDevice; use crate::{Context, Result}; use hex::FromHex; use std::str::FromStr; pub fn read_icdi_version(device: &mut impl IcdiDevice) -> Result<u32> { let mut response = device.send_remote_command(b"version")?; response.decode_buffer(); let hex = response.get_payload()?; let x = Vec::<...
true
387f1829ed30e369fd234c0dd750d5c73d58a81c
Rust
cki/backuprotate
/src/path_filter.rs
UTF-8
4,355
2.859375
3
[]
no_license
use std::path::{PathBuf, Path}; use chrono::{NaiveDate, Utc}; use chrono::format::ParseError; fn extract_date(file_prefix: &String, p: &Path) -> NaiveDate { let fname = p.file_name().expect("could not get filename").to_str().expect("could not get str"); NaiveDate::parse_from_str(fname, &format!("{}%Y-%m-%d.zip...
true
b5e932314e51cbe33332fc4b184f642f7fb43293
Rust
Carlton-Perkins/aoc-2020
/day11-p2/src/main.rs
UTF-8
5,750
3.1875
3
[]
no_license
/* --- Part Two --- As soon as people start to arrive, you realize your mistake. People don't just care about adjacent seats - they care about the first seat they can see in each of those eight directions! Now, instead of considering just the eight immediately adjacent seats, consider the first seat in each of those e...
true
a49ff310122f6d6a6e3ffcac4a9ced2b6eb8ce39
Rust
White-Green/impl-encrypt
/algorithms/transposition/src/test.rs
UTF-8
675
2.71875
3
[ "MIT" ]
permissive
use super::{decrypt, encrypt, Key}; #[test] fn test_key() { assert_eq!(Key::new("1 0 2"), Ok(Key(vec![1, 0, 2]))); Key::new("").unwrap_err(); Key::new("0 0 2").unwrap_err(); Key::new("0 2 3").unwrap_err(); assert_eq!(Key::new("2 0 3 1").unwrap().small(3), Key(vec![2, 0, 1])); assert_eq!(Key::n...
true
2d753e7ea227eeb08127d654d2282e9877669a2d
Rust
jonscanzi/music-master
/src/audio_handler/mod.rs
UTF-8
1,980
2.890625
3
[]
no_license
use std::path::Path; use std::sync::{Arc, Mutex}; use gst::prelude::*; use std::fs; use std::thread; pub struct AudioHandler { player: gst_player::Player, main_loop: glib::MainLoop, } impl AudioHandler { // ================== PUBLIC INTERFACE ================== pub fn new() -> Self{ // Ini...
true
67829294efe445c6277c6aaef0b59472b7d1557e
Rust
xpayn/aoc2018
/src/day14.rs
UTF-8
2,585
3.21875
3
[]
no_license
use aoc_runner_derive::aoc; fn parse_seq(input: &str) -> Vec<u8> { input .trim() .chars() .filter_map(|c| c.to_digit(10)) .map(|i| i as u8) .collect() } #[aoc(day14, part1)] pub fn solve_part1(input: &str) -> String { let mut recipes = vec![3, 7]; let n = input.trim...
true
2b33b2a6e607c98daf7ee905941dd9ced4c61c37
Rust
jlmcmchl/AdventOfCode2020
/src/day9.rs
UTF-8
1,395
2.984375
3
[]
no_license
use std::collections::HashSet; use aoc_runner_derive::{aoc, aoc_generator}; use itertools::Itertools; #[aoc_generator(day9)] pub fn input_generator(input: &str) -> Vec<u64> { input.lines().map(|u| u.parse::<u64>().unwrap()).collect() } fn is_predicated(e: u64, queue: &[u64]) -> bool { let set: HashSet<_> = q...
true
718525b46f6a8f35af2ad81a9ffa743cc5f6a4b4
Rust
yijie37/DaQiao
/bridge/parity-ethereum/util/len-caching-lock/src/lib.rs
UTF-8
2,716
2.984375
3
[ "Unlicense" ]
permissive
// Copyright 2015-2019 Parity Technologies (UK) Ltd. // This file is part of Parity Ethereum. // Parity Ethereum is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at yo...
true
53c248e7db21e563a9ab30615290859fe3924ea3
Rust
thaumant/eddie
/src/str/leven.rs
UTF-8
9,703
3.65625
4
[]
no_license
use crate::slice; use crate::utils::Buffer; const DEFAULT_CAPACITY: usize = 20; /// # Levenshtein distance. /// /// See [the detailed description][1]. /// /// [1]: https://en.wikipedia.org/wiki/Levenshtein_distance /// /// # Usage /// /// ```rust /// use eddie::Levenshtein; /// /// let lev = Levenshtein::new(); /// l...
true
c2935d7723a06549bffdbbea4c5bbcbf4f318d14
Rust
GSam/rust-refactor
/src/compiler/loader.rs
UTF-8
971
2.9375
3
[]
no_license
use std::collections::HashMap; use std::fs::{self, File}; use std::io::{self, Read}; use std::path::Path; use syntax::codemap::{FileLoader, FileName}; pub struct ReplaceLoader { files: HashMap<FileName, String>, } // Custom file loader to replace files matching certain names for the codemap. impl FileLoader for R...
true
11c43473c8659c8cc9ce1905156f7f9747a33b9d
Rust
ekmixon/gazebo
/gazebo/src/dupe.rs
UTF-8
5,695
2.71875
3
[ "Apache-2.0", "MIT" ]
permissive
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under both the MIT license found in the * LICENSE-MIT file in the root directory of this source tree and the Apache * License, Version 2.0 found in the LICENSE-APACHE file in the root directory * of this source tree. */ //! A...
true
1511c67df1c27a8049a31756f08cbba1c4b2bcca
Rust
akmal-ali-learning/sw-rust
/book/chapter9/panic/src/main.rs
UTF-8
2,382
3.71875
4
[ "MIT" ]
permissive
use std::fs::File; use std::io; use std::io::ErrorKind; use std::io::Read; fn main() { if(false){ let f= File::open("hello.txt"); let f = match f { Ok(file) => file, Err(error) => match error.kind() { ErrorKind::NotFound => match File::create("hello.txt") { Ok(fc) =...
true
d1d3f5af512611f1c34a9e30a921e7272c20cd76
Rust
A-Chathumini/Simple-Programs
/Rust-Programs/rust_basics/arrays.rs
UTF-8
684
3.671875
4
[ "MIT" ]
permissive
// Arrays - fixed list where elemtns are the same data types use std::mem; pub fn run() { println!("Arrays.rs start"); let mut numbers: [i32; 5] = [1, 2, 3, 4, 5]; // can make mutable with mut // re assigning numbers[2] = 20; println!("{:?}", numbers); // gets all values println!("Single va...
true
42003cad8b55bbe77459d6a37e1d8b0c09e5b514
Rust
Kerollmops/slice-group-by
/src/linear_str_group/linear_str_group.rs
UTF-8
1,335
3.09375
3
[ "MIT" ]
permissive
use crate::{LinearStrGroupBy, LinearStrGroupByMut}; /// An iterator that will return non-overlapping groups of equal `char` /// in the `str` using *linear/sequential search*. /// /// It will use the `char` [`PartialEq::eq`] function. /// /// [`PartialEq::eq`]: https://doc.rust-lang.org/std/primitive.char.html#impl-Par...
true
db848c17ad1f2cb7d17d8fee2286967b4f6b4cc2
Rust
mibac138/crates.io
/src/middleware/app.rs
UTF-8
937
2.796875
3
[ "Apache-2.0", "MIT" ]
permissive
use super::prelude::*; use crate::App; use std::sync::Arc; /// Middleware that injects the `App` instance into the `Request` extensions pub struct AppMiddleware { app: Arc<App>, } impl AppMiddleware { pub fn new(app: Arc<App>) -> AppMiddleware { AppMiddleware { app } } } impl Middleware for AppM...
true
89300bb4ea3578590c23d7155d2463dd0d698042
Rust
davidcole1340/chune
/src/error.rs
UTF-8
951
2.890625
3
[]
no_license
use thiserror::Error; type DynError = Box<dyn std::error::Error + Send + Sync>; #[derive(Debug, Error)] pub enum ConfigError { #[error("Could not read file `{0}`: {1:?}")] InvalidPath(String, std::io::Error), #[error("Read invalid toml content from `{0}`: {1:?}")] InvalidContent(String, toml::de::Erro...
true
59a79d1c4fe9d740059fab7a0bf89d5ea3987644
Rust
edoipi/rusty_duckling
/src/sat_solver.rs
UTF-8
6,325
2.578125
3
[]
no_license
use Cnf; use cnf_manager::*; use std::iter::*; use std::process::exit; pub struct Luby { pub seq : Vec<i32>, pub index : i32, pub k : i32 } impl Luby { pub fn new() -> Luby { Luby {seq : Vec::new(), index : 0, k : 1} } pub fn next(& mut self) -> i32 { self.index += 1; if self.index == (1 << self.k) - 1 {...
true
a4310e120ddbbb06347006a8308ea1ae1c99fb10
Rust
sunny4381/gphoto
/src/cmd.rs
UTF-8
1,457
2.515625
3
[]
no_license
pub(crate) mod init; pub(crate) mod refresh; pub(crate) mod whoami; pub(crate) mod albums; pub(crate) mod photos; use clap::ArgMatches; use self::init::execute_init; use self::refresh::execute_refresh; use self::whoami::execute_whoami; use self::albums::list::execute_albums_list; use self::albums::create::execute_alb...
true
cbcb6c591f84ed072aa3efd5939b6c0033edcd9b
Rust
rhavill/rust-programming-language
/8_common_collections/strings/src/main.rs
UTF-8
4,433
3.84375
4
[ "MIT" ]
permissive
fn main() { create_strings(); updating_strings(); indexing_into_strings(); slicing_strings(); iterating_strings(); } fn create_strings() { #[allow(unused_mut)] let mut s = String::new(); println!("In create_strings, s is '{}'.", s); let data = "initial contents"; let s2 = data...
true
436b7d104363495cfcd6ea32e7f38c72055da86d
Rust
rantt-io/rantt
/src/plan.rs
UTF-8
1,517
2.984375
3
[ "MIT" ]
permissive
use serde::{Deserialize, Serialize}; use std::fs; use std::fs::File; use std::io::{Read, Write}; use std::path::Path; #[derive(Debug, Deserialize, Serialize)] pub struct Plan { pub tasks: Vec<Task>, } #[derive(Debug, Deserialize, Serialize)] pub struct Task { pub description: String, pub effort: Effort, }...
true
dbdb8469acff1ace431090df5790f21d8cee0541
Rust
tamilps2/learning-rust
/lifetimes/src/main.rs
UTF-8
3,286
3.96875
4
[]
no_license
// case1: error // when looking at this function from the compilers borrow checker perspective, // it does not know which of the two borrowed arguments it needs to // keep the reference for, since the function returns only one str slice, // and it can be any of the 2 arguments passed. // fn longest(x: &str, y: &str) -...
true
f75ab25c51af55b4cd2e71fe229c44f0303053ab
Rust
gijs-s/pointctl
/src/view/scene.rs
UTF-8
18,637
2.6875
3
[ "MIT" ]
permissive
//! Code containing the scene used by the future, this tracks the state of the entire program. // Build in imports use std::process::exit; // Third party imports use kiss3d::{ camera::Camera, event::{Action, WindowEvent}, light::Light, planar_camera::PlanarCamera, post_processing::PostProcessingEf...
true
85fe05a1ab379ce46138f4c454073004092c0e54
Rust
ModProg/autod
/src/calendar.rs
UTF-8
29,476
3
3
[]
no_license
use std::fmt::Formatter; use std::fmt::{Debug, Display}; use std::str::FromStr; use chrono::NaiveDate; use chrono::TimeZone; use chrono::{ DateTime, Datelike, Duration, Local, Timelike, Weekday, }; use lazy_static::lazy_static; use regex::Regex; use unwrap::unwrap; #[derive(Debug)] pub enum Timer { Timers(Vec...
true
a1c3b8737d4db251daa7064dbd9052c4e63fac48
Rust
sisuware/vst_window
/src/platform/windows/event_source.rs
UTF-8
5,185
2.796875
3
[ "MIT", "Apache-2.0" ]
permissive
//! Provides a source for window events on Windows platforms. use std::sync::mpsc::{channel, Receiver, Sender}; use winapi::{ shared::{minwindef, windef}, um::winuser, }; use crate::event::{MouseButton, WindowEvent}; use crate::platform::EditorWindowImpl; use crate::platform::EventSourceBackend; pub(in crat...
true
026033eacdac8595fc314b3a7d443218e6f87c2c
Rust
ninjasource/lis2dh12-spi
/src/non_blocking.rs
UTF-8
23,206
2.8125
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::*; use accelerometer::vector::I16x3; use embassy_traits::spi::FullDuplex; use embedded_hal::digital::v2::OutputPin; pub use accelerometer::{vector::F32x3, Accelerometer}; pub enum ClickSource { Single, Double, } pub enum ClickInterupt { None, Int1(InterruptConfig), Int2(InterruptConfig...
true
6137f7853804fa5d26a03077255e19988f3e3d4d
Rust
eddyli1989/rust-study
/comm/src/config.rs
UTF-8
1,148
2.671875
3
[]
no_license
use rustc_serialize::json::Json; use std::fs::File; use std::io::Read; const FILE_PATH:&'static str = "../conf/conf.json"; #[derive(Debug)] pub struct Config { file_content:String, json_obj: Json } lazy_static! { static ref CONFIG: Config = Config::new(); } impl Config { fn new() -> Config { ...
true
07629ae7886b5953cc1187764cfa65483ca75f92
Rust
Hraesvel/minesweeper
/src/gameboard.rs
UTF-8
3,296
3.234375
3
[]
no_license
use rand::{thread_rng, Rng}; use crate::{Board, Tile}; #[derive(Debug)] pub struct GameBoard(pub Vec<Vec<Tile>>); impl GameBoard { pub fn new(level: usize, x_size: usize, y_size: usize, set_proxy: bool) -> Self { let mut board = GameBoard(Tile::blank_board(x_size, y_size).unwrap()); for dir in S...
true
d1ed4e4ad8c699334c930cadad57fca21592e356
Rust
siabard/rust_jrpg
/src/main.rs
UTF-8
3,516
2.8125
3
[]
no_license
use sdl2::event::Event; use sdl2::image::InitFlag; use std::collections::HashSet; use std::time::Duration; use sdl_isometric::states::*; use sdl_isometric::*; fn main() -> Result<(), String> { let sdl_context = sdl2::init().expect("ERROR on SDL CONTEXT"); let video_subsystem = sdl_context.video().expect("ERRO...
true
9b5cfd9fa5d1dd2295ea87c1ad60b85df5f486c9
Rust
rstanleyhum/graph-rs
/src/types/delta.rs
UTF-8
4,500
2.671875
3
[ "MIT" ]
permissive
use crate::error::GraphFailure; use crate::http::GraphResponse; use crate::types::content::Content; use graph_error::GraphResult; use reqwest::header::CONTENT_TYPE; use serde::export::PhantomData; use std::sync::mpsc::{channel, Receiver}; use std::thread; pub enum Delta<T> { Next(GraphResponse<T>), Done(Option...
true
b4868b12415080a758d7feb736c28bec969ebf27
Rust
gmrdn/ruban
/src/taskmanager.rs
UTF-8
4,920
3.171875
3
[]
no_license
use chrono::DateTime; use chrono::FixedOffset; use chrono::Utc; use serde::{Deserialize, Serialize}; use std::io::Read; #[derive(Debug, Serialize, Deserialize, Default)] pub struct Tasks { pub tasks: Vec<Task>, } impl IntoIterator for Tasks { type Item = Task; type IntoIter = ::std::vec::IntoIter<Task>; ...
true
ceb9fdb2a26f1e756fe381da2f2fee523c01cefe
Rust
uuhan/luster
/gc-arena/gc-arena-derive/src/lib.rs
UTF-8
5,094
2.75
3
[]
no_license
use proc_macro2::{Ident, Span, TokenStream}; use quote::{quote, ToTokens}; use synstructure::{decl_derive, AddBounds}; fn collect_derive(s: synstructure::Structure) -> TokenStream { // Deriving `Collect` must be done with care, because an implementation of `Drop` is not // necessarily safe for `Collect` types....
true
9a521adec8a414ef6cdc88faee3e671b4b9e58c0
Rust
elitecodegroovy/guessing_number
/src/main.rs
UTF-8
22,459
3.390625
3
[ "Apache-2.0" ]
permissive
use actix_web::{web, App, HttpResponse, HttpServer, Responder}; use rand::Rng; use serde::Serialize; use std::cmp::Ordering; use std::io; fn index() -> impl Responder { let my_string = String::from("Rust Async"); // first_word works on slices of `String`s let _word = first_word(&my_string[..]); let m...
true
e12aaf496b8c5846d6bbf6ddb29e33a200ae078e
Rust
wess/zi
/zi/src/text/string.rs
UTF-8
4,112
3
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use std::ops::{Bound, RangeBounds}; use unicode_segmentation::{GraphemeCursor, GraphemeIncomplete, Graphemes, UnicodeSegmentation}; use super::{ByteIndex, CharIndex, LineIndex, TextStorage, TextStorageMut}; impl<'a> TextStorage<'a> for String { type Slice = &'a str; type GraphemeIterator = Graphemes<'a>; ...
true
3e7d07d5a441ee9a15868e45da978f5c133512b2
Rust
dlunch/account
/scrap/src/kbcard.rs
UTF-8
19,919
2.515625
3
[ "MIT" ]
permissive
use std::collections::HashSet; use async_trait::async_trait; use chrono::{NaiveDateTime, TimeZone}; use chrono_tz::Asia::Seoul; use fantoccini::{elements::Element, error::CmdError, Client, Locator}; use prost_types::Timestamp; use serde_json::{json, Value}; use super::structs::{Card, CardTransaction}; use super::util...
true
27099952fc7ef8c13e7863d6eb3cf577255f6e5d
Rust
gkanwar/gullfoss-os
/user-rs/wallpaper/src/main.rs
UTF-8
3,623
2.65625
3
[ "MIT" ]
permissive
#![no_std] #![no_main] extern crate kernel; use kernel::{Signal}; use kernel::graphics::*; use core::*; use core::sync::atomic::{AtomicBool,Ordering}; // use image::{RgbaImage,Rgba}; static SHOULD_QUIT: AtomicBool = AtomicBool::new(false); // fn load_default_wallpaper(width: u32, height: u32) -> RgbaImage { // let...
true
a9b0cd27c228eb1929ba4b4c816a77b5ce5c565c
Rust
online-group-trivia/online-group-trivia-server
/websocket/src/websocket_routing.rs
UTF-8
325
2.734375
3
[ "MIT" ]
permissive
use serde::Deserialize; #[derive(Deserialize)] enum WebsocketMessage { Echo { body: String }, } pub fn handle_client_message(text: &str) -> String { let websocket_message: WebsocketMessage = serde_json::from_str(text).unwrap(); match websocket_message { WebsocketMessage::Echo { body } => body, ...
true
fce1492f448dcee4d7a274ff5955f4ce6650563f
Rust
flame4/leetcode
/src/medium/path_sum_ii_113.rs
UTF-8
1,759
3.484375
3
[]
no_license
use crate::Solution; use crate::treenode::PackTreeNode; impl Solution { /// https://leetcode.com/problems/path-sum-ii/ /// 给定一个sum, 找出所有从根到叶子的路径和等于这个值的. /// 就DFS吧... pub fn path_sum(root: PackTreeNode, sum: i32) -> Vec<Vec<i32>> { let mut ret = Vec::new(); if root.is_none() { return ret...
true
9580195f89201c438780fdefb4f6da3034e4eef0
Rust
sneako/advent_of_code_2020
/src/day10.rs
UTF-8
1,439
3.265625
3
[]
no_license
use aoc_runner_derive::{aoc, aoc_generator}; #[aoc_generator(day10)] fn parse_input(input: &str) -> Vec<u8> { let mut parsed: Vec<u8> = input .trim() .split("\n") .map(|val| val.parse::<u8>().unwrap()) .collect(); parsed.sort(); parsed } #[aoc(day10, part1)] pub fn part_one...
true
52bbda090555880ecc665b589195213575b94507
Rust
bouzuya/rust-atcoder
/cargo-atcoder/contests/arc054/src/bin/a.rs
UTF-8
657
2.875
3
[]
no_license
use proconio::input; fn main() { input! { l: usize, x: usize, y: usize, s: usize, d: usize, }; if d == s { println!("0"); return; } let mut ans = l as f64 / x as f64; if x < y { // 反時計回り let da = y - x; let la = if ...
true
59b0ab9507e15052e4440af1e624e7c46cbd3199
Rust
oshunter/fuchsia
/third_party/rust_crates/vendor/async-std/src/process/mod.rs
UTF-8
472
2.640625
3
[ "BSD-3-Clause", "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! A module for working with processes. //! //! This module is mostly concerned with spawning and interacting with child processes, but it also //! provides abort and exit for terminating the current process. //! //! This is an async version of [`std::process`]. //! //! [`std::process`]: https://doc.rust-lang.org/std/...
true
973b5e6bd70aba96e83fed3babfa1b7140797b06
Rust
guangie88/rs-json-collection
/src/storage.rs
UTF-8
3,634
3.203125
3
[ "MIT" ]
permissive
extern crate chrono; extern crate serde; use self::chrono::{DateTime, Local}; #[derive(Serialize, Deserialize, Getters, Debug)] pub struct Storage { path: String, capacity: u64, used: u64, remaining: u64, used_prop: f64, remaining_prop: f64, datetime: DateTime<Local>, } #[derive(Default, ...
true
f090292f58954fd08e56d5f593de8ade8c9cf010
Rust
carlokok/wasmtime
/cranelift/codegen/src/isa/x64/abi.rs
UTF-8
39,558
2.65625
3
[ "LLVM-exception", "Apache-2.0" ]
permissive
//! Implementation of the standard x64 ABI. use alloc::vec::Vec; use log::trace; use regalloc::{RealReg, Reg, RegClass, Set, SpillSlot, Writable}; use std::mem; use crate::binemit::Stackmap; use crate::ir::{self, types, types::*, ArgumentExtension, StackSlot, Type}; use crate::isa::{x64::inst::*, CallConv}; use crate...
true