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
c0299d6cfe30d3689829b4134a4e4f9f94f2be04
Rust
yutiansut/steward
/src/lib.rs
UTF-8
3,650
2.984375
3
[ "MIT" ]
permissive
#![deny(missing_docs)] //! Task runner and process manager for Rust. //! //! If you're not happy managing your infrastructure with a pile of bash scripts, //! this crate might be helpful. It provides base building blocks for defining //! and running various kinds of tasks. //! It's like [`foreman`](https://github.com/...
true
377c18cd50a16f1478d1b285e4c61cb2a9692a23
Rust
Lakelezz/serenity
/src/model/user.rs
UTF-8
29,317
2.90625
3
[ "ISC" ]
permissive
//! User information-related models. use serde_json; use std::fmt; use super::utils::deserialize_u16; use super::prelude::*; use internal::prelude::*; use model::misc::Mentionable; #[cfg(all(feature = "cache", feature = "model"))] use CACHE; #[cfg(feature = "model")] use builder::{CreateMessage, EditProfile}; #[cfg(f...
true
042afc04d1cb71b2e6c9d865cfda42f07558aaca
Rust
kingfree/learn-rust
/my-redis/examples/read_to_end.rs
UTF-8
298
2.671875
3
[]
no_license
use tokio::fs::File; use tokio::io::{self, AsyncReadExt}; #[tokio::main] async fn main() -> io::Result<()> { let mut f = File::open("Cargo.toml").await?; let mut buffer = Vec::new(); f.read_to_end(&mut buffer).await?; println!("The bytes: {:?}", buffer); Ok(()) }
true
b0e149c560f73bf631cc9e960b0fb89c2d315ad7
Rust
magnet/metered-rs
/metered/src/atomic.rs
UTF-8
2,994
3.859375
4
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! A module providing new-type Atomic wrapper that implements Debug & //! Serialize. use serde::{Serialize, Serializer}; use std::{ fmt, fmt::{Debug, Display}, sync::atomic::Ordering, }; /// A new-type wrapper over `atomic::Atomic` that supports serde serialization /// and a cleaner debug output. /// ///...
true
47dfa441f5a1c0d6918272b54be064ef0eaa77e8
Rust
kozo002/rust-learning
/bitonic_sorter/src/fourth.rs
UTF-8
2,129
3.328125
3
[]
no_license
use super::SortOrder; use rayon; use std::cmp::Ordering; const PARALLEL_THRESHOLD: usize = 4096; pub fn sort_by<T, F>(x: &mut [T], comparator: &F) -> Result<(), String> where T: Send, F: Sync + Fn(&T, &T) -> Ordering { if x.len().is_power_of_two() { do_sort(x, true, comparator); Ok(()) } else { ...
true
cf9ee55963b59e2313970038562175b71028fc7d
Rust
idubrov/dfp-rs
/src/tests.rs
UTF-8
3,806
2.6875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
#![allow(warnings)] use super::FpCategory; use crate::traits::DecimalConsts; use crate::*; type d32_down = Decimal<u32, DownRoundingContext>; use std::fmt; #[derive(PartialEq)] pub struct Bits<T: fmt::LowerHex>(pub T); impl<T: fmt::LowerHex> fmt::Debug for Bits<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt:...
true
076ca946775af60a873096b3514b60aae027709f
Rust
bouzuya/rust-atcoder
/cargo-atcoder/contests/abc108/src/bin/b.rs
UTF-8
301
2.734375
3
[]
no_license
use proconio::input; fn main() { input! { x1: i64, y1: i64, x2: i64, y2: i64, }; let dx = x2 - x1; let dy = y2 - y1; let x3 = x2 - dy; let y3 = y2 + dx; let x4 = x3 - dx; let y4 = y3 - dy; println!("{} {} {} {}", x3, y3, x4, y4); }
true
e58ead948f73a230f49844265dda04bb2ff34385
Rust
armstrtw/pnlsim
/tests/fx_fwd_tests.rs
UTF-8
876
2.84375
3
[]
no_license
use chrono::NaiveDate; use pnlsim::Currency::*; use pnlsim::Security::*; use pnlsim::*; #[test] fn fxfrd_basic_tx() { let mut portfolio = Portfolio::new(); assert!(portfolio.is_empty()); let usdjpy = FxFrd(USD, JPY, NaiveDate::from_ymd(2020, 3, 31)); tx(&mut portfolio, &usdjpy, 1e6, 107.0); asser...
true
7dae8af9c1aca7e8f30908149f25cd44f3c96ff5
Rust
df5602/interpreter_tutorial
/src/ast/unary_operator_node.rs
UTF-8
9,044
3.46875
3
[]
no_license
use std::fmt; use tokens::{Token, OperatorType, TokenValue, Span}; use symbol_table::SymbolTable; use ast::{Ast, AstNode, AstIndex}; use errors::SyntaxError; use interpreter::{NodeVisitor, Value}; /// Unary operator node. /// Unary operators are '+' and '-' in front of expressions. #[derive(Debug)] pub struct UnaryOp...
true
6b3db7680441aeb809e98296086b6f63be2a0205
Rust
alexeyden/bpi-bare-bones
/src/devices/io.rs
UTF-8
886
3.03125
3
[]
no_license
use core::ptr::write_volatile; use core::ptr::read_volatile; pub unsafe fn write(reg: u32, value: u32) { write_volatile(reg as *mut u32, value) } pub unsafe fn read(reg: u32) -> u32 { read_volatile(reg as *mut u32) } pub unsafe fn set_bits(reg: u32, v: u32) { let val = read(reg); write(reg, val | v);...
true
88560159d843e0ee3121d7d46ab30daa624ad099
Rust
andoriyu/uclicious
/src/raw/object.rs
UTF-8
23,998
3.203125
3
[ "BSD-2-Clause" ]
permissive
//! Objects parsed by the parser. //! //! When you are done feeding the parser call `::get_object()` method on a parser. This will give you //! an owned copy of an `Object`. Difference between `Object` and `ObjectRef` - internal reference count is only decreased for `Object` when dropped. //! //! ### Cloning //! //! Du...
true
915e25458a2c003f40c9cea2555bd6ff18fa74e6
Rust
PistonDevelopers/find_folder
/src/lib.rs
UTF-8
5,457
3.8125
4
[]
no_license
use std::fs; use std::io; use std::path::{Path, PathBuf}; /// Depth of recursion through kids. pub type KidsDepth = u8; /// Depth of recursion through parents. pub type ParentsDepth = u8; /// The direction in which `find_folder` should search for the folder. #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum Sea...
true
d63f70982a12d1474da10326f65ff05fad1f5886
Rust
MRuvinshteyn/rust-testing
/sort/selection/main.rs
UTF-8
470
3.328125
3
[]
no_license
fn selection_sort(v:&mut Vec<i64>) -> () { for i in 0..(v.len() - 1) { let mut min:i64 = v[i + 1]; let mut min_pos:usize = i + 1; for j in i..(v.len() - 1) { if v[j] < min { min = v[j]; min_pos = j; } } v[min_pos] = v[i]...
true
0750ff70c8509825890e5464ec7a28c33e655ad7
Rust
ridgetinez/cryptopals
/avltree/src/lib.rs
UTF-8
3,476
3.65625
4
[]
no_license
use std::fmt::{Display, Debug}; use std::cmp::Ordering; use std::iter::FromIterator; // Exercise 1: Define the datatypes as enums, different from the struct they use! // Ord is overly strict, we only need `lt`, not `lte` #[derive(Debug, PartialEq, Eq, Clone)] enum BinaryTree<T> { Leaf, Node(T, Box<BinaryTree<...
true
9fbe1cbe0e990b6d707f91377fa88a9ea5f264b5
Rust
rahulg/dns-lookup
/src/nameinfo.rs
UTF-8
2,736
2.875
3
[ "MIT", "Apache-2.0" ]
permissive
use socket2::SockAddr; use std::ffi::CStr; use std::io; use std::net::SocketAddr; use std::str; #[cfg(unix)] use libc::{c_char, getnameinfo as c_getnameinfo}; #[cfg(windows)] use winapi::ctypes::c_char; #[cfg(windows)] use winapi::um::ws2tcpip::getnameinfo as c_getnameinfo; use err::LookupError; /// Retrieve the na...
true
2b9d668b77986ffb6ddfb775965e5d36a816e9e7
Rust
thvdburgt/advent-of-code-2017
/day-12-digital-plumber/src/lib.rs
UTF-8
1,878
3.390625
3
[]
no_license
use std::collections::{HashMap, HashSet}; pub fn solve_puzzle_part_1(input: &str) -> String { let programs: HashMap<usize, HashSet<usize>> = input.lines().map(to_program).collect(); depth_first_search(&programs, 0).len().to_string() } pub fn solve_puzzle_part_2(input: &str) -> String { let programs: Hash...
true
e0e7014b54b52dd43c0baad26993e8f496c5b7ed
Rust
siddharth-kulshrestha/learn-rust
/programs/communicator/src/lib.rs
UTF-8
570
2.796875
3
[]
no_license
//mod network { //fn connect() { //} //mod server { //fn connect() { //} //} //// In this scenario, we are creating server as submodule of network, which makes more sense here. //} // can be used as network::connect() // //mod client { //fn connect() { } //} //...
true
d516b4d25d8bf709ad963b27f88162daf54e6581
Rust
scottmcm/uax
/src/property_tables/block.rs
UTF-8
10,035
2.75
3
[]
no_license
use crate::lookup_table::LookupTable; use crate::properties::Block; use Block::*; impl From<char> for Block { #[inline] fn from(c: char) -> Self { if c < ROW0_LIMIT { return ROW0_TABLE.get_or(&(c as u8), No_Block); } if c < PLANE0_LIMIT { return PLANE0_TABLE.get...
true
6906a5cf96860fdf62b8e0c4e70c3d1dff204ab0
Rust
lupyuen/kurbo-embedded
/src/cubicbez.rs
UTF-8
14,556
2.625
3
[ "Apache-2.0", "MIT" ]
permissive
//! Cubic Bézier segments. use libm; //// use core::ops::{Mul, Range}; //// ////use std::ops::{Mul, Range}; use introsort; //// use crate::MAX_EXTREMA; use arrayvec::ArrayVec; use crate::common::solve_quadratic; use crate::common::GAUSS_LEGENDRE_COEFFS_9; use crate::{ Affine, ParamCurve, ParamCurveArclen, ParamC...
true
fa9052ac0f0a23650ff778823ba1b9000783fded
Rust
sirxyzzy/ilbm
/src/bytes.rs
UTF-8
2,449
3.28125
3
[]
no_license
use crate::{IlbmError, Result}; use std::convert::TryInto; // // Note, this module is heavily inspired by the "bytes" crate, but differs // mainly in being panic free, instead returning results. // It is also a tad faster, I like fast // /// Expose interface as a Trait, doing thing this way leads to a more concise //...
true
552af248a8661a906fb1b779f49ee475cbfa47d1
Rust
sammyne/the-rust-programming-language
/chapter18/listings/_08/src/main.rs
UTF-8
91
2.8125
3
[]
no_license
fn main() { let some_option_value = Some(123); let Some(x) = some_option_value; }
true
bcdb48d0c2289cab347b35b0e022cfa282e2af64
Rust
ratmice/pikelet
/src/semantics/tests/check_module.rs
UTF-8
3,459
2.578125
3
[ "Apache-2.0" ]
permissive
use library; use super::*; #[test] fn prelude() { let mut codemap = CodeMap::new(); let filemap = codemap.add_filemap(FileName::virtual_("test"), library::PRELUDE.into()); let writer = StandardStream::stdout(ColorChoice::Always); let (concrete_module, errors) = parse::module(&filemap); if !errors...
true
ca927923726ee8032b537d677daf4057b497c50b
Rust
michaeljclark/piet-gpu
/piet-gpu-derive/src/parse.rs
UTF-8
6,959
3.3125
3
[ "MIT", "Apache-2.0", "Unlicense" ]
permissive
//! Parsing of the source extern crate proc_macro; use std::collections::HashSet; use syn::{ Expr, ExprLit, Fields, FieldsNamed, FieldsUnnamed, GenericArgument, ItemEnum, ItemStruct, Lit, PathArguments, TypeArray, TypePath, }; /// A scalar that can be represented in a packed data structure. #[derive(Clone, ...
true
63f74ca01f47e060e13c8b42720cea2688689a5b
Rust
cambricorp/amq
/src/node.rs
UTF-8
3,020
2.984375
3
[ "MIT" ]
permissive
use actix::io::FramedWrite; use actix::prelude::*; use futures::Stream; use log::info; use std::net; use std::str::FromStr; use tokio_codec::FramedRead; use tokio_io::AsyncRead; use tokio_tcp::{TcpListener, TcpStream}; use crate::codec::MqCodec; use crate::server::MqServer; use crate::session::MqSession; use crate::ty...
true
2cad08c98a0bc8286631f1c8d7e24b524369426e
Rust
alinpopa/exbio
/native/exbio/src/alignment/distance.rs
UTF-8
890
2.625
3
[]
no_license
use bio::alignment::distance::{hamming as hdist, levenshtein as ldist}; use bio::utils::TextSlice; use rustler::{Encoder, Env, NifResult, Term}; mod atoms { rustler_atoms! { atom ok; atom error; atom invalid_args; } } pub fn hamming<'a>(env: Env<'a>, args: &[Term<'a>]) -> NifResult<Ter...
true
bee3cdff970e94c8dbd31a698289e442de4cf04d
Rust
JP-Ellis/coding-problems
/src/daily_coding_problem/p063.rs
UTF-8
894
3.15625
3
[]
no_license
use crate::{Error, Problem}; use std::io::prelude::*; pub struct P; const STATEMENT: &str = r#"Given a 2D matrix of characters and a target word, write a function that returns whether the word can be found in the matrix by going left-to-right, or up-to-down. For example, given the following matrix: [['F', 'A', 'C',...
true
ea0b18ba4dbf30cb16060393596a615b03d3bfc5
Rust
libspecinfra/specinfra
/src/provider/service/mod.rs
UTF-8
2,870
2.59375
3
[ "MIT" ]
permissive
use provider::HandleFunc; use provider::service::inline::InlineProvider; use provider::service::shell::ShellProvider; pub struct ServiceProvider { pub inline: Box<InlineProvider>, pub shell: Box<ShellProvider>, } impl ServiceProvider { pub fn new(i: Box<InlineProvider>, s: Box<ShellProvider>) -> ServicePr...
true
105e80e334a3da70ec0bb34ba6189d75fef9984d
Rust
zhangjunfang/rust_note
/rust_grep/src/main.rs
UTF-8
1,463
3.515625
4
[ "Apache-2.0" ]
permissive
use std::error::Error; use std::env; use std::fs::File; use std::process; use std::io::Read; fn main() { let args: Vec<String> = env::args().collect(); if args.is_empty() { println!("Hello, world!"); } else { let config = Config::new(&args).unwrap_or_else(|err| { eprintln!("Prob...
true
abcbb95311d00620aba73f56c4354b7f9da27cf3
Rust
shunf4/rust-matching-engine
/src/errors.rs
UTF-8
2,807
2.75
3
[]
no_license
use actix_web::{error, HttpResponse}; use derive_more::Display; use failure::Fail; use http::StatusCode; #[derive(Serialize)] pub struct EngineErrorModel { status: u16, error: String, } #[derive(Debug, Display)] pub enum EngineError { #[display(fmt = "{}", _0)] InternalError(String), #[display(fmt...
true
680ea14c5343f495dbebc920894501da156efd5c
Rust
dmweis/remote-controller
/src/lib.rs
UTF-8
8,400
2.734375
3
[ "MIT", "Apache-2.0" ]
permissive
use futures::{SinkExt, StreamExt}; use include_dir::{include_dir, Dir}; use log::*; use serde::{Deserialize, Serialize}; use std::{ sync::{ mpsc::{channel, Receiver, Sender, TryRecvError}, Arc, Mutex, }, time::Duration, }; use tokio::time::{sleep, timeout}; use warp::{ filters::BoxedFilt...
true
a48fcb73c4d5cd47a3739242296cc544327d6913
Rust
llwt/aoc-2020
/src/bin/day4-2.rs
UTF-8
2,098
3.1875
3
[]
no_license
use aoc_2020::{is_int_between, is_valid_hex_color, read_aoc_input}; use itertools::Itertools; use phf::phf_map; use std::collections::HashMap; type Validator = fn(&str) -> bool; fn is_valid_height(v: &str) -> bool { match v.split_at(v.len() - 2) { (height, "cm") => is_int_between(height, 150, 193), ...
true
975c06fcc35090be15e3462880d455bb37cfd447
Rust
snorrwe/perplexio-backend
/src/model/participation.rs
UTF-8
2,033
2.546875
3
[]
no_license
use super::super::schema::game_participations; use crate::DieselConnection; use crate::model::user::User; use chrono::{DateTime, Utc}; use diesel::prelude::*; use diesel::update; use juniper::FieldResult; #[derive(Insertable)] #[table_name = "game_participations"] pub struct GameParticipation { pub user_id: i32, ...
true
2dae63c9ff79310f696bc9d9f6055af5758e0660
Rust
rhurkes/sware-server
/src/http_client.rs
UTF-8
2,474
3.015625
3
[]
no_license
use reqwest::blocking::{Client, Response}; use reqwest::header::{ACCEPT, USER_AGENT}; use reqwest::StatusCode; use serde::de::DeserializeOwned; use std::thread; use std::time::Duration; const APP_USER_AGENT: &str = "sigtor.org"; const MAX_RETRIES: usize = 3; pub struct HttpClient { client: Client, } impl HttpCli...
true
2cc5658ebc4c3102def353205515dd7b6e1c0ad1
Rust
godaddy-icfp/icfp-2020
/vendor/wasmparser/src/readers/table_section.rs
UTF-8
2,990
2.71875
3
[ "MIT" ]
permissive
/* Copyright 2018 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed...
true
3b8c7f011e02a896c6fd076ea62a7587b344681b
Rust
l4l/flow
/flowclib/src/generator/generate.rs
UTF-8
7,407
2.796875
3
[ "MIT" ]
permissive
use std::io::Result; use std::collections::HashMap; use std::fs::File; use std::io::prelude::*; use std::path::PathBuf; use std::collections::HashSet; use model::runnable::Runnable; use model::flow::Flow; use model::route::Route; use model::connection::Connection; use flowrlib::manifest::Manifest; #[derive(Serialize)]...
true
b1b050f426edae0ae667b1c0c940a0561f313940
Rust
endogeny/vulkano-framing
/src/buffer.rs
UTF-8
3,897
3.28125
3
[]
no_license
use std::error::Error as StdError; use std::fmt; use std::sync::Arc; use vulkano::buffer::{BufferAccess, CpuAccessibleBuffer}; use vulkano::buffer::cpu_access::{ ReadLock, WriteLock, ReadLockError, WriteLockError }; use framing::Image; /// Wraps a buffer, providing functions that allow the user to inte...
true
10aecb8a521522ab7a2cfda39a50773a1c5ac8c9
Rust
frondeus/Horust
/tests/utils/mod.rs
UTF-8
3,719
2.859375
3
[ "MIT" ]
permissive
use assert_cmd::prelude::*; use libc::pid_t; use nix::sys::signal::{kill, Signal}; use nix::unistd::Pid; use rand::distributions::Alphanumeric; use rand::{thread_rng, Rng}; use std::path::Path; use std::process::Command; use std::sync::mpsc; use std::thread; use std::time::Duration; use tempdir::TempDir; /// Creates s...
true
4beb5a93913b0bf1e0eeafa719b414036934b905
Rust
Happy-Ferret/pikelet
/src/syntax/pretty/core.rs
UTF-8
14,079
2.75
3
[ "Apache-2.0" ]
permissive
//! Pretty printing for the core syntax use moniker::{FreeVar, Var}; use pretty::Doc; use std::iter; use syntax::core::{Head, Literal, Neutral, Term, Value}; use syntax::raw; use syntax::{Label, Level}; use super::{parens, sexpr, StaticDoc, ToDoc}; fn pretty_ann(expr: &impl ToDoc, ty: &impl ToDoc) -> StaticDoc { ...
true
97e89469846bdb4502208823035b130b66ec5337
Rust
bwestlin/advent-of-code-2020
/rust/src/day08.rs
UTF-8
4,050
3.1875
3
[ "MIT" ]
permissive
extern crate utils; use std::env; use std::collections::HashSet; use std::str::FromStr; use std::num::ParseIntError; use std::io::{self, BufReader}; use std::io::prelude::*; use std::fs::File; use utils::*; type Input = Vec<Instruction>; #[derive(Eq, PartialEq, Copy, Clone, Debug)] enum OpCode { Nop, Acc, Jmp } ...
true
b7d682f1e253eaba2dbc43871821fdbb93144517
Rust
JaniM/katlang
/src/main.rs
UTF-8
3,047
2.609375
3
[ "MIT" ]
permissive
extern crate clap; extern crate itertools; extern crate termion; mod interpreter; mod parser; mod spec; mod term; use clap::{App, Arg}; use interpreter::{CatValue::VStack, ExecFrame, Interpreter}; use parser::Parser; use std::time::Instant; use term::run_term; fn print_frame(frame: ExecFrame, depth: usize) { pri...
true
0a8c2466b7ca8b6a46ed5ffcb4eeb99cde4c688c
Rust
sm921/pattern-making
/clothes/src/pattern/shirt/sleeve/sleeve.rs
UTF-8
578
2.546875
3
[]
no_license
use crate::pattern::{common::pattern::Pattern, measurements::Cm}; use super::short_sleeve::ShortSleeve; pub enum SleeveType { Short, } pub struct Sleeve { pub pattern: Pattern, } impl Sleeve { pub fn new( sleeve_type: SleeveType, sleeve_length: Cm, front_arm_hole: Cm, bac...
true
8548aca49f43fbd4794c57480d642e6c5cbe74c9
Rust
carrotflakes/kantera
/src/renders/clip.rs
UTF-8
1,031
2.671875
3
[ "MIT" ]
permissive
use crate::render::{Res, Render, RenderOpt}; use std::marker::PhantomData; pub struct Clip<T, R: Render<T>> { pub render: R, pub start: f64, pub end: f64, pub t: PhantomData<T> } impl <T, R: Render<T>> Render<T> for Clip<T, R> { fn sample(&self, u: f64, v: f64, time: f64, res: Res) -> T { ...
true
2918132d26fc714049e6f4c8089104319101b4ad
Rust
kapzyl/toggle_cool_cow_says_type
/src/main.rs
UTF-8
9,542
2.953125
3
[ "MIT" ]
permissive
use std::env::args; use tinybit::events::{events, Event, EventModel, KeyCode, KeyEvent, KeyModifiers}; use tinybit::render::RenderTarget; use tinybit::widgets::Text; use tinybit::{term_size, Color, Pixel, Renderer, ScreenPos, ScreenSize, StdoutTarget, Viewport}; mod config; mod error; mod gamestate; mod words; use c...
true
8b8993725d3a413ad9b74cad86192ea5c052041b
Rust
elmarco/libslirp-rs
/src/opt.rs
UTF-8
2,933
2.59375
3
[]
no_license
use std::net::{Ipv4Addr, Ipv6Addr}; use std::path::PathBuf; use structopt::StructOpt; #[derive(Debug, StructOpt)] pub struct OptIpv4 { /// Whether to disable IPv4 #[structopt(name = "disable-ipv4", long = "disable-ipv4")] pub disable: bool, /// IP network address that the guest will see #[structopt...
true
2595510aeec1f83bca77e0c509e3727a4dd40bf1
Rust
wkcn/leetcode
/1201-1300/1266-minimum-time-visiting-all-points.rs
UTF-8
623
3.390625
3
[]
no_license
struct Solution {} impl Solution { pub fn min_time_to_visit_all_points(points: Vec<Vec<i32>>) -> i32 { let mut ans = 0; for i in 0..points.len() - 1 { // 这里也等于取x或y绝对值的最大值 // max(dx.abs(), dy.abs()) let dx = (points[i + 1][0] - points[i][0]).abs(); let...
true
4ac38f48f1ec4d1f8fdac52dc19c83b45ac00a69
Rust
mgacek8/rust-clippy
/clippy_lints/src/needless_bitwise_bool.rs
UTF-8
3,112
3.015625
3
[ "MIT", "Apache-2.0" ]
permissive
use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::in_macro; use clippy_utils::source::snippet_opt; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; use rustc_session::{declare_lint_p...
true
aed8f7396db46e5f7795e03e2584c8cd998face0
Rust
l1212s-tee/MIRAI
/examples/taint/src/main.rs
UTF-8
290
2.625
3
[ "MIT" ]
permissive
extern crate taint_error; use std::sync::Arc; use taint_error::{source, use_arc, Foo}; fn use_arc_test() { let f: Foo = source(Arc::new([1, 2, 3])); // get tainted Foo let (_, sum) = use_arc(f); // use tainted Foo println!("sum = {}", sum); } fn main() { use_arc_test(); }
true
e2305e7b40c4b4b203400deac30907742e692a0f
Rust
ayazhafiz/slide
/libslide/src/parser/test_utils.rs
UTF-8
3,909
2.953125
3
[ "BSD-3-Clause" ]
permissive
#![cfg(test)] macro_rules! __parse { (parse_statements, $inout:expr) => {{ use crate::parser::parse_statements; use crate::scanner::scan; let inout: Vec<&str> = $inout.split(" => ").collect(); let pin = inout[0]; let pout = if inout.len() > 1 { inout[1].to_owned...
true
f2d19321dc37781aa212eab1ea930f3825737a83
Rust
input-output-hk/jormungandr
/jcli/src/jcli_lib/address.rs
UTF-8
5,560
2.828125
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::jcli_lib::utils::key_parser::parse_pub_key; use chain_addr::{AddressReadable, Discrimination, Kind}; use chain_crypto::{bech32::Bech32 as _, AsymmetricPublicKey, Ed25519, PublicKey}; use structopt::StructOpt; use thiserror::Error; #[derive(StructOpt)] #[structopt(name = "address", rename_all = "kebab-case")...
true
25e1f97e2c598709ba78cd67684b9233e644e2e4
Rust
CedN/rust_playground
/src/secret_number.rs
UTF-8
750
3.5
4
[]
no_license
use std::cmp::Ordering; use std::io; use rand::prelude::*; pub fn play() { let number = thread_rng().gen_range(1..101); println!("Try to guess my secret number:"); loop { let mut buffer = String::new(); io::stdin().read_line(&mut buffer).expect("Failed to read input line"); let...
true
89ded6b70b84b6809a6e4302cbe83f4247fb039e
Rust
shadowsocks/shadowsocks-rust
/crates/shadowsocks/src/dns_resolver/mod.rs
UTF-8
7,482
2.59375
3
[ "MIT" ]
permissive
//! Asynchronous DNS resolver #![macro_use] pub use self::resolver::{DnsResolve, DnsResolver}; mod resolver; #[cfg(feature = "trust-dns")] mod trust_dns_resolver; /// Helper macro for resolving host and then process each addresses #[macro_export] macro_rules! lookup_then { ($context:expr, $addr:expr, $port:expr,...
true
51134ee9e1a635cc54ea92717901a22c59318a3e
Rust
ngtkana/aribook
/crates/chap3_5/biparite_matching/src/main.rs
UTF-8
800
2.59375
3
[]
no_license
#![allow(clippy::many_single_char_names)] use proconio::input; fn main() { input!(a: usize, b: usize, m: usize, uv: [(usize, usize); m]); let mut dinic = chap3_5_dinic::Dinic::with_len(a + b + 2); let s = a + b; let t = a + b + 1; (0..a).for_each(|i| dinic.add_edge(s, i, 1)); (0..b).for_each(|i...
true
54a89cc0a9a3e9a8c2f4f88502f553ee8df5cd1b
Rust
maxverbeek/Blockchain-based-E-voting
/eVotingnode/code/milestone2/identity-iota/src/chain/document_chain.rs
UTF-8
4,504
2.640625
3
[]
no_license
// Copyright 2020-2021 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 use core::fmt::Display; use core::fmt::Error as FmtError; use core::fmt::Formatter; use core::fmt::Result as FmtResult; use identity_core::convert::ToJson; use crate::chain::DiffChain; use crate::chain::IntegrationChain; use crate::did::Docum...
true
7a4bebdd135dde3aaa8c1f502eaa923b239fb16e
Rust
ToruNiina/rustracer
/src/vector/fallback/vector3.rs
UTF-8
3,044
3.546875
4
[ "MIT" ]
permissive
#[derive(Debug, Copy, Clone, PartialEq)] pub struct Vector3 { values: [f32; 3], } impl Vector3 { pub fn new(x: f32, y: f32, z: f32) -> Vector3 { Vector3{values: [x, y, z]} } pub fn zero() -> Vector3 { Vector3{values: [0.0, 0.0, 0.0]} } pub fn len(self) -> f32 { self.len...
true
6e504bbb6e81216e5e5c7220ebefbba9f240274d
Rust
apognu/defcon
/src/model/specs/http/spec.rs
UTF-8
2,612
2.71875
3
[ "MIT" ]
permissive
use std::collections::HashMap; use anyhow::Result; use sqlx::{FromRow, MySqlConnection}; use crate::model::{ specs::{http::HttpHeaders, SpecMeta}, Check, Duration, }; #[derive(Debug, FromRow, Clone, Serialize, Deserialize)] pub struct Http { #[serde(skip)] pub id: u64, #[serde(skip)] pub check_id: u64, ...
true
7159fc6d2f9834cc7bd42fd866c8358ea5006538
Rust
rust-lang/rust
/tests/mir-opt/sroa/lifetimes.rs
UTF-8
700
2.59375
3
[ "Apache-2.0", "LLVM-exception", "NCSA", "BSD-2-Clause", "LicenseRef-scancode-unicode", "MIT", "LicenseRef-scancode-other-permissive" ]
permissive
// unit-test: ScalarReplacementOfAggregates // compile-flags: -Cpanic=abort // no-prefer-dynamic trait Err { type Err; } struct Foo<T: Err> { // Check that the `'static` lifetime is erased when creating the local for `x`, // even if we fail to normalize the type. x: Result<Box<dyn std::fmt::Display + ...
true
71a3c4d21deb51718742384c81ca8074dfb6ccdb
Rust
gnoliyil/fuchsia
/src/recovery/lib/recovery-ui/src/keys.rs
UTF-8
9,717
2.65625
3
[ "BSD-2-Clause" ]
permissive
// Copyright 2021 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. #[derive(PartialEq, Debug, Clone)] pub struct LetterKey { pub(crate) lower: &'static str, pub(crate) upper: &'static str, pub(crate) alt: &'sta...
true
7a475c80ea8954322fdc14e955799fab12010cd2
Rust
jgrazian/wgpu-raytracer
/src/aabb.rs
UTF-8
1,779
3.25
3
[ "MIT" ]
permissive
use glam::Vec3; pub trait Bounded: std::fmt::Debug { fn get_bounds(&self) -> AABB; } #[derive(Clone, Copy, Debug)] pub struct AABB { pub min: Vec3, pub max: Vec3, } #[derive(Debug)] pub enum Axis { X, Y, Z, } impl AABB { pub fn from_bounds(min: Vec3, max: Vec3) -> Self { AABB { m...
true
8cd891666f2310800bca7f4e0cb57e2ca2ae3b97
Rust
cottonsmithco/kvdata
/src/print.rs
UTF-8
463
3.578125
4
[]
no_license
pub fn run() { // print to console println!("hello from print"); //basic formatting println!("{} looks like {}", "ben", "neb"); //positional arguments println!("{0} is from {1} and {0} likes {2}", "ben", "lincoln", "music"); // named arguments println!("{name} likes {activity}", n...
true
1969058d9ce28780653039a2960e11c12ba9a75f
Rust
Nakamurus/rust_convert_big_latin
/convert_big_latin/src/main.rs
UTF-8
384
3.515625
4
[]
no_license
fn main() { let mut txt = String::from("first"); converter(txt); } fn converter(mut s: String) { let vowels = ['a', 'i', 'u', 'e', 'o']; let mut hay = String::from("-hay"); let head = &s.chars().nth(0).unwrap(); if vowels.contains(&head) == false { hay = format!("-{}ay", head); } ...
true
3093081682e648ee8c1d24cf43c014b1b711a56a
Rust
knarkzel/rogue-wii
/png-parser/src/main.rs
UTF-8
960
3.046875
3
[]
no_license
use std::fs; fn main() { // args let mut args = std::env::args().skip(1); let image_path = args.next(); let header_path = args.next(); if let (Some(image_path), Some(header_path)) = (image_path, header_path) { // image data let decoder = png::Decoder::new(fs::File::open(image_path)...
true
7d03ad8ead9d5aa4696651f3c760da9bd3bc22a8
Rust
BinaryBearzz/analog-multiplexer
/src/lib.rs
UTF-8
8,789
3.234375
3
[ "Apache-2.0" ]
permissive
#![no_std] //! This crate provides an interface, `Multiplexer` that makes it trivially easy //! to select channels on any given 74HC4051 or 74HC4067 series analog multiplexer. //! Internally it keeps track of each multiplexer's state, allowing you to //! check what channel is presently active or to enable/disable the m...
true
46142e8167c5f1ea9d6b26bfc2f479e8af44df3f
Rust
aidan-coward/rust
/project_euler/problem_15/src/try-3-main.rs
UTF-8
2,951
3
3
[]
no_license
fn main() { let mut list_routes: Vec<Vec<[u8; 2]>> = vec![vec![[0, 0]]]; let mut next_routes: Vec<Vec<[u8; 2]>> = Vec::new(); //let mut intermediate: Vec<[u8; 2]> = list_routes[0].clone(); let mut intermediate: Vec<[u8; 2]>; let mut none_counter: u8 = 0; let mut loop_counter: u64 = 0; /...
true
df3238881231e7cfdb7af56c203fc3dd80808b4d
Rust
maro525/rust-study
/ch3_expression/src/main.rs
UTF-8
428
3.921875
4
[]
no_license
fn main() { let x = five(); let y = { let x = 3; x + 1 }; let z = plus_one(44); println!("The value of x is: {}", x); println!("The value of y is: {}", y); println!("The value of z is: {}", z); iterate_num(); } fn five() -> i32 { 25 } fn plus_one(x: i32) -> i32 ...
true
653c91703284bf4b9760b697fef4c1e9a3abd84b
Rust
chrisvittal/aoc-2017
/src/bin/day10.rs
UTF-8
670
2.59375
3
[ "MIT" ]
permissive
extern crate aoc; use aoc::knothash::{self, KnotHash}; const INPUT: &'static str = "data/day10"; fn main() { let input = aoc::file::first_line(INPUT); let input_num: Vec<usize> = input.trim().split(",") .map(|b| b.parse().unwrap()).collect(); println!("1: {}", solve1(&input_num)); let length...
true
d9c3abfe2e1d51d8bb8508f96d2f668cfd7c6f52
Rust
IThawk/rust-project
/rust-master/src/test/ui/generator/drop-and-replace.rs
UTF-8
1,020
3
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// run-pass // Regression test for incorrect DropAndReplace behavior introduced in #60840 // and fixed in #61373. When combined with the optimization implemented in // #60187, this produced incorrect code for generators when a saved local was // re-assigned. #![feature(generators, generator_trait)] use std::ops::{Gen...
true
55f537d1519f853ab08b757b4fb7fc72eef1783d
Rust
sisso/test-unity3d-rust
/rust/game/src/client/mod.rs
UTF-8
2,112
3.203125
3
[ "MIT" ]
permissive
use std::net::{TcpStream, Shutdown}; use std::io::{Write, Read, Error, ErrorKind}; /// Read and write from a socket in non blocking mode with buffers #[derive(Debug)] pub struct SocketClient { stream: TcpStream, /// bytes to be send output_buffer: Vec<u8>, /// bytes to be taken input_buffer: Vec<u8...
true
481ca96e5da7af0c4ed772ddf1edc40639c2701f
Rust
timsuchanek/prisma-engines
/query-engine/query-engine/src/dmmf/schema/field_renderer.rs
UTF-8
1,823
2.875
3
[ "Apache-2.0" ]
permissive
use super::*; #[derive(Debug)] pub enum DMMFFieldRenderer { Input(InputFieldRef), Output(FieldRef), } impl<'a> Renderer<'a, DMMFFieldWrapper> for DMMFFieldRenderer { fn render(&self, ctx: &RenderContext) -> DMMFFieldWrapper { match self { DMMFFieldRenderer::Input(input) => self.render_...
true
67783e0ef7269870a6fcb0387f706dbda1d56065
Rust
AntonHermann/space_invaders
/src/game/systems/bullet_collision.rs
UTF-8
1,227
2.765625
3
[]
no_license
use specs::prelude::*; use game::components::*; pub struct BulletCollisionSystem; impl<'a> System<'a> for BulletCollisionSystem { type SystemData = ( ReadStorage<'a, Projectile>, ReadStorage<'a, Position>, ReadStorage<'a, EnemyFlag>, Entities<'a>, ); fn run(&mut self, (proj,...
true
8bd3e83aff1fc75948e026a3b62a9a788685429c
Rust
Berteun/rust-toy-list
/src/main.rs
UTF-8
380
2.9375
3
[]
no_license
#![allow(dead_code)] mod list; use list::List; fn main() { let mut list = List::single(1); list.append(List::single(2)); list.append(List::single(3)); list.append(List::single(4)); println!("List ({} elements): {}", list.length(), list); list.reverse(); println!("Reversed: {}", list); ...
true
79abded9f77e389988ad5a985f3d05336d84de94
Rust
Lol3rrr/waswolf
/statemachines/src/withstate.rs
UTF-8
3,393
3.09375
3
[]
no_license
use std::{future::Future, marker::PhantomData, sync::Arc}; use async_trait::async_trait; use crate::{AsyncTransition, TransitionResult}; /// Allows you to have some internal State that can be modified with each Transition attempt pub struct WithState<ARGUMENT, NEXT, STATE, CONTEXT, ERROR, TRANSITION, FUTURE> { t...
true
42572644702121883a18f86d1547638e02320ac1
Rust
bk-rs/rust-tls-client_hello
/tls-client_hello-parser/tests/parser.rs
UTF-8
2,537
2.515625
3
[ "Apache-2.0", "MIT" ]
permissive
use std::io::{self, Cursor, Write}; use rustls::internal::msgs::{ codec::Codec, enums::Compression, handshake::{ClientExtension, Random, SessionID}, }; use rustls::{CipherSuite, ProtocolVersion}; use tls_client_hello_parser::{ClientHelloPayload, ParseOutput, Parser, TLSError}; #[test] fn test_parse() -> ...
true
80f198d6a4f42cd09ea1548f19f2dbeca8f893c3
Rust
Scetch/fungui
/src/lib.rs
UTF-8
49,526
3.921875
4
[ "MIT", "Apache-2.0" ]
permissive
//! FunGUI is a UI layout system that seperates the description of the interface and //! the styling/layout. //! //! In FunGUI there are two main systems that come into play that the //! rest is built around: Nodes and Styles. //! //! # Nodes //! //! Nodes are used to describe the user interface without any information...
true
f705af3498d3c5f0ef368804948a2f1b87234434
Rust
oniproject/oni
/examples/testbed/src/components/input_buffer.rs
UTF-8
2,077
2.625
3
[ "MIT", "Apache-2.0" ]
permissive
use serde::{ ser::{Serialize, Serializer}, de::{Deserialize, Deserializer}, }; use specs::prelude::*; use std::fmt; use oni_reliable::{Sequence, SequenceOps}; #[derive(Component)] #[storage(DenseVecStorage)] pub struct InputBuffer { pub seq: Sequence<u8>, pub ack: [u64; 4], } macro wrd64($pos:expr) { ...
true
8325fc37eb193633a3a2802cb379ed75bd179fd0
Rust
m-kann0/atcoder-rust
/examples/aising2019_c.rs
UTF-8
3,642
3.34375
3
[]
no_license
use std::io::Read; fn main() { let mut buf = String::new(); std::io::stdin().read_to_string(&mut buf).unwrap(); let answer = solve(&buf); println!("{}", answer); } fn solve(input: &str) -> String { let mut iterator = input.split_whitespace(); let h: usize = iterator.next().unwrap().parse()....
true
9a2ab8a968c9fec6f2661d6571c37b630e4fa42b
Rust
mholub/raytracer
/src/scenes/random_spheres.rs
UTF-8
3,161
2.578125
3
[]
no_license
#![allow(dead_code)] #![allow(clippy::cast_precision_loss)] use crate::intersections::{MovingSphere, Sphere, World}; use crate::types::{Color, Point3, Vec3}; use crate::material::{Dielectric, Lambertian, Material, Metal}; use crate::random::{rand, rand_range}; use crate::scenes::Scene; pub fn scene() -> Scene { S...
true
f554ab7bb3c680fc86cb98131df0293b45f23f5d
Rust
artslob/pngme
/pngme/src/args.rs
UTF-8
1,965
3.078125
3
[ "MIT" ]
permissive
use ::clap::{AppSettings, Clap}; use std::path::PathBuf; #[derive(Clap)] #[clap(setting = AppSettings::ColoredHelp)] #[clap(version = env!("CARGO_PKG_VERSION"))] #[clap(about = "Utility that lets you hide secret messages in PNG files")] pub struct Opts { #[clap(subcommand)] pub(crate) sub_cmd: SubCommand, } #...
true
35788c7529283d7384c84750391824fa96833585
Rust
cithiLoe/exercism
/rust/luhn-trait/src/lib.rs
UTF-8
670
3.28125
3
[]
no_license
pub trait Luhn { fn valid_luhn(&self) -> bool; } impl<T: ToString> Luhn for T { fn valid_luhn(&self) -> bool { if self.to_string().chars().filter(|c| c.is_digit(10)).count() < 2 || self.to_string() .chars() .any(|c| !c.is_digit(10) && c != ' ') { ret...
true
0e4032084ddba42b1ee9d803112b5e9e70ec125c
Rust
ballpointcarrot/aoc-2020-rust
/src/day5.rs
UTF-8
1,246
3.140625
3
[]
no_license
use aoc_runner_derive::{aoc, aoc_generator}; #[aoc_generator(day5)] fn parse_input_day5(input: &str) -> Vec<String> { input.lines().map(|v| String::from(v)).collect() } #[aoc(day5, part1)] fn highest_pass(passes: &Vec<String>) -> usize { passes.iter().map(|p| pass_id(p)).max().unwrap() } fn pass_id(pass: &St...
true
1ec79e1f6d498920aee48eccecffbe8ad4528789
Rust
xpeerchain/xpeerchain
/common/metrics/src/unit_tests/lib_test.rs
UTF-8
2,068
2.640625
3
[ "Apache-2.0" ]
permissive
// Copyright (c) The XPeer Core Contributors // SPDX-License-Identifier: Apache-2.0 use super::super::*; use assert_approx_eq::assert_approx_eq; use lazy_static::lazy_static; use prometheus::{core::Collector, proto::MetricFamily, Counter, IntCounter, Opts, Registry}; use rusty_fork::{rusty_fork_id, rusty_fork_test, ru...
true
ab516e6f6c461438034fa78fc3068e1ba6add4ad
Rust
wasmerio/wasmer
/lib/wasm-interface/src/parser.rs
UTF-8
19,640
3.078125
3
[ "MIT" ]
permissive
//! Parsers to get a wasm interface from text //! //! The grammar of the text format is: //! interface = "(" interface name? interface-entry* ")" //! interface-entry = func | global //! //! func = import-fn | export-fn //! global = import-global | export-global //! //! import-fn = "(" "func" import-id param-list? resul...
true
922c123f45aa38192a5ab069de9ecb52f23acc4e
Rust
rust-lang/rust
/tests/ui/const-generics/generic_const_exprs/single-satisfied-ConstEvaluatable-in-probe.rs
UTF-8
587
2.546875
3
[ "Apache-2.0", "LLVM-exception", "NCSA", "BSD-2-Clause", "LicenseRef-scancode-unicode", "MIT", "LicenseRef-scancode-other-permissive" ]
permissive
// check-pass #![allow(incomplete_features)] #![feature(generic_const_exprs)] use std::marker::PhantomData; pub trait Bytes { const BYTES: usize; } #[derive(Clone, Debug)] pub struct Conster<OT> where OT: Bytes, [(); OT::BYTES]: Sized, { _offset_type: PhantomData<fn(OT) -> OT>, } impl<OT> Conster<O...
true
94dbcff26f89a6d7f246513200142d21aabfac52
Rust
Gopiandcode/rust-projects
/hashcode_2018/src/parser/mod.rs
UTF-8
3,109
2.703125
3
[]
no_license
use ::std::vec::Vec; use ::std::fs::File; use ::std::io::{Write, Read, Error, ErrorKind, BufReader, BufRead}; pub use hashcode_2018::problem::ride::Ride; pub use hashcode_2018::problem::Problem; pub fn read_input(name : &str) -> Problem { let mut input = File::open(format!("problems/{}.in", name)).expect("Could n...
true
3832a89e9b8646e637fbedfda844cde3893034c5
Rust
rust-lang/rustc-perf
/collector/compile-benchmarks/syn/syn_codegen/src/main.rs
UTF-8
30,761
2.578125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! This crate automatically generates the definition of the Visitor, //! VisitorMut, and Folder traits in `syn` based on the `syn` source. It //! discovers structs and enums declared with the `ast_*` macros and generates //! the functions for those types. //! //! It makes a few assumptions about the target crate: //! ...
true
c9d21deb432378f002def97cefa41921fdb6912d
Rust
internetghost0/terminal-notes
/src/main.rs
UTF-8
5,575
3.109375
3
[]
no_license
use std::env; use std::fs; use std::path::Path; use std::path::PathBuf; use std::process::Command; // change it static PATH: &str = "/home/USER/.local/share/notes"; // all notes will locate in this folder static EDITOR: &str = "/bin/vim"; // fn usage() { println!("Usage: ./notes [FLAG] <note>"); println!("Fla...
true
e58eec297235b6844900feb61b9860b2645eb2c2
Rust
RandyKonwalski/basic-webserver
/src/http.rs
UTF-8
1,582
3.1875
3
[]
no_license
enum HTTPMethod{ GET, POST, HEAD, PUT, PATCH, DELETE, TRACE, OPTIONS, CONNECT } pub struct HTTPResponseHeader{ header: String } impl HTTPResponseHeader{ pub fn new() -> HTTPResponseHeader{ HTTPResponseHeader{ header: String::new() } } pu...
true
f80501eb353e2d4d2fadcf7e58d5abe9dbca8d7c
Rust
LiquidityC/aoc
/2020/day_19/src/main.rs
UTF-8
4,436
3.265625
3
[]
no_license
use std::{collections::BTreeMap, error::Error}; use regex::Regex; type RuleMap = BTreeMap<u32, Rule>; #[derive(Debug, Clone)] struct Rule { id: u32, pattern: Option<String>, sub: Option<Vec<u32>>, alt: Option<Vec<u32>>, } impl std::str::FromStr for Rule { type Err = Box<dyn Error>; fn from_...
true
a2bccfc53987803fc7b89e0f71003fe2a9050524
Rust
yijie37/DaQiao
/bridge/parity-ethereum/accounts/ethstore/src/json/presale.rs
UTF-8
2,477
2.65625
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
0846d1418aa2897a1405d9dfe5a042cc4084dd06
Rust
blackspherefollower/buttplug-rs
/buttplug/src/device/protocol/wevibe.rs
UTF-8
7,255
2.546875
3
[ "BSD-3-Clause" ]
permissive
use super::{ButtplugDeviceResultFuture, ButtplugProtocol, ButtplugProtocolCommandHandler}; use crate::{ core::{ errors::ButtplugError, messages::{self, ButtplugDeviceCommandMessageUnion, DeviceMessageAttributesMap}, }, device::{ protocol::{generic_command_manager::GenericCommandManager, ButtplugProtoc...
true
61dca82ea676d5a7ec7dcf1ec92660fcec48632a
Rust
gnoliyil/fuchsia
/third_party/rust_crates/vendor/spki-0.5.4/src/error.rs
UTF-8
1,702
3.046875
3
[ "BSD-2-Clause", "MIT", "Apache-2.0" ]
permissive
//! Error types use core::fmt; use der::asn1::ObjectIdentifier; /// Result type with `spki` crate's [`Error`] type. pub type Result<T> = core::result::Result<T, Error>; /// Error type #[derive(Copy, Clone, Debug, Eq, PartialEq)] #[non_exhaustive] pub enum Error { /// Algorithm parameters are missing. Algorit...
true
8fe6b6710d7017416f03ba0ae72b75688cb12027
Rust
echizentm/repair
/src/main.rs
UTF-8
621
2.796875
3
[]
no_license
extern crate repair; use repair::repair::RePair; use repair::string_attractor::StringAttractor; use std::io; fn main() { loop { println!("input text to indicate string attractors:"); let mut input_text = String::new(); io::stdin() .read_line(&mut input_text) .expect...
true
6dc59c4bb20921c2c900f4cbf412c405d3a11186
Rust
Gogomoe/LeetCodeSolutions
/src/0273.rs
UTF-8
2,823
3.8125
4
[]
no_license
fn generate_digital(num: i32) -> String { String::from( match num { 1 => "One", 2 => "Two", 3 => "Three", 4 => "Four", 5 => "Five", 6 => "Six", 7 => "Seven", 8 => "Eight", 9 => "Nine", _ =...
true
4e273f3018710420eb50bd599c9aff61115a7aba
Rust
raftario/session-0sw
/src/selection.rs
UTF-8
1,129
2.84375
3
[ "Apache-2.0" ]
permissive
use rand::Rng; use crate::{creature::Creature, Opts}; impl Creature { pub fn select(creatures: &mut Vec<Self>, qty: usize, opts: &Opts, rng: &mut impl Rng) { let mut total_energy = 0.0; for c in creatures.iter() { total_energy += c.energy; } while creatures.len() < qty...
true
d80007e3f1538bdfdfdb2563804b9d0b605c4093
Rust
LukasKalbertodt/pingame
/src/players/mod.rs
UTF-8
840
2.984375
3
[]
no_license
use {Oracle, PinState}; mod human; mod random; mod stepper; pub use self::human::Human; pub use self::random::Random; pub use self::stepper::Stepper; /// Represents something that can solve the game. pub trait Player { /// Plays one complete game with a given oracle. /// /// The oracle knows the secret ...
true
dda2edfbedf99d7b042fb0e1b13bb14485c1c49d
Rust
laopo001/leetcode-rust
/src/detect_capital/mod.rs
UTF-8
512
3.09375
3
[]
no_license
struct Solution; impl Solution { pub fn detect_capital_use(word: String) -> bool { let mut res = true; let mut res2 = true; let mut res3 = true; for (i,c) in word.as_bytes().iter().enumerate() { if *c < ('a' as u8) { // 大写 if i > 0 { r...
true
46625a59aaef9835b9df7d6fc825722e77ca7d65
Rust
leudz/shipyard
/tests/iteration/non_packed.rs
UTF-8
12,428
2.78125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use shipyard::*; #[derive(PartialEq, Eq, Debug, Clone, Copy)] struct USIZE(usize); impl Component for USIZE {} #[derive(PartialEq, Eq, Debug, Clone, Copy)] struct U32(u32); impl Component for U32 {} #[derive(PartialEq, Eq, Debug, Clone, Copy)] struct I16(i16); impl Component for I16 {} #[test] fn basic() { let ...
true
bf834f58bcbfc2ebe1dedde6076908083ad5021e
Rust
AlexPikalov/cassandra-proto
/src/types/data_serialization_types.rs
UTF-8
18,929
2.546875
3
[ "MIT", "Apache-2.0" ]
permissive
use std::io; use std::net; use std::string::FromUtf8Error; use super::blob::Blob; use super::decimal::Decimal; use super::*; use crate::error; use crate::frame::FromCursor; use uuid; // https://github.com/apache/cassandra/blob/trunk/doc/native_protocol_v4.spec#L813 // Decodes Cassandra `ascii` data (bytes) into Rust...
true
67517201194ea112565243747572eb1f19a75abe
Rust
ryanlg/Bedrock
/x86_64/src/bios/bda.rs
UTF-8
210
2.71875
3
[]
no_license
/** Base address of the BDA */ const BDA_BASE: u16 = 0x0400; pub unsafe fn get_word_at_offset(offset: u16) -> u16 { let bda_base = BDA_BASE; let addr = (bda_base + offset) as *const u16; *addr }
true
ef1bf2461f9576a1f5876776da9dba240780269b
Rust
jamesmunns/bluepill
/src/bin/bin.rs
UTF-8
2,018
2.765625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Example application //! //! This shows all the parts that are required to build an application // We don't link to the `std` crate because it's not available for Cortex-M // devices. #![no_std] // Necessary to pull in `bkpt!()` #![feature(asm)] // We have to link our crate, obviously #[macro_use] extern crate de...
true
9ff446dc0e72874803b6245795ed06b4d6439e41
Rust
rust-lang/miri
/tests/fail/stacked_borrows/shared_rw_borrows_are_weak2.rs
UTF-8
632
2.515625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// We want to test that granting a SharedReadWrite will be added // *below* an already granted SharedReadWrite -- so writing to // the SharedReadWrite will invalidate the SharedReadWrite. //@normalize-stderr-test: "0x[0-9a-fA-F]+" -> "$$HEX" use std::cell::RefCell; use std::mem; fn main() { unsafe { let x...
true