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
62116e864f150bdd64b7e4f2e826a3c1325c4dfe
Rust
Jscorpio1611/ckb
/util/types/src/core/error.rs
UTF-8
1,444
2.890625
3
[ "MIT" ]
permissive
//! The error types to unexpected out-points. use crate::generated::packed::{Byte32, OutPoint}; use ckb_error::{prelude::*, Error, ErrorKind}; /// Errors due to the fact that the out-point rules are not respected. #[derive(Error, Debug, PartialEq, Eq, Clone)] pub enum OutPointError { /// The target cell was alrea...
true
997e5fcfd6f43dcfe10f84f24cb5f0dac2e00728
Rust
snsvrno/download-lp-rs
/src/lib.rs
UTF-8
3,002
3.09375
3
[]
no_license
extern crate reqwest; extern crate indicatif; #[macro_use] extern crate failure; use failure::Error; #[macro_use] extern crate log; use std::path::{ Path, PathBuf }; use std::fs; use std::io::prelude::*; mod tools; pub fn download<P:AsRef<Path>>(link : &str, path : P) -> Result<(String,usize),Error> where std::p...
true
13f5422a81cb9a5ffd3533cb2f2e0e20e617df4a
Rust
s-panferov/valico
/src/json_schema/validators/required.rs
UTF-8
768
2.546875
3
[ "MIT" ]
permissive
use serde_json::Value; use super::super::errors; use super::super::scope; #[allow(missing_copy_implementations)] pub struct Required { pub items: Vec<String>, } impl super::Validator for Required { fn validate( &self, val: &Value, path: &str, _scope: &scope::Scope, _: ...
true
aa0f9b8bb2286b97e86d37aa78d1b425c43b7787
Rust
brandon-chow/crustydb
/src/common/src/logical_plan/mod.rs
UTF-8
9,560
3.28125
3
[]
no_license
use crate::crusty_graph::{CrustyGraph, NodeIndex}; use crate::CrustyError; pub use logical_op::*; use serde_json::{json, Value}; use std::collections::HashMap; mod logical_op; use std::default::Default; use std::fmt; /// OpIndex is used to identify nodes in the LogicalPlan. pub type OpIndex = NodeIndex; /// Graph whe...
true
d4fe164703a7f4e045d378b89aa73fbd2c751ecc
Rust
Symmetric-Q/CryptaPath
/crush/src/algebra/test.rs
UTF-8
1,244
2.703125
3
[ "MIT" ]
permissive
use crate::algebra; #[test] fn solving_linear_system_test() { let m = matrix![vec![ vob![true, false, true, false], vob![false, true, true, true], vob![false, false, true, true], vob![false, false, false, true] ]]; let v = vob![true, false, true, true]; let sol = algebra...
true
5bd386e92a90f12b9e1f055db95187c34b2e81f9
Rust
cambricorp/rust-postgres-array
/src/impls/mod.rs
UTF-8
7,089
2.59375
3
[ "MIT" ]
permissive
use std::io::prelude::*; use byteorder::{ReadBytesExt, WriteBytesExt, BigEndian}; use postgres::{self, Error, Type, Kind, ToSql, FromSql, Oid}; use postgres::types::{IsNull}; use {Array, ArrayBase, DimensionInfo}; impl<T> FromSql for ArrayBase<Option<T>> where T: FromSql { fn from_sql<R: Read>(ty: &Type, raw: &m...
true
ae4397895bd2f1c2c7631123a968bf091d04c2b0
Rust
wangyanhai/calyx
/interp/src/environment.rs
UTF-8
4,864
3.15625
3
[ "MIT" ]
permissive
use super::primitives; use calyx::ir; use std::collections::HashMap; use std::rc::Rc; /// Stores information for updates. #[derive(Clone, Debug)] pub struct Update { /// The cell to be updated pub cell: ir::Id, /// The vector of input ports pub inputs: Vec<ir::Id>, /// The vector of output ports ...
true
228fc3ab71a6b704fc39077b164cd9aafb404775
Rust
intdxdt/bbox-2d
/src/mbr_tests.rs
UTF-8
12,893
2.765625
3
[]
no_license
use super::*; use math_util::round; use rstar::Envelope; use serde_json; #[test] fn test_construction() { let m_a: MBR = (0.5, 0.2).into(); let m_b: MBR = [0.5, 0.2].into(); assert!(m_a.equals(&m_b)); assert_eq!(m_a.as_tuple(), (0.5, 0.2, 0.5, 0.2)); assert_eq!(m_b.as_array(), [0.5, 0.2, 0.5, 0.2])...
true
3d132be9395b11e2ff009f807454b440e5f69b1a
Rust
Niedzwiedzw/minecraftrs
/mc/server/src/protocol/login.rs
UTF-8
995
2.640625
3
[]
no_license
use super::{ReadablePacket, WritablePacket, PacketResult, PacketError}; use crate::packet::serial::*; use std::io::Cursor; use uuid::Uuid; #[derive(Debug)] pub struct LoginStartPacket { pub username: String } impl ReadablePacket for LoginStartPacket { fn read_packet(mut src: Cursor<&Vec<u8>>) -> PacketResul...
true
67e7130eee1b14f87043a5abad403b26fc519c44
Rust
Eraden/tetris-rust
/src/app/tests/erase_full.rs
UTF-8
1,574
2.890625
3
[]
no_license
use app::tetris_game::*; use app::tests::utils::TestableApp; #[test] pub fn check_need_erase_one_line() { let mut app = TetrisGame::new(); app.test_inject_grid_line(19, &[1; 11]); app.remove_full_lines(); { let actual: [u8; 11] = app.test_current_grid_line(19); assert_eq!(actual, [0; 1...
true
f01e7529f357de69f5168e2682b9fb52140544e3
Rust
mickaelvieira/rustybot
/src/dom/url.rs
UTF-8
2,870
3.703125
4
[]
no_license
use url::Url; use regex::Regex; #[derive(Debug)] pub struct ParsedUrl { original: String, parsed: Url, } impl ParsedUrl { fn clean_chars(url: &str) -> String { url.trim() .replace("—", "-") .to_lowercase() } pub fn new(url: &str) -> ParsedUrl { ParsedUrl { ...
true
cf5d5a14043985c7113c8e4c9c27c8da27f238c6
Rust
cda-group/arcon
/arcon/src/data/arrow.rs
UTF-8
2,255
3.015625
3
[ "Apache-2.0" ]
permissive
use crate::table::MutableTable; use arrow::{ array::{ ArrayBuilder, BinaryBuilder, BooleanBuilder, Float32Builder, Float64Builder, Int32Builder, Int64Builder, StringBuilder, StructBuilder, UInt32Builder, UInt64Builder, }, datatypes::{DataType, Schema}, error::ArrowError, }; /// Represen...
true
bac3b58c78b0556dd344b34ac54db54dbaf7678b
Rust
Lucky4Luuk/minecraft-protocol
/src/network.rs
UTF-8
4,928
2.796875
3
[]
no_license
use crate::packets::{serializer::MinecraftPacketPart, VarInt}; use std::io::{Read, Write}; #[derive(Debug)] pub enum NetworkError { Custom(&'static str), Io(std::io::Error), } impl From<std::io::Error> for NetworkError { fn from(e: std::io::Error) -> Self { NetworkError::Io(e) } } impl From<&...
true
825bd9474b9745cee7e74b9a8bd442dc03161ca4
Rust
shigedangao/capoomobi
/src/core/configurator/builder.rs
UTF-8
3,854
3.296875
3
[]
no_license
/// Builder /// /// # Description /// Module use to manipulate the content of the .capoomobi.json /// /// # Info /// The .capoomobi.json has the following file format /// "projects": [ /// { /// "name": <project_name>, /// "path": <project_path> /// }, /// {...}, /// ], /// "current": <project_name> use s...
true
2208ced145b1a999da71580d40f4d78b6407e187
Rust
pyigyli/JRPG-engine
/src/tilemap/mod.rs
UTF-8
2,554
2.671875
3
[]
no_license
use ggez::graphics::{spritebatch, Image, DrawParam, Rect, draw}; use ggez::nalgebra::Point2; use ggez::{Context, GameResult}; use crate::globals::WINDOW_SIZE; pub mod tile; pub mod player; use crate::GameMode; use crate::transition::{Transition, TransitionStyle}; use crate::party::Party; use crate::battle::Battle; use ...
true
19f2b8eaf659c43af2ab7a66240a07386b4f4d02
Rust
fisherdarling/luther
/src/dfa.rs
UTF-8
4,646
3.734375
4
[]
no_license
use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; #[derive(Debug, Default, Clone, PartialEq, Eq)] pub struct DFA { rows: Vec<Row>, } impl DFA { fn new(rows: Vec<Row>) -> Self { Self { rows } } pub fn from_file(path: impl AsRef<Path>) -> Result<Self, Box<dyn std::error...
true
9e8901c6293a34823023da024df048974d86d7d1
Rust
zedseven/file-server
/src/main.rs
UTF-8
2,580
2.703125
3
[ "WTFPL" ]
permissive
//! A basic file server made with [Rocket](https://rocket.rs/) for serving up static files over HTTP. // Linting rules #![warn( missing_crate_level_docs, missing_docs, clippy::complexity, clippy::correctness, clippy::perf, clippy::style, clippy::suspicious, clippy::pedantic, clippy::filetype_is_file, clippy:...
true
78bd0d30a540b30d5dd8dcd59397f8a3b086f255
Rust
cptpcrd/simple_libc
/src/time.rs
UTF-8
4,490
2.828125
3
[ "MIT" ]
permissive
use std::io; use std::time::{Duration, SystemTime}; #[cfg(not(target_os = "netbsd"))] fn clock_gettime(clockid: libc::clockid_t) -> io::Result<Duration> { let mut timespec = libc::timespec { tv_sec: 0, tv_nsec: 0, }; crate::error::convert_nzero_ret(unsafe { libc::clock_gettime(clockid, &mu...
true
93f377cc28a0c2a01324c5249ac3ed8bfe4014a5
Rust
SirVer/point_cloud_viewer
/src/ply.rs
UTF-8
16,348
2.515625
3
[ "Apache-2.0" ]
permissive
// Copyright 2016 Google Inc. // // 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 to in...
true
1d03cd3855c0e78874da37d46bd18d144ad2377f
Rust
rumpl/drap
/src/bundle/store.rs
UTF-8
1,627
2.84375
3
[]
no_license
use crate::cnab::Bundle; use dirs; use std::path::{Path, PathBuf}; use walkdir::WalkDir; #[derive(Debug)] pub struct Reference { pub name: String, } #[derive(Debug)] pub struct StoreBundle { pub reference: Reference, pub bundle: Bundle, } impl Reference { pub fn named(n: &Path) -> Reference { ...
true
55752101a78d481b603f4b8d4f523dde3df99f15
Rust
acmumn/snack-card-reader
/barcodes/src/scancodes.rs
UTF-8
10,117
3.296875
3
[]
no_license
use num::FromPrimitive; use std::fmt::{Display, Formatter}; use std::fmt::Result as FmtResult; #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub enum Key { Esc = 1, Num1 = 2, Num2 = 3, Num3 = 4, Num4 = 5, Num5 = 6, Num6 = 7, Num7 = 8, Num8 = 9, Num9 = 10, ...
true
e703f166bbdc9da11bce94907a4564d95b8bdf04
Rust
AngelLandoni/Crystal
/crates/engine/src/graphics/shaders/mod.rs
UTF-8
484
2.71875
3
[]
no_license
use wgpu::ShaderModule; /// Defins the possibles shader sources. pub enum ShaderProvider { /// Default WGPU shader language. Wgsl(String), /// OpenGL shader language. Glsl(String), } pub enum ShaderStage { Vertex, Fragment, Compute } /// Defines the possible actions for a shader generato...
true
b3a90ad19ec20e64b3db8468f000cc999818651f
Rust
roberts-ivanovs/mermaid-to-code
/src/common.rs
UTF-8
810
2.8125
3
[ "MIT" ]
permissive
use crate::ast::{ASTAttribute, ASTClass, ASTFunction}; pub trait Parsable { fn imports(&self) -> &str; fn parse_class(&self, class: &ASTClass) -> String; fn parse_attribute(&self, attribute: &ASTAttribute) -> String; fn parse_function(&self, function: &ASTFunction) -> String; fn parse_type(&self, d...
true
b65575067d77201f1c91ca6aaf6af2bcf977ecf2
Rust
Tryweirder/doggy
/src/main.rs
UTF-8
1,413
3.125
3
[ "Apache-2.0" ]
permissive
use console::Term; use console::style; use std::io::*; mod usecases; use usecases::UseCase; fn main() { // temporal let test123 = usecases::items(); println!("{}", test123[0].id()); println!("{}", test123[0].name()); println!("{}", test123[0].description()); let output = test123[0].execute()...
true
6f3554b7ea2c1235ca2d1018dcb51038181b1496
Rust
tempbottle/probor
/rust/examples/search.rs
UTF-8
1,105
2.8125
3
[]
no_license
#[macro_use] extern crate probor; use probor::{Encoder, Encodable}; use probor::{Decoder, Config, decode}; use std::io::Cursor; probor_struct!( #[derive(PartialEq, Eq, Debug)] struct Page { url: String => (#0), title: String => (#1), snippet: Option<String> => (#2 optional), }); probor_struct!( #[derive(...
true
4a5d3dfbfd16c6d725004f0330d015cce3452b47
Rust
marti1125/culqi-rust
/src/culqi/charge.rs
UTF-8
5,549
2.515625
3
[ "MIT" ]
permissive
extern crate serde_json; use client::Client; use std::collections::HashMap; #[derive(Debug)] pub struct Charge { } impl Charge { //! # Examples //! //! ``` //! let client = culqi::Client::new("{KEY}"); //! ``` //! //! ``` //! let ref antifraud_details = culqi::AntifraudDetails::new("...
true
8796f2125a3ab714218df910136f07bec8c972d0
Rust
dgreid/crosvm
/common/sys_util/src/scoped_signal_handler.rs
UTF-8
14,869
2.78125
3
[ "BSD-3-Clause" ]
permissive
// Copyright 2021 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. //! Provides a struct for registering signal handlers that get cleared on drop. use std::convert::TryFrom; use std::fmt; use std::io::{Cursor, Write};...
true
a8937b2d37bbcbf91dcf86f9c02d61808e2a96ec
Rust
TheDan64/enum-methods
/src/getters.rs
UTF-8
11,177
2.53125
3
[ "Apache-2.0" ]
permissive
use crate::util::*; use syn::*; use syn::punctuated::Punctuated; use syn::token::{Comma, Paren}; use proc_macro::{Span, TokenStream}; pub(crate) fn impl_enum_as_getters(ast: &ItemEnum) -> TokenStream { let name = &ast.ident; let variant_names = variant_filter!(ast.variants => Unnamed) .filter(|v| v.fi...
true
9c60881c433f9d5dc337fb8e53e5898067467fef
Rust
gamma-delta/AOC-2020
/src/day17/mod.rs
UTF-8
724
2.828125
3
[ "Unlicense" ]
permissive
mod dimension3; mod dimension4; use anyhow::Result; const INPUT: &str = include_str!("input.txt"); #[test] fn part1() -> Result<()> { let mut dimension = dimension3::Dimension::new(INPUT)?; for _ in 0..6 { dimension.step(); } let active = dimension.get_world().len(); pri...
true
0ba785d9d3aaba9c9c9c0d33dc4ef81c9f2e325b
Rust
Coder-256/magic-numbers
/src/ops/float.rs
UTF-8
2,242
3.3125
3
[ "MIT" ]
permissive
use core::num::FpCategory; /// Operations for floating-point numbers. pub trait FloatCore { /// Returns positive infinity. fn infinity() -> Self; /// Returns negative infinity. fn neg_infinity() -> Self; /// Returns NaN. fn nan() -> Self; /// Returns `-0.0`. fn neg_zero() -> Self; ...
true
2c8a207698dac22582a923872920d61576faa82d
Rust
ssachtleben/battleship-rs
/src/models/player.rs
UTF-8
7,015
3.125
3
[]
no_license
use models::board::Board as Board; use models::fleet::Fleet as Fleet; use models::ship::Direction as Direction; use utils::stringutil as Stringutil; use ansi_term::Colour; use std::collections::LinkedList; use std::io::stdin; pub static BOARD_WIDTH: usize = 10; pub static BOARD_HEIGHT: usize = 10; pub struct Player ...
true
bc86df089ebe97917e33869c1b6fdf019b22edfc
Rust
Warhorst/record_sort
/tests/permutation_test.rs
UTF-8
581
2.53125
3
[]
no_license
extern crate record_sort; use record_sort::util::fac::fac; use record_sort::util::permutation::HeapPermutaionIterator; #[test] fn success() { let n: u64 = 3; let all_permutations = vec![ vec![1u8,2,3], vec![1,3,2], vec![2,1,3], vec![2,3,1], vec![3,2,1], vec![3,1...
true
a1fdd3cf502b44f6be510c96d662dddf55489bb5
Rust
stellar/slingshot
/spacesuit/src/cloak.rs
UTF-8
2,668
3.078125
3
[ "Apache-2.0" ]
permissive
use crate::bit_range::BitRange; use crate::shuffle::{padded_shuffle, value_shuffle}; use crate::value::AllocatedValue; use crate::{mix::k_mix, range_proof}; use bulletproofs::r1cs::{R1CSError, RandomizableConstraintSystem}; /// Enforces that the outputs are a valid rearrangement of the inputs, following the /// soundn...
true
0bad45bb45deec125ab87d02593bd9e5655703d8
Rust
joelarmstrong/aoc18
/src/aoc24.rs
UTF-8
12,687
3.046875
3
[]
no_license
use std::collections::HashMap; use std::collections::HashSet; use std::cmp::Reverse; use std::io; use std::io::BufRead; use std::u32; use regex::Regex; use rayon::prelude::*; use failure::{Error, format_err}; pub fn aoc24(part2: bool) -> Result<(), Error> { let mut armies = parse_armies(&mut io::stdin().lock())?; ...
true
4118270998c4c49ef6d4893f23c206aa2619e71e
Rust
loriopatrick/cartoon-upsample
/src/shape.rs
UTF-8
6,749
2.703125
3
[]
no_license
extern crate image; use image::Rgb; use quadtree::QuadTree; use models::Point; use imbin::ImBin; pub struct Shape { pub color: Rgb<u8>, pub parts: Vec<Box<QuadTree>>, pub area: f64, } impl Shape { pub fn take_shapes(option: &mut Option<Box<QuadTree>>, edges: bool) -> Vec<Shape> { let mut shap...
true
1794dfbd58eb3cea4a940a338f1092b137830888
Rust
erde74/som-rs
/som-interpreter-ast/src/class.rs
UTF-8
7,085
3.109375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::cell::RefCell; use std::fmt; use std::rc::{Rc, Weak}; use indexmap::IndexMap; use som_core::ast::{ClassDef, MethodBody}; use crate::method::{Method, MethodKind}; use crate::value::Value; use crate::{SOMRef, SOMWeakRef}; /// A reference that may be either weak or owned/strong. #[derive(Debug, Clone)] pub en...
true
12e4587c47d6f98cf8f78b0e3d41e30a61494093
Rust
myuon/atcoder
/abc097/src/bin/d.rs
UTF-8
3,238
3.109375
3
[]
no_license
use std::collections::{HashMap, HashSet}; #[macro_export] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let s = { use std::io::Read; let mut s = String::new(); ...
true
53f571003ef10b06b580e457c8ea5b64840f6a30
Rust
kwannoel/121-chat
/src/components/services/main_control/sender.rs
UTF-8
1,858
2.734375
3
[]
no_license
use log::{error, info}; use std::collections::HashMap; use std::time::Instant; use tokio::io::AsyncWriteExt; use tokio::net::tcp::OwnedWriteHalf; use tokio::sync::mpsc::Receiver; use uuid::Uuid; use super::messages::Message; pub async fn start( mut socket_write: OwnedWriteHalf, mut sender_event_receiver: Recei...
true
e1b13cbc0b6e46e2f5227e5e5ce57ce342b5db66
Rust
phlip9/rust-analyzer
/crates/thread_worker/src/lib.rs
UTF-8
1,905
3.046875
3
[ "MIT", "Apache-2.0" ]
permissive
//! Small utility to correctly spawn crossbeam-channel based worker threads. use crossbeam_channel::{bounded, unbounded, Receiver, Sender}; /// A wrapper around event-processing thread with automatic shutdown semantics. pub struct Worker<I, O> { // XXX: field order is significant here. // // In Rust, fiel...
true
65ffa6fc4aac1693a315f6b8ceb256a53b3f6b33
Rust
luojia65/opensbi-rt
/src/sbi/legacy.rs
UTF-8
3,955
2.875
3
[ "MIT" ]
permissive
//! [Legacy SBI Extension (v0.1)](https://github.com/riscv/riscv-sbi-doc/blob/master/riscv-sbi.adoc#legacy-sbi-extension-extension-ids-0x00-through-0x0f) #[inline(always)] fn sbi_call(which: usize, arg0: usize, arg1: usize, arg2: usize) -> usize { let ret; unsafe { llvm_asm!("ecall" : "={x1...
true
6d0129c206ce83d48e354b8790a4099b4bbe95c3
Rust
cyclopunk/werkflow
/crates/werkflow-agents/src/plugins.rs
UTF-8
4,412
2.78125
3
[ "MIT" ]
permissive
pub mod http { use anyhow::{anyhow, Result}; use log::debug; use werkflow_scripting::ScriptEnginePlugin; use werkflow_scripting::{to_dynamic, RegisterResultFn}; use werkflow_scripting::{Dynamic, EvalAltResult, Map}; use crate::{threads::AsyncRunner, work::SerMap}; pub struct Plugin; i...
true
af327d580c978c3492b82199bd99edd6d977e9b8
Rust
rust-lang/rust
/tests/ui/pattern/usefulness/doc-hidden-non-exhaustive.rs
UTF-8
875
2.734375
3
[ "Apache-2.0", "LLVM-exception", "NCSA", "BSD-2-Clause", "LicenseRef-scancode-unicode", "MIT", "LicenseRef-scancode-other-permissive" ]
permissive
// aux-build:hidden.rs extern crate hidden; use hidden::HiddenEnum; enum InCrate { A, B, #[doc(hidden)] C, } fn main() { match HiddenEnum::A { HiddenEnum::A => {} HiddenEnum::B => {} } //~^^^^ non-exhaustive patterns: `_` not covered match HiddenEnum::A { Hid...
true
b85b4f3cee508acf97419c30a1438a9fd94996ae
Rust
esbullington/cryptopals
/tests/set_two.rs
UTF-8
723
2.859375
3
[ "MIT" ]
permissive
extern crate cryptopals; use cryptopals::challenges::set_two::*; #[test] fn test_nine() { let unpadded = b"YELLOW SUBMARINE"; let padded = challenge_nine::pad_bytes(unpadded, 20, 0x04); assert_eq!("YELLOW SUBMARINE\x04\x04\x04\x04", String::from_utf8(padded).unwrap()); } #[test] fn challenge_ten() { ...
true
bdebed749aac5899e82ede08e67cea126e53b276
Rust
Origen-SDK/o2
/rust/origen_metal/src/ast/processors/to_string.rs
UTF-8
1,008
3.34375
3
[ "MIT" ]
permissive
//! This is used to implement the fmt::Display trait for nodes and is a //! good example of a simple AST processor use crate::ast::{node::Attrs, Node, Processor, Return}; use crate::Result; pub struct ToString<T> { indent: usize, output: String, // Had to use T somewhere in here to get it to compile, gave...
true
969805a6c284924dfa09f281038b24aba834b525
Rust
minioin/experiments
/pubsub/src/channel/multicast.rs
UTF-8
1,028
2.734375
3
[]
no_license
use std::{ net::{Ipv4Addr, UdpSocket}, time::Duration, }; use net2::UdpBuilder; use crate::channel::Channel; const MULTICAST_ADDR: &'static str = "233.255.255.255:20000"; pub struct MulticastNetwork { pub socket: UdpSocket, } impl Channel<Vec<u8>> for MulticastNetwork { fn send(&mut self, msg: Vec<u8>) { sel...
true
1cab6be67ba2c2959ad0d7375b3f2b7882272509
Rust
zeyonaut/mun
/crates/mun_compiler/src/diagnostics.rs
UTF-8
7,084
2.578125
3
[ "Apache-2.0", "MIT" ]
permissive
use mun_hir::diagnostics::DiagnosticSink; use mun_hir::{FileId, HirDatabase, Module}; use std::cell::RefCell; use crate::diagnostics_snippets; use annotate_snippets::{ display_list::DisplayList, formatter::DisplayListFormatter, snippet::Snippet, }; /// Emits all specified diagnostic messages to the given stream ...
true
230df2b2c4469fabd5c0570a4f594b3fefe32e57
Rust
Gelbpunkt/alpine-stockfish
/server.rs
UTF-8
1,060
2.875
3
[]
no_license
use std::net::{TcpListener, TcpStream}; use std::os::unix::io::{AsRawFd, FromRawFd, RawFd}; use std::process::{Command, Stdio}; use std::thread::spawn; fn handle_client(stream: TcpStream) { spawn(move || { stream.set_ttl(60).unwrap(); let fd: RawFd = stream.as_raw_fd(); let other = stream.t...
true
41d2cb7d467921eb051ad72c6452e9abe252b636
Rust
ZacharyGroff/Kattis
/1.4/SymmetricOrder.rs
UTF-8
1,555
3.453125
3
[]
no_license
fn main() { let mut set: u32 = 1; loop { let len: u32 = get_set_length(); if len == 0 { break; } let mut names: Vec<String> = get_set_names(len); names = sort_names(names); let (names1, names2) = split_names(names); let names = merge_names(names1, names2); print_set(names, set)...
true
47afc2f1604de6dfe1de00a545e4dadcaf99d275
Rust
EdsonAlcala/eth2-reward-simulation
/src/exporter/file_exporter.rs
UTF-8
1,640
3.109375
3
[ "Apache-2.0" ]
permissive
use super::config::*; use std::error::Error; use std::fs::File; use std::io::prelude::*; use std::path::Path; use crate::types::MonthlyReportRow; pub struct FileExporter { // TODO To make it generic rows: Vec<MonthlyReportRow> } impl FileExporter { pub fn new() -> FileExporter { let rows: Vec<MonthlyR...
true
f9fab6ad3f596d662346d8bab6905d2af6e7fbb0
Rust
Evergreenn/Itemgenerator
/src/main.rs
UTF-8
14,223
2.671875
3
[]
no_license
extern crate strum; // 0.10.0 #[macro_use] extern crate strum_macros; // 0.10.0 use strum::AsStaticRef; use rand::{ Rng, distributions::{WeightedIndex, Distribution, Standard}, }; const PLAYER_LEVEL:u8 = 20; #[derive(Debug, AsStaticStr, Clone, Copy)] enum WpnAilment { None, Poison, Stun, ...
true
aade43e897c31ef0b02f90c1f0fe8a8a7c2827dc
Rust
ramn/advent-of-code-rs
/src/day_05.rs
UTF-8
2,272
3.171875
3
[]
no_license
use std::fmt::Write; use std::collections::HashMap; use md5; const INPUT: &'static str = "uqwqemis"; const PAT: &'static str = "00000"; pub fn problem_1() -> String { let out = (0_usize..) .take(100000000) .map(|i| hex(&compute(i)[0..3])) .filter(|s| &s[0..5] == PAT) .map(|s| s.ch...
true
a58b34ec5476bd850c00eb28c633444aa8e6c349
Rust
nimalar/Advent-of-Code
/2021/day13.rs
UTF-8
1,511
3.078125
3
[]
no_license
use std::env; use std::fs::read_to_string; use std::collections::HashSet; fn fold(ref fold:(&str, usize), dots:HashSet<(usize, usize)>) -> HashSet<(usize, usize)> { let mut new_dots:HashSet<(usize, usize)> = HashSet::new(); for dot in dots.iter() { if fold.0 == "x" && dot.0 > fold.1 { new_dots.insert((dot.0 ...
true
1e9297747f23f7824b037531b3c1a791777e90ae
Rust
googleforgames/quilkin
/src/config/config_type.rs
UTF-8
5,549
2.828125
3
[ "Apache-2.0", "Unicode-DFS-2016", "BSD-3-Clause", "MPL-2.0", "CC0-1.0", "BSD-2-Clause" ]
permissive
/* * Copyright 2021 Google LLC * * 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 to i...
true
2f5ffbb201e39fc3f7b8ce4a89e6751590e349ff
Rust
murtyjones/birb
/crates/filing-parser/src/regexes/common/stock_based_compensation.rs
UTF-8
971
2.796875
3
[]
no_license
// regex use regex::{Regex, RegexBuilder}; lazy_static! { static ref PATTERN: &'static str = r" ^ \s* # sometimes there's whitespace before stock\s+based\s+compensation \s* # sometimes there's whites...
true
20ab668b289b91f9307442159c7af1e88cc4e888
Rust
zscaiosi/dprint
/crates/dprint/src/create_formatter.rs
UTF-8
7,899
2.96875
3
[ "MIT" ]
permissive
use dprint_core::plugins::{Formatter, Plugin}; use std::collections::HashMap; use super::configuration::{ConfigMapValue, ConfigMap}; use super::environment::Environment; pub fn create_formatter(config_map: ConfigMap, environment: &impl Environment) -> Result<Formatter, String> { let mut plugins = Formatter::new(g...
true
f42583986b5d48d09699e84da736006ec7a65613
Rust
inspier/stevia
/ast/src/terms/shift/logical_shift_right.rs
UTF-8
681
2.78125
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::expr::utils::BinTermExpr; mod marker { use crate::{ExprKind, ExprMarker}; #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct LogicalShiftRightMarker; impl ExprMarker for LogicalShiftRightMarker { const EXPR_KIND: ExprKind = ExprKind::LogicalShiftRight; } } /// Binar...
true
d91b7900c784c89e9f36694531dd74c7e94306e0
Rust
SeijiEmery/while-rs
/src/while_lang/ast/state.rs
UTF-8
786
3.359375
3
[]
no_license
use std::collections::HashMap; pub type Value = i64; pub type Variable = String; pub type VResult = Result<Value, String>; pub trait State { fn get (&self, var: &str) -> VResult; fn set (&mut self, var: &str, val: Value); } // Wrap HashMap but only provide our State's public interface pub struct HashState(Has...
true
033176ad0374a3c05435bf2b70dcc3c287508c4b
Rust
mrcodechef/posh
/dash/src/serialize/rpc.rs
UTF-8
3,047
3.046875
3
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
use super::{program, stream, Location}; use serde::{Deserialize, Serialize}; use std::path::PathBuf; #[derive(Serialize, Deserialize, PartialEq, Debug, Copy, Clone)] pub enum ClientReturnCode { Success, Failure, } #[derive(Serialize, Deserialize, PartialEq, Debug, Copy, Clone)] pub enum ClientLoadStatus { ...
true
f253ee77cd0cfed0a20d76d9fbdb21baf2c6713b
Rust
rminnich/rust-9p
/src/error.rs
UTF-8
10,933
3
3
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! 9P error representations. //! //! In 9P2000 errors are represented as strings. //! All the error strings in this module are imported from include/net/9p/error.c of Linux kernel. //! //! By contrast, in 9P2000.L, errors are represented as numbers (errno). //! Using the Linux system errno numbers is the expected beha...
true
cd861675254b9040c87a05c68f37c939662dcf1e
Rust
GopherSecurity/plonky
/src/gates/constant.rs
UTF-8
2,456
2.921875
3
[]
no_license
use std::marker::PhantomData; use crate::gates::Gate; use crate::{CircuitBuilder, HaloCurve, PartialWitness, Target, Wire, WitnessGenerator}; /// A gate which takes a single constant parameter and outputs that value. pub struct ConstantGate<C: HaloCurve> { pub index: usize, _phantom: PhantomData<C>, } impl<C...
true
45d187dbe7423ed97d90f89e44ad2a2fb12584c2
Rust
boneskull/wld
/src/models/house.rs
UTF-8
2,867
3.65625
4
[ "Apache-2.0" ]
permissive
use crate::{ enums::EntityType, models::Position, }; use scroll::{ ctx::{ SizeWith, TryFromCtx, TryIntoCtx, }, Endian, Error as ScrollError, Pread, Pwrite, LE, }; /// Represents NPC housing. /// /// See [Terraria Wiki: House] for more information. /// /// [Terraria Wiki: House]: https://t...
true
0060d6d8d1739145d622eedd85998df414cb6e1d
Rust
jackxbritton/game2
/server/src/main.rs
UTF-8
15,643
2.53125
3
[]
no_license
use futures::future::join_all; use generational_arena::{Arena, Index}; use nalgebra::Vector2; use std::env::args; use std::error::Error; use std::net::SocketAddr; use std::num::Wrapping; use std::time::Duration; use std::time::SystemTime; use tokio::net::{TcpListener, TcpStream, UdpSocket}; use tokio::prelude::*; use t...
true
21cac6fb8b6d13c872da65486c285e7368e1a60a
Rust
Akagi201/learning-rust
/misc/hellorust/src/main.rs
UTF-8
71
3.03125
3
[ "MIT" ]
permissive
fn main() { let rust = "Rust"; println!("Hello, {}!", rust); }
true
98227a0ca83a0b17625d84f79f0ac0aeac537704
Rust
robinhundt/bali-score
/src/balibase.rs
UTF-8
2,122
2.6875
3
[]
no_license
use std::fs::File; use std::io::BufReader; use std::path::Path; use anyhow::Result; use quick_xml::de::from_reader; use serde::Deserialize; use crate::{Alignment, Sequence}; pub fn parse(path: impl AsRef<Path>) -> Result<Alignment> { let bb_alignment = BBAlignment::from_xml_file(path)?; Ok(bb_alignment.into(...
true
9878149716c7c2bccad5032f06a04ae2de680b21
Rust
gzbakku/fdb
/cert/src/subject.rs
UTF-8
1,355
3.5
4
[ "MIT" ]
permissive
use std::collections::HashMap; #[derive(Debug, Clone)] pub struct Subject { pub common_name:String, pub org:String, pub location:String, pub state:String, pub country:String } impl Subject { pub fn new() -> Subject { Subject { country:String::new(), org:String:...
true
530a9ceb04c3a1c2027fe404f1f84dadb934e620
Rust
tib888/lcd-hal
/src/pcd8544/mod.rs
UTF-8
4,341
3.21875
3
[]
no_license
pub mod gpio; pub mod spi; use super::font; use super::Display; pub trait Pcd8544Base { type Error; fn command(&mut self, cmd: u8) -> Result<(), Self::Error>; fn data(&mut self, data: &[u8]) -> Result<(), Self::Error>; } pub enum Modes { Blank = 0b0001000, Normal = 0b0001100, Filled = 0b00010...
true
f1838ee1e32bbec10a4579875e726c8fefbbeb0a
Rust
Arunscape/ECE421
/assignments/assignment2/1.rs
UTF-8
213
3.21875
3
[]
no_license
#[derive(Debug)] struct Bag<T> { items: [T; 3], } fn main() { let b = Bag { items: [1, 2, 3] }; let b2 = Bag { items: [vec![1, 2, 3], vec![2], vec![4, 5, 6]] }; println!("{:?}", b); println!("{:?}", b2); }
true
a49886c4bf16ad44b4e7d42850d5ae1d63a35790
Rust
gcapizzi/expect
/src/matchers.rs
UTF-8
1,542
3.34375
3
[]
no_license
pub mod collection; pub mod option; pub mod path; pub mod result; pub mod string; use crate::{Description, Matcher}; /// Matches if `expected` is equal to the actual value. /// /// # Examples /// /// ``` /// # use expect::{expect, matchers::equal}; /// expect(&"foo").to(equal("foo")); /// expect(&"foo").not_to(equal(...
true
0507cd82e053e4ae957265a050850a450ff60d8c
Rust
favetelinguis/aaws
/src/main.rs
UTF-8
880
3.046875
3
[ "Apache-2.0" ]
permissive
use std::process::Command; use structopt::StructOpt; use std::thread; use std::sync::Arc; #[derive(StructOpt)] struct Cli { command: String, profiles: Vec<String> } fn main() { let args = Cli::from_args(); let mut handlers = vec![]; let command = Arc::new(args.command); for p in args.profiles ...
true
585e87462a6316b2b42e37cdb07feedeccf946ad
Rust
Luweiba/c10k
/src/bin/c10k_server_p.rs
UTF-8
1,182
2.625
3
[]
no_license
use tokio::net::{TcpListener, TcpStream}; use std::error::Error; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use std::sync::atomic::{AtomicU32, Ordering}; #[tokio::main] async fn main() -> std::io::Result<()> { let listener = TcpListener::bind("127.0.0.1:8080").await?; //let mut packet_cnt = AtomicU32::n...
true
8116af0bcd1d615cc4dfe40e6b78cb515852036a
Rust
ClementNerma/ReBackup
/examples/rules.rs
UTF-8
3,109
2.84375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! # Examples //! //! This file contains examples on how to write simple to complex rules for ReBackup's [walker](rebackup::walk). use rebackup::{WalkerItemType, WalkerRule, WalkerRuleResult}; use std::env; use std::ffi::OsString; use std::process::Command; /// Exclude the 'target' directory in Cargo projects pub fn...
true
d13877c79cb5d0b83b10b8fdae722f92d8abac80
Rust
brayniac/heatmap
/src/lib.rs
UTF-8
15,518
3.640625
4
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
//! Heatmap provides a time-series of Histograms, which is useful for //! recording distributions over time and reporting percentiles over time //! //! //! # Goals //! * pre-allocated datastructure //! * report time-series percentiles //! * auto-slicing by record time //! //! # Future work //! * more efficient serializ...
true
fa69cfb0f87b4cc4121e958283628a75734fb5ba
Rust
maxnelso/joustus
/src/main.rs
UTF-8
563
2.53125
3
[]
no_license
mod action; mod grid; mod card; mod tile; use crate::card::Arrow; use crate::card::Card; use crate::grid::Grid; fn main() { let mut grid = Grid::new("data/A.grid".to_string()); let mut c1: Card = Default::default(); c1.arrows[0] = Arrow::Single; let mut c2: Card = Default::default(); c2.arrows[0] ...
true
9a36ff02f9cd50b50d4ee3d680c2278eefc4957a
Rust
DevinR528/traycing
/src/main.rs
UTF-8
3,876
2.671875
3
[]
no_license
#![allow(unused)] use rand::random; use std::fs::OpenOptions; mod camera; mod material; mod ray; mod stuff; mod vec; use rayon::prelude::{IndexedParallelIterator, IntoParallelIterator, ParallelIterator}; use camera::Camera; use material::{Lambertian, Reflective}; use ray::Ray; use stuff::{Objects, Sphere}; use vec...
true
f7603d494447f4145308b7e60e28336ade604eff
Rust
despawnerer/langid-rs
/src/model.rs
UTF-8
2,684
3.296875
3
[ "MIT", "Apache-2.0" ]
permissive
use std::collections::HashMap; use itertools::Itertools; use rustc_serialize::json; use ngrams::ngrams; use errors::DeserializeError; pub struct Model { pub ngram_ranks: HashMap<String, usize>, } impl Model { pub fn build_from_text(text: &str) -> Self { let mut ngram_counts = HashMap::new(); ...
true
949f70a64ef95e15038261e9783a9749459c98d6
Rust
jkelleyrtp/specs_particles
/src/main.rs
UTF-8
4,810
2.59375
3
[]
no_license
#[cfg(not(target_arch = "wasm32"))] use { ocl, ocl::builders::ContextProperties, ocl::enums::ArgVal, ocl::{core, flags}, }; use rand::thread_rng; use specs::prelude::*; use specs_particles::{ components::{Position, Velocity}, simulation, }; use std::ffi::CString; fn run_test(num_agents: i64, ...
true
039847c8b2418351b94ae01c856b21d6d67525b8
Rust
JadeEyes/builder
/builder-test/src/main.rs
UTF-8
504
3.125
3
[]
no_license
use builder::Builder; #[derive(Debug)] struct X {} #[derive(Debug, Builder)] struct MyStruct<T, U> where T: Default, { a: u32, b: Option<&'static str>, c: String, #[builder(required)] d: X, e: T, #[builder(required)] f: U, } fn main() { let algo: MyStruct<i32, &str> = MyStruct...
true
5b23feee74ad7ab11418a88b9d1a0e3f9d702127
Rust
poyeker/petgraph-gen
/src/random_graph.rs
UTF-8
3,858
2.640625
3
[]
no_license
use petgraph::algo::*; use petgraph::prelude::*; use crate::classic::ToCompleteGraph; use crate::common::init_graph; use itertools::{repeat_n, Itertools}; use simple_rand::*; pub trait ToWattsStrogatzGraph<U: Clone> { fn to_watts_strogatz_graph(&mut self, k: usize, p: f64, weight: U); } impl<T, U: Clone> ToWatts...
true
84fea3d4d2e04c23f42b87ed3b84161ddcbbe9c6
Rust
crossterm-rs/crossterm-winapi
/src/semaphore.rs
UTF-8
1,258
2.65625
3
[ "MIT" ]
permissive
use std::{io, ptr}; use winapi::um::synchapi::{CreateSemaphoreW, ReleaseSemaphore}; use crate::{nonnull_handle_result, result, Handle}; /// A [Windows semaphore](https://docs.microsoft.com/en-us/windows/win32/sync/semaphore-objects). #[derive(Clone, Debug)] pub struct Semaphore(Handle); impl Semaphore { /// Con...
true
9fe562b67372f740f539d6695e4762033960c872
Rust
iwillspeak/ullage
/src/syntax/tree/types.rs
UTF-8
3,764
3.625
4
[ "MIT" ]
permissive
//! Syntax Types //! //! This module contians the structures used in the syntax tree to //! reference types. use super::super::text::{SourceText, Span, DUMMY_SPAN}; use super::super::{SepList, SyntaxNode}; use super::Token; use std::borrow::Cow; /// Type Reference /// /// Represents a reference to a type. This could ...
true
7bee2fb72135b03156cb2818ad529755827aabb6
Rust
steveyen/couchbase-shell
/src/cli/scopes_create.rs
UTF-8
2,073
2.9375
3
[ "Apache-2.0" ]
permissive
//! The `collections get` command fetches all of the collection names from the server. use crate::state::State; use couchbase::CreateScopeOptions; use crate::cli::util::bucket_name_from_args; use async_trait::async_trait; use log::debug; use nu_cli::{CommandArgs, OutputStream}; use nu_errors::ShellError; use nu_proto...
true
4735c36c3b2545eff333c0997fc04158c903eb84
Rust
gtk-rs/gir
/src/codegen/trait_impls.rs
UTF-8
6,960
2.734375
3
[ "MIT" ]
permissive
use std::io::{Result, Write}; use crate::{ analysis::{ functions::Info, special_functions::{Infos, Type}, }, codegen::general::{cfg_condition_no_doc, version_condition}, version::Version, Env, }; pub fn generate( w: &mut dyn Write, env: &Env, type_name: &str, functi...
true
72fbe7cf10c38723f132352035e54c7a1fecda98
Rust
mtvu/influxdb_iox
/generated_types/src/google.rs
UTF-8
13,461
2.734375
3
[ "MIT", "Apache-2.0" ]
permissive
//! Protobuf types for errors from the google standards and //! conversions to `tonic::Status` pub mod protobuf { pub use pbjson_types::*; } pub mod rpc { include!(concat!(env!("OUT_DIR"), "/google.rpc.rs")); include!(concat!(env!("OUT_DIR"), "/google.rpc.serde.rs")); } pub mod longrunning { include!...
true
fd346796daa1af9af51ebbeab68b7e58cf3feed7
Rust
iamahless/rust-course
/activities/src/bin/a9.rs
UTF-8
351
3.3125
3
[]
no_license
// Topic: Data management using tuples // // Requirements: // * Print whether the y-value of a cartesian coordinate is // greater than 5, less than 5, or equal to 5 // // Notes: // * Use a function that returns a tuple // * Destructure the return value into two variables // * Use an if..else if..else block to determi...
true
49b7e943eea309277a6960265a8e2409ad3951d2
Rust
baptistemanson/rust-pathfinder
/app/src/sprite_atlas.rs
UTF-8
4,497
2.828125
3
[ "MIT" ]
permissive
use wgputils::Vertex; use crate::algebra::{make_box, Vec2}; #[repr(C)] #[derive(Debug, Vertex, PartialEq)] pub struct SpriteVertex { pos: [f32; 2], uv: [f32; 2], z: [f32; 1], } #[derive(Debug, PartialEq)] pub struct Sprite { pub pos: Vec2, // in tiles dimension pub scale: f32, pub id_in_atlas...
true
79403e1ac23afddda84754673b84fab5a31db5d4
Rust
haochuan/advent-of-code
/2019/rust/problems/day1/src/lib.rs
UTF-8
1,374
3.640625
4
[]
no_license
use std::error::Error; use std::fs::File; use std::io::{BufRead, BufReader}; pub struct Input { pub filepath: &'static str, pub data: Vec<i32>, } impl Input { pub fn read_data(&mut self) -> Result<(), Box<dyn Error>> { let file = File::open(self.filepath)?; let reader = BufReader::new(file...
true
ec14c270f7f2c5505fb432351af1ac94fe2aeaec
Rust
happysalada/poem
/poem-openapi/src/types/external/floats.rs
UTF-8
2,118
2.640625
3
[ "Apache-2.0", "MIT" ]
permissive
use std::borrow::Cow; use poem::web::Field; use serde_json::{Number, Value}; use crate::{ registry::{MetaSchema, MetaSchemaRef}, types::{ ParseError, ParseFromJSON, ParseFromMultipartField, ParseFromParameter, ParseResult, ToJSON, Type, }, }; macro_rules! impl_type_for_floats { ($(($t...
true
f9930ca0273e38d312a2e30b6233e11f379a405b
Rust
franktea/leetcode-rust
/src/bin/0010.rs
UTF-8
2,590
3.59375
4
[]
no_license
#[derive(Debug)] enum Pattern { Char(char), // just char, or dot Wild(char), // char * Fill, // 只是占位 } impl Solution { pub fn is_match(s: String, p: String) -> bool { // 将pattern拆成一个数组,*和前面的一个字符一组,其它字符单独一组 // 从后往前拆 let mut patterns: Vec<Pattern> = Vec::new(); { ...
true
0a31347a0ddf50eb83e378eac85a592e8402a016
Rust
0Mayank/Mangakekw
/dex/src/creator/tests.rs
UTF-8
1,556
2.578125
3
[ "MIT" ]
permissive
use super::utils::DexWrappedObject; use super::CreatorTemplate; use std::fs; use std::path::Path; #[allow(dead_code)] fn load_test_responses() -> Vec<CreatorTemplate> { let path_to_test_respones = Path::new(".").join("example_responses").join("creator"); eprintln!("{}", path_to_test_respones.to_str().u...
true
b18c6dcf68323a47ebcd33ce429bf35dc4993a8b
Rust
stevedagiraffe/jank-bot
/src/main.rs
UTF-8
2,571
2.53125
3
[]
no_license
mod config; mod commands; mod utils; use commands::{general, music}; use songbird::SerenityInit; use std::{collections::HashSet, sync::Arc}; use serenity::{async_trait, framework::StandardFramework, http::Http, model::{gateway::Ready, id::ChannelId}, prelude::*}; use log::{self, LevelFilter}; use crate::{commands::m...
true
e5ebcba5f85a8b8f66ae483fc87a5952ef70066b
Rust
AlvinKuruvilla/rust-gedcom
/src/types/event.rs
UTF-8
2,130
3.5
4
[ "MIT" ]
permissive
use crate::types::SourceCitation; use std::{fmt, string::ToString}; #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug, PartialEq)] pub enum EventType { Adoption, Birth, Burial, Death, Marriage, Residence, SourceData(String), // "Other" is used to construct an event withou...
true
6bd2856b0b7d597c98e736ed21c60e2334a10154
Rust
IamNator/go-cosmwasm
/src/api.rs
UTF-8
4,190
2.609375
3
[ "Apache-2.0" ]
permissive
use cosmwasm_std::{Binary, CanonicalAddr, HumanAddr}; use cosmwasm_vm::{Api, FfiError, FfiResult, GasInfo}; use crate::error::GoResult; use crate::memory::Buffer; // this represents something passed in from the caller side of FFI // in this case a struct with go function pointers #[repr(C)] pub struct api_t { _pr...
true
6b6e487221acccce8e3daf537a49b629200aea9b
Rust
cualquiercosa327/pscontroller-rs
/examples/console.rs
UTF-8
2,117
2.65625
3
[ "Apache-2.0", "MIT" ]
permissive
extern crate linux_embedded_hal as linux_hal; extern crate embedded_hal; extern crate pscontroller_rs; use std::io; use std::{thread, time}; use linux_hal::Spidev; use linux_hal::spidev::{SpidevOptions, SPI_MODE_3}; use linux_hal::Pin; use pscontroller_rs::PlayStationPort; // Specific to the host device used on Linu...
true
b9a770f6be12dc6e503edc77529d34719e1cd233
Rust
cano159/animosity
/src/anim.rs
UTF-8
26,118
2.75
3
[ "Apache-2.0" ]
permissive
use std::convert::TryFrom; use std::io::{self, Read, Seek, SeekFrom, Write}; use std::iter; use std::sync::Mutex; use byteorder::{ReadBytesExt, WriteBytesExt, LE}; use ddsfile::{Dds, D3DFormat}; use failure::{Error, ResultExt}; pub struct Anim { layer_names: Vec<String>, sprites: Vec<SpriteType>, scale: u...
true
1a9e878f38072713f83edc2dd22164fe275c8b57
Rust
asomers/mockall
/mockall/tests/automock_foreign_c.rs
UTF-8
1,337
2.6875
3
[ "Apache-2.0", "MIT" ]
permissive
// vim: tw=80 #![deny(warnings)] use mockall::*; use std::sync::Mutex; #[automock] mod ffi { extern "C" { pub(super) fn foo(x: u32) -> i64; // Every should_panic method needs to operate on a separate method so it // doesn't poison other tests #[allow(dead_code)] pub(super) ...
true
f6993f4cc7d02cf03f34420ece0f769d6c6932f5
Rust
fredguile/rustycheckers
/src/board/coordinate.rs
UTF-8
1,170
3.3125
3
[]
no_license
#[derive(Debug, Copy, Clone, PartialEq)] pub struct Coordinate(pub usize, pub usize); impl Coordinate { pub fn on_board(self) -> bool { let Coordinate(x, y) = self; x <= 7 && y <= 7 } pub fn jumps_target_from(&self) -> impl Iterator<Item = Coordinate> { let mut jumps = Vec::new(); ...
true
dc00dc818ecaf257e61ee7a5e864c759dafa3c06
Rust
suhanyujie/siwei-note
/src/sdk/request.rs
UTF-8
1,503
2.890625
3
[]
no_license
extern crate http; extern crate reqwest; extern crate tokio; extern crate tokio_test; use std::collections::HashMap; use std::{fmt::format, time::Duration}; use http::header::{CONTENT_LENGTH, CONTENT_TYPE, HOST}; use http::HeaderMap; pub fn request() {} /// http post 请求 pub async fn post(url: &str, body: String, he...
true
1f7ab68d838a552ac59c6e14865ffecbb14aea0a
Rust
AkifumiSato/actix-web-demo
/src/usecase/tag_register_to_post.rs
UTF-8
514
2.640625
3
[]
no_license
use crate::usecase::error::DataAccessError; use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] pub struct InputData { pub post_id: i32, pub tag_id: i32, } pub trait RegisterTagPostDataAccess { fn register_tag_post(&self, post_id: i32, tag_id: i32) -> Result<(), DataAccessError>;...
true
477b994824862b0a2b1299d49ea9448ffcb7b607
Rust
google-apis-rs/generated
/gen/cloudiot/v1/cli/src/main.rs
UTF-8
9,794
2.640625
3
[]
no_license
use clap::{App, AppSettings, Arg, SubCommand}; use default_boxed::DefaultBoxed; #[derive(DefaultBoxed)] struct Outer<'a, 'b> { inner: HeapApp<'a, 'b>, } struct HeapApp<'a, 'b> { app: App<'a, 'b>, } impl<'a, 'b> Default for HeapApp<'a, 'b> { fn default() -> Self { let mut app = App::new("cloudiot1...
true
d3fdb2d8d7560f2ce93ea87b584c76aa00e00904
Rust
khvzak/libbluez-rs
/src/error.rs
UTF-8
903
2.84375
3
[ "MIT" ]
permissive
use std::{error, fmt}; use dbus; #[derive(Debug)] pub enum BtError { DBus(dbus::Error), DBusInternal(String), } impl From<dbus::Error> for BtError { fn from(err: dbus::Error) -> BtError { BtError::DBus(err) } } impl fmt::Display for BtError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt:...
true