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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
78d5c6103e8f76c6ca6fe309cd47b6a4747902d1 | Rust | pwoolcoc/tantivy | /src/termdict/mod.rs | UTF-8 | 16,294 | 3.15625 | 3 | [
"MIT"
] | permissive | /*!
The term dictionary main role is to associate the sorted [`Term`s](../struct.Term.html) to
a [`TermInfo`](../postings/struct.TermInfo.html) struct that contains some meta-information
about the term.
Internally, the term dictionary relies on the `fst` crate to store
a sorted mapping that associate each term to its ... | true |
704005eed020bb85534ce32111c4b12089e0ddd4 | Rust | lempiy/Kottans-Pizza-Api | /api/src/routes/middlewares.rs | UTF-8 | 2,699 | 2.5625 | 3 | [] | no_license | use iron::{status, IronError, IronResult, Request, Response};
use iron::headers::{Authorization, Bearer, ContentType};
use iron::{AfterMiddleware, BeforeMiddleware};
use std::sync::{Arc, Mutex};
use utils::types::StringError;
use utils::jwt::check;
use iron::modifiers;
use redis::Connection;
pub struct JsonAfterMiddle... | true |
45ab10155dc2b28f673d1ab7d3a9c890abbd2f45 | Rust | u-root/cpu | /p9cpu/crates/9p/src/error.rs | UTF-8 | 9,588 | 2.90625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] | 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 |
02fe386bdf350bad0ec9c2aa3d44065a23e1a868 | Rust | yangfengzzz/vox_render-rs | /src/local_to_model_job.rs | UTF-8 | 58,017 | 2.703125 | 3 | [
"MIT"
] | permissive | /*
* // Copyright (c) 2021 Feng Yang
* //
* // I am making my contributions/submissions to this project solely in my
* // personal capacity and am not conveying any rights to any intellectual
* // property of any third parties.
*/
use crate::skeleton::Skeleton;
use crate::simd_math::{Float4x4, SimdFloat4};
use c... | true |
9cececb00fc24ae268b2919a56db9fa0a8e844dc | Rust | HermannDppes/sprechzeiten | /src/time.rs | UTF-8 | 4,166 | 3.328125 | 3 | [] | no_license | use std::cmp::{Ord, Ordering};
/// A day of the week (Mon – Fri, since noone can be reached on the weekend).
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
pub enum Day {
Mon,
Tue,
Wed,
Thu,
Fri,
}
#[derive(Debug)]
pub enum WeekendError {
Sat,
Sun,
}
impl Day {
// TODO: This should possibly be an implementatio... | true |
1179cfe8b6fb2f44372185f3e53a1877277076e1 | Rust | NalbertLeal/rust-files-xor | /src/main.rs | UTF-8 | 2,945 | 3.09375 | 3 | [] | no_license | use std::io;
use std::io::prelude::*;
use std::fs;
use std::fs::File;
use std::env;
use std::process;
extern crate regex;
fn get_args_vector() -> Vec<String> {
let mut pure_args = env::args();
let mut args: Vec<String> = Vec::new();
loop {
if pure_args.len() == 0 {
break
}
let a: String = pur... | true |
e0d005c17c5c2d2af134d7aea31aa5ce8b1eff21 | Rust | pnadon/aoc | /y2019/day_3/src/main.rs | UTF-8 | 1,037 | 3.046875 | 3 | [
"Apache-2.0"
] | permissive | use std::env;
use std::fs::File;
use std::io::{Error, Read};
mod day_3;
use day_3::{find_min_intersection, find_min_travel, Move, Point};
fn parse_list(fname: &str) -> Result<Vec<Point>, Error> {
let mut contents = String::new();
File::open(fname)?.read_to_string(&mut contents)?;
let moves: Vec<Move> = co... | true |
5e8ad7b485ffd7618059e2ebb5172f0c30aecec1 | Rust | maham/advent_2020_rust | /src/bin/day_seven.rs | UTF-8 | 4,858 | 3.09375 | 3 | [] | no_license | use std::{fs, env};
use itertools::Itertools;
use time::OffsetDateTime;
use std::collections::HashMap;
struct Bag<'a> {
color: &'a str,
capacity: Vec<(usize, usize)>
}
impl<'a> Bag<'a> {
fn new(data: &'a str, bag_ids: &HashMap<&str, usize>) -> Self {
let color = extract_bag_color(data);
le... | true |
dec29d997f5e92d92e5d3e2893fb07105247c8e9 | Rust | hongweixiao/for_offer | /src/stack_min_022.rs | UTF-8 | 1,230 | 3.390625 | 3 | [] | no_license | struct Stack {
bucket_all: Vec<i32>,
bucket_min: Vec<i32>,
}
impl Stack {
fn new() -> Self {
Stack {
bucket_all: vec!(),
bucket_min: vec!(),
}
}
fn push(&mut self, val: i32) {
self.bucket_all.push(val);
if !self.bucket_min.is_empty() {
if self.min().unwrap() > val {
self.bucket_min.push(... | true |
420964964745e70fd60ffced217f06cc10243308 | Rust | Tristan971/advent-of-code-2020 | /src/bin/day10/main.rs | UTF-8 | 2,333 | 3.0625 | 3 | [] | no_license | use std::collections::{HashMap, HashSet};
use std::ops::{Add, Mul};
use rug::{Float, Integer};
use advent_of_code_2020::common::inputs;
fn main() {
// official
run_for_input("src/bin/day10/input");
// both probably wrong due to bigint stuff
// big100k
//run_for_input("src/bin/day10/big_input_100... | true |
5f5a106bdbda5b8c4848b66399f128061a6f1cd0 | Rust | sidred/palette | /src/matrix.rs | UTF-8 | 4,407 | 3.140625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | //!This module provides simple matrix operations on 3x3 matrix to aid in chromatic adaptation and
//!conversion calculations.
use num::Float;
use std::marker::PhantomData;
use {Xyz, Rgb};
use white_point::WhitePoint;
///A 9 element array representing a 3x3 matrix
pub type Mat3<T> = [T;9];
///Multiply the 3x3 matri... | true |
6f87c04170918543ef500d23d1c4c4e456528c98 | Rust | mxryan/minefinder2 | /src/cell.rs | UTF-8 | 1,062 | 3.3125 | 3 | [] | no_license | #[derive(Debug, PartialEq)]
pub enum CellState {
Hidden,
Revealed,
Flagged,
}
#[derive(Debug)]
pub struct Cell {
pub neighboring_mines: i32,
pub state: CellState,
pub has_mine: bool,
}
impl Cell {
pub fn e() -> Cell {
Cell {
neighboring_mines: 0,
state: Cell... | true |
274909b243d6d3ad2c68b35de203df2a019d5661 | Rust | eric7237cire/rgb_delivery | /rgb-solver/src/solver/structs/grid_connections_using_edges.rs | UTF-8 | 7,374 | 2.90625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use bitvec::{BigEndian, BitVec};
use crate::solver::structs::{Direction, CellIndex, ALL_DIRECTIONS};
use crate::solver::structs::Direction::*;
use crate::solver::structs::direction::get_adjacent_index;
#[derive(Clone, Default)]
pub struct GridConnections {
is_connected: BitVec<BigEndian, u8>,
num_rows: usize,
... | true |
e497a9ce09434888ea4d9d75c2d85ae064d467cd | Rust | ia7ck/competitive-programming | /AtCoder/abc242/src/bin/e/main.rs | UTF-8 | 1,170 | 2.71875 | 3 | [] | no_license | use scanner_proc_macro::insert_scanner;
#[insert_scanner]
fn main() {
let t = scan!(usize);
for _ in 0..t {
let n = scan!(usize);
let s = scan!(String);
solve(n, s);
}
}
fn solve(n: usize, s: String) {
let mo = 998244353_u64;
let mut dp = vec![0; n + 1];
dp[0] = 1;
... | true |
3d9efd4b909ae2c187c9f43fc6345cae7a2b6309 | Rust | RustyYato/compiler | /tools/lib-arena/src/local.rs | UTF-8 | 1,684 | 3.390625 | 3 | [] | no_license | use std::cell::UnsafeCell;
pub struct LocalArena<T> {
data: UnsafeCell<Vec<Vec<T>>>,
}
impl<T> Default for LocalArena<T> {
fn default() -> Self {
Self::new()
}
}
impl<T> LocalArena<T> {
pub const fn new() -> Self {
Self {
data: UnsafeCell::new(Vec::new()),
}
}
... | true |
96cadf67e64efc75f5c816205dac6f94ed38685a | Rust | passcod/blograph | /native/post/src/capitalise.rs | UTF-8 | 1,290 | 3.875 | 4 | [
"ISC",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | pub fn capitalise(source: &str) -> String {
let mut chars = source.chars();
match chars.next() {
Some(first) => first
.to_uppercase()
.collect::<String>()
+ chars.as_str(),
None => String::new()
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
... | true |
63eb226c719df9d71ec1e968c727352a8bcc99a7 | Rust | thenewwazoo/lpc177x_8x | /src/usb/eotintset/mod.rs | UTF-8 | 29,912 | 2.796875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::EOTINTSET {
#[doc = r" Writes to the register"]
#[inline]
pub fn write<F>(&self, f: F)
where
F: FnOnce(&mut W) -> &mut W,
{
let mut w = W::reset_value();
f(&mut w);
self.register.s... | true |
5d5106ddb91953fc803d4b2d1f034851c71959ab | Rust | LiveSplit/livesplit-core | /src/layout/layout_state.rs | UTF-8 | 1,516 | 2.984375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use super::{ComponentState, LayoutDirection};
use crate::{
platform::prelude::*,
settings::{Color, Font, Gradient},
};
use serde_derive::{Deserialize, Serialize};
/// The state object describes the information to visualize for the layout.
#[derive(Default, Serialize, Deserialize)]
pub struct LayoutState {
... | true |
f7d62a85d54350b326182cb3abeb3a16caae9384 | Rust | jtimon/rustlnd | /src/argman.rs | UTF-8 | 14,513 | 3.125 | 3 | [
"MIT"
] | permissive |
use std::collections::HashMap;
use std::env;
#[derive(Debug)]
enum ArgType {
ArgBool,
ArgMultistr,
ArgMapStr,
ArgStr,
}
#[derive(Debug)]
struct ArgumentHelp {
description: String,
arg_type: ArgType,
default: Option<String>,
default_multi: Vec<String>,
default_map: HashMap<String, ... | true |
8c4bb3ec2ce7a1cbfb57dbfd6aa00eaa2578bfb3 | Rust | DanielDahlJuhl/unions-aoc2020 | /snoothy/rust_aoc2020/src/aoc/t02.rs | UTF-8 | 1,631 | 3.3125 | 3 | [] | no_license | use super::util;
#[derive(Debug)]
struct Password {
min: u32,
max: u32,
letter: char,
code: String
}
impl From<&String> for Password {
fn from(item: &String) -> Self {
let input : Vec<&str> = item.split_whitespace().collect();
let values: Vec<&str> = input[0].split_ter... | true |
0e4c33f6f7d1ca30bb1d9e66890f3b9959887d7b | Rust | svevang/open-analytics | /src/app.rs | UTF-8 | 1,355 | 2.578125 | 3 | [] | no_license | use r2d2;
use db;
use iron;
use iron::Request;
use iron::BeforeMiddleware;
use std::sync::Arc;
use std::env;
use std::process;
pub struct App {
pub database: db::Pool,
}
impl App {
pub fn new() -> App {
let db_config = r2d2::Config::builder()
.pool_size(10)
... | true |
9d75a6f9b4f0b7eb76f92b0b6f223c8f5c7fa95f | Rust | hiddenmemory/crdt | /src/set/pnset.rs | UTF-8 | 9,968 | 3.34375 | 3 | [
"Apache-2.0"
] | permissive | use std::cmp::Ordering::{self, Equal, Greater, Less};
use std::collections::hash_map::{self, HashMap};
use std::hash::Hash;
#[cfg(any(quickcheck, test))]
use quickcheck::{Arbitrary, Gen};
use {Crdt, ReplicaId};
use pn::Pn;
/// A counting add/remove set.
#[derive(Clone, Debug)]
pub struct PnSet<T>
where
T: Eq + H... | true |
adebd51818fb289e9301aa3d7881c7191c267310 | Rust | pastleo/rs-wasm-glife | /src/main.rs | UTF-8 | 486 | 2.859375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | mod hello;
mod universe;
use universe::Universe;
fn main() {
hello::hello();
println!("");
let mut universe = Universe::new(8, 8);
println!("universe:\n{}", universe);
println!("universe.get_index(1,3) = {}", universe.get_index(1,3));
println!("universe.get(1,3) = {}", universe.get(1,3));
... | true |
f3eaf1f9f298663c0e31a0016bfeffcbe09d8ea4 | Rust | amosleeday/Team3 | /projects/lesson-2/runtime/src/substratekitties.rs | UTF-8 | 4,123 | 2.5625 | 3 | [
"Unlicense"
] | permissive | //reference:
// https://www.shawntabrizi.com/substrate-collectables-workshop/#/zh-cn/2/refactoring-our-code
use support::{
decl_storage,
decl_module,
StorageValue,
StorageMap,
dispatch::Result,
ensure,
decl_event
};
use system::ensure_signed;
use sr_primitives::{
traits::{
Zero, Hash
}... | true |
ea8e7d992f394aa0afc1af996d5b959678b15b37 | Rust | EFanZh/LeetCode | /src/problem_0856_score_of_parentheses/mod.rs | UTF-8 | 430 | 3 | 3 | [] | no_license | pub mod iterative;
pub mod recursive;
pub mod recursive_2;
pub trait Solution {
fn score_of_parentheses(s: String) -> i32;
}
#[cfg(test)]
mod tests {
use super::Solution;
pub fn run<S: Solution>() {
let test_cases = [("()", 1), ("(())", 2), ("()()", 2), ("(()(()))", 6)];
for (s, expected... | true |
899350dcead4c4fdd65e0aae00d95309e850cd19 | Rust | tercen/rustson | /src/deser.rs | UTF-8 | 12,172 | 2.765625 | 3 | [] | no_license | use std::io::Read;
use std::ptr::slice_from_raw_parts_mut;
use std::slice;
use byteorder::{ByteOrder, LittleEndian};
use super::*;
pub trait Reader {
fn read_all(&mut self, buf: &mut Vec<u8>) -> TsonResult<()>;
fn read_u8(&mut self) -> TsonResult<u8>;
fn read_i8(&mut self) -> TsonResult<i8>;
fn read_u... | true |
9c4b08f4104633f8858e71f172e116c25590e50c | Rust | shirts/double | /src/lib.rs | UTF-8 | 1,423 | 3.25 | 3 | [
"MIT"
] | permissive | //! Double is a fully-featured mocking library for mocking `trait`
//! implementations.
//!
//! The `Mock` struct tracks function call arguments and specifies return
//! values or function overrides.
//!
//! # Examples
//!
//! ```
//! #[macro_use]
//! extern crate double;
//!
//! // Code under test
//! trait BalanceShe... | true |
906537a1379e586fefca1f1e4dd2e36de77efdf1 | Rust | bouzuya/rust-atcoder | /cargo-atcoder/contests/abc308/src/bin/e.rs | UTF-8 | 1,250 | 2.921875 | 3 | [] | no_license | use std::collections::HashSet;
use proconio::{input, marker::Chars};
fn main() {
input! {
n: usize,
a: [usize; n],
s: Chars,
};
let mut map_x = vec![0_usize; 3];
for (s_i, a_i) in s.iter().copied().zip(a.iter().copied()) {
if s_i != 'X' {
continue;
... | true |
74fe13acb94f7e77e25a863d72a5ad2c9c44aeeb | Rust | foozzi/deadwiki | /src/markdown.rs | UTF-8 | 4,415 | 3.28125 | 3 | [
"MIT"
] | permissive | //! Convert wiki Markdown to HTML.
//!
//! Supports two syntax extensions:
//!
//! - [Page] to link directly to a wiki page.
//! - #tag to link to a hashtag.
//!
use {crate::db::DB, linkify::LinkFinder, pulldown_cmark as markdown, std::borrow::Cow};
/// Convert raw wiki Markdown into HTML.
/// Takes a list of all wik... | true |
3a6bfa616ff74181141c055a122508a8543bc5a7 | Rust | synlestidae/rust-huff | /src/main.rs | UTF-8 | 433 | 2.578125 | 3 | [] | no_license | use std::env;
mod tree;
mod algorithm;
mod front;
fn main() {
let mut args : Vec<_> = env::args().collect();
let usage = format!("Usage: input_file");
if args.len() == 2 {
println!("Compressing... {}", args[1]);
front::compress_file(args[1].clone());
}else if args.len() == 3 {
println!("Decompressing {}...... | true |
49a3a1b1c07f2ea33103f333b9ffc5ec91c1323b | Rust | Goncalerta/tiff-encoder | /src/file.rs | UTF-8 | 6,096 | 3.28125 | 3 | [
"MIT"
] | permissive | use std::fs;
use std::io;
use std::path::Path;
use crate::ifd::{AllocatedIfdChain, IfdChain};
use crate::write::{Cursor, EndianFile, Endianness};
/// Representation of a Tagged Image File.
///
/// This is the central structure of the crate. It holds all the other structures
/// of the TIFF file and is responsible for... | true |
922ee7b9ce4279ef8df166c3fde9351437c5d0d8 | Rust | falsovsky/advent2020 | /advent2020/src/day02.rs | UTF-8 | 1,887 | 3.171875 | 3 | [] | no_license | #![feature(test)]
extern crate test;
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
struct Password {
low: u8,
high: u8,
letter: char,
password: String,
}
fn is_valid_part1(entry: &Password) -> bool {
let total = entry.password.matches(entry.letter).count() as u8;
if total ... | true |
76c80ee8f28f9d447357a358d02af4447ffac8f6 | Rust | cxuhua/btx | /src/leveldb.rs | UTF-8 | 14,653 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | use crate::errors::Error;
use crate::index::{HasKey, IKey};
use crate::iobuf::{Reader, Serializer, Writer};
use leveldb::database::batch::{Batch, Writebatch, WritebatchIterator};
use leveldb::database::cache::Cache;
use leveldb::database::Database;
use leveldb::iterator::LevelDBIterator;
use leveldb::iterator::{Iterabl... | true |
303a4451be8c945a0fd58c7a40962952f5657ebc | Rust | Swatinem/psy | /benches/lookup.rs | UTF-8 | 2,212 | 2.515625 | 3 | [] | no_license | use criterion::{
black_box, criterion_group, criterion_main, AxisScale, BenchmarkId, Criterion,
PlotConfiguration, Throughput,
};
use rand::prelude::*;
use rand::rngs::SmallRng;
use psy::prefix_sum_index;
pub fn bench_lookup(c: &mut Criterion) {
let plot_config = PlotConfiguration::default().summary_scal... | true |
c88e379830f4bedae318f48164ff91ce50dc61d6 | Rust | laudv/bitboost | /src/bitset.rs | UTF-8 | 1,881 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | /*
* Copyright 2019 DTAI Research Group - KU Leuven.
* License: Apache License 2.0
* Author: Laurens Devos
*/
use std::ops::{Deref, DerefMut};
use crate::bitblock::{BitBlock, BitBlocks};
pub struct Bitset {
blocks: BitBlocks,
}
impl Bitset {
pub fn zeros(nbits: usize) -> Bitset {
Bitset {
... | true |
803662345c599a3daa0a9d9a45e3e24b0bc990ce | Rust | couchemar/bsvm | /src/vm/value.rs | UTF-8 | 53 | 2.53125 | 3 | [] | no_license | pub enum Value {
Int(int),
Primitive(Prim)
}
| true |
676ed75ca49165d67b6dc9e36d21e9e0a30c2cdc | Rust | japaric/f3 | /src/examples/_02_leds.rs | UTF-8 | 655 | 2.609375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Turns all the user LEDs on
//!
//! ```
//! #![deny(unsafe_code)]
//! #![deny(warnings)]
//! #![no_std]
//! #![no_main]
//!
//! extern crate panic_semihosting;
//!
//! use cortex_m_rt::entry;
//! use f3::{
//! hal::{prelude::*, stm32f30x},
//! led::Leds,
//! };
//!
//! #[entry]
//! fn main() -> ! {
//! ... | true |
958fc6f677cf6c595a5d04fa47b25c2d2252e6b6 | Rust | Vorticity-Flux/nash-rust | /nash-protocol/src/types/blockchain/eth.rs | UTF-8 | 9,607 | 2.8125 | 3 | [
"MIT"
] | permissive | //! Ethereum specific types shared across protocol requests
use super::super::{Amount, Asset, AssetOrCrosschain, AssetofPrecision, Nonce, OrderRate, Rate};
use super::{bigdecimal_to_nash_u64, nash_u64_to_bigdecimal};
use crate::errors::{ProtocolError, Result};
use byteorder::{BigEndian, ReadBytesExt};
#[cfg(feature = ... | true |
f5d62f57e548954d6ce6fd7b50ce219abef30859 | Rust | EliasDeMa/exercism-exercises | /rust/pythagorean-triplet/src/lib.rs | UTF-8 | 270 | 2.796875 | 3 | [] | no_license | pub fn find() -> Option<u32> {
let sum = 1000;
(2..sum)
.flat_map(|c| {
let a = sum - c;
(1..a).map(move |a| (a, sum - c - a, c))
})
.find(|&(a, b, c)| a * a + b * b == c * c)
.map(|(a, b, c)| a * b * c)
}
| true |
f121e0b10d68fffc5fafae8469cf8c30a3a06254 | Rust | johnmave126/tea-soft | /src/impls.rs | UTF-8 | 5,509 | 2.671875 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"MIT",
"Apache-2.0"
] | permissive | pub use cipher::{BlockCipher, NewBlockCipher};
use core::ops::{BitXor, Shl, Shr};
use byteorder::{BigEndian, ByteOrder};
use cipher::consts::{U16, U4, U8};
use cipher::generic_array::GenericArray;
use crate::simd::{slice_block, unslice_block, WrapArithmetic};
const TEA_DELTA: u32 = 0x9E3779B9;
pub type Block8 = Ge... | true |
b37ccc8304e268a23fade1f0574f367bdec1edf7 | Rust | ellenhp/radium | /src/types.rs | UTF-8 | 2,236 | 2.9375 | 3 | [
"MIT"
] | permissive | //! Best-effort atomic types
//!
//! This module exports `RadiumType` aliases that map to the `AtomicType` on
//! targets that have it, or `Cell<type>` on targets that do not. This alias can
//! be used as a consistent name for crates that need portable names for
//! non-portable types.
/// Best-effort atomic `bool` t... | true |
198b0eeabeb0558efe4a036b07fcd2a015f0a928 | Rust | tesaguri/twitter-stream-message | /src/direct_message.rs | UTF-8 | 773 | 2.53125 | 3 | [
"MIT"
] | permissive | //! Direct messages
use std::borrow::Cow;
use Entities;
use types::DateTime;
use user::{User, UserId};
use util;
#[derive(Clone, Debug, Deserialize, PartialEq)]
pub struct DirectMessage<'a> {
#[serde(deserialize_with = "util::deserialize_datetime")]
pub created_at: DateTime,
#[serde(borrow)]
pub ent... | true |
0c503c9b4af5585b4235e0c133eeddf0cfb17968 | Rust | emeryc/aoc_2020 | /src/day03.rs | UTF-8 | 2,664 | 3.234375 | 3 | [] | no_license | use eyre::{Error, Result};
use std::collections::HashSet;
use std::{cmp::max, str::FromStr};
#[derive(Debug)]
struct Map {
width: usize,
pub height: usize,
trees: HashSet<[usize; 2]>,
}
impl FromStr for Map {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let trees: H... | true |
bc052029dd25ffeb92d87f9729ad0fed705aa8d2 | Rust | Desmonddai583/Notes | /Rust/cxyjt/量化&数据分析/demo/2. 不使用库/src/lib/dataframe.rs | UTF-8 | 4,603 | 2.96875 | 3 | [] | no_license |
use std::{cell::RefCell, borrow::BorrowMut, fmt::Error};
use chrono::{NaiveDate};
use csv::Reader;
use serde::{Deserialize};
// 本课程来自 程序员在囧途(www.jtthink.com) 咨询群:98514334
#[derive(Default,Debug,Clone,Deserialize)]
pub struct data_frame{
pub ts_code:Option<String>, //股票代码
#[serde(deseriali... | true |
698c9b6f78c9de1d389e9565eb80bcd510038726 | Rust | jstarry/solana | /sdk/program/src/sysvar/stake_history.rs | UTF-8 | 1,836 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | //! named accounts for synthesized data accounts for bank state, etc.
//!
//! this account carries history about stake activations and de-activations
//!
pub use crate::stake_history::StakeHistory;
use crate::sysvar::Sysvar;
crate::declare_sysvar_id!("SysvarStakeHistory1111111111111111111111111", StakeHistory);
impl ... | true |
d17798f1c86232d82ccd26687f95d81cbe24f0a6 | Rust | victorhqc/julie-vic-wedding-backend | /julie-vic-wedding-api/src/auth/token.rs | UTF-8 | 1,256 | 2.796875 | 3 | [
"MIT"
] | permissive | use jsonwebtoken::{encode, Header};
use julie_vic_wedding_core::models::User;
use serde_derive::{Deserialize, Serialize};
use std::env;
use std::time::Duration;
use std::time::{SystemTime, UNIX_EPOCH};
use uuid::Uuid;
#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct AuthUser {
email: String,
user_id:... | true |
9d67e5b752cfa18278e1caafde687cf069a9061d | Rust | LuxInTenebr1s/mqttfsd | /src/codec.rs | UTF-8 | 1,288 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | use tokio_util::codec::{Decoder, Encoder};
use std::io::{self, Cursor, BufReader, Error, ErrorKind};
use bytes::BytesMut;
use mqtt3::{Packet, MqttRead, MqttWrite};
pub struct MqttCodec;
impl MqttCodec {
pub fn new() -> MqttCodec {
MqttCodec {}
}
}
impl Decoder for MqttCodec {
type Item = Packet;... | true |
7a31ab42cb2092794b76dbe38bfa230a8505d8f1 | Rust | C4K3/nbted | /src/unstable/tests/iter_replacer.rs | UTF-8 | 2,300 | 3.078125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"CC0-1.0"
] | permissive | use crate::iter_replacer::ReplacerExt;
use std::sync::mpsc::sync_channel;
#[test]
fn noop() {
let a: Vec<u8> = vec![0, 1, 2, 3, 4, 5, 6, 7, 8];
let b: Vec<u8> = a.iter().replacer(&[9], &[]).collect();
assert_eq!(a, b);
}
#[test]
fn length_one_match() {
let a: Vec<&str> = vec!["a", "b", "c", "d", "e"... | true |
131fd91da8caa00274f787a6a61d6cd9d08add5a | Rust | thomas9911/fun-with-flags-rs | /src/config.rs | UTF-8 | 7,687 | 3.109375 | 3 | [
"Unlicense"
] | permissive | use std::convert::TryFrom;
pub use config::ConfigError;
use config::{Config, Environment, File};
use dotenv::dotenv;
#[derive(Debug, Deserialize)]
pub struct RawConfig {
#[serde(rename(deserialize = "name"))]
pub database_name: Option<String>,
#[serde(rename(deserialize = "address"))]
pub database_ad... | true |
86e9dd491974475151c6b597487ece25ba992f0e | Rust | N-Maas/sample_hep | /benches/sorting_benchmark.rs | UTF-8 | 7,040 | 2.875 | 3 | [] | no_license | #[macro_use]
extern crate lazy_static;
use criterion::{criterion_group, criterion_main, Criterion, Throughput};
use rand::{Rng, SeedableRng};
use rand_pcg::Pcg32;
use sample_heap::{heap::FlatHeap, SampleHeap};
use std::{cmp::Reverse, collections::BinaryHeap, fmt::Debug};
fn random_sequence(len: usize, range: u32, see... | true |
8f524954ae839bcd87418dfc7578db6a420f89fa | Rust | Wdiviner/geektime-rust | /16_data_structure/src/slice2.rs | UTF-8 | 845 | 3.6875 | 4 | [
"Apache-2.0"
] | permissive | use std::fmt;
fn main() {
let v = vec![1, 2, 3, 4];
// Vec 实现了 Deref,&Vec<T> 会被自动解引用为 &[T],符合接口定义
print_slice(&v);
// 直接是 &[T],符合接口定义
print_slice(&v[..]);
// &Vec<T> 支持 AsRef<[T]>
print_slice1(&v);
// &[T] 支持 AsRef<[T]>
print_slice1(&v[..]);
// Vec<T> 也支持 AsRef<[T]>
print_s... | true |
1ad74b59fd0186c311621bef48db350e9dceadd5 | Rust | cs2dsb/github-game-jam-2018 | /src/config/sprite.rs | UTF-8 | 665 | 2.984375 | 3 | [
"MIT"
] | permissive | #[derive(Debug, Deserialize, Serialize)]
pub struct SpriteConfig {
pub name: String,
//These are the raw sizes in the spritesheet
pub sheet_x: u32,
pub sheet_y: u32,
pub sheet_height: u32,
pub sheet_width: u32,
//This is the output size and offsets
pub scaled_x: u32,
pub scaled_y: u32,
pub scaled_wi... | true |
d9defa94544cbab0e876d32ba3af2b2fb5fc1f99 | Rust | subspace/subspace | /crates/subspace-farmer-components/src/sector.rs | UTF-8 | 23,228 | 2.609375 | 3 | [] | no_license | use bitvec::prelude::*;
use parity_scale_codec::{Decode, Encode};
use rayon::prelude::*;
use std::ops::{Deref, DerefMut};
use std::{mem, slice};
use subspace_core_primitives::checksum::Blake3Checksummed;
use subspace_core_primitives::crypto::blake3_hash;
use subspace_core_primitives::{
Blake3Hash, HistorySize, Piec... | true |
4aec8436548267939e07d7f116f6bd20bc8c092d | Rust | preston-evans98/homeView | /src/row.rs | UTF-8 | 9,342 | 3.171875 | 3 | [] | no_license | use crate::editor::{
Highlight, Syntax, ALLOW_SINGLE_QUOTE, HIGHLIGHT_NUMBERS, HIGHLIGHT_STRINGS, TAB_STOP,
};
pub struct Row {
text: String,
rendered: String,
highlight: Vec<Highlight>,
}
fn is_separator(c: char) -> bool {
for ch in " \0,.()+-/*=~%<>[];".chars() {
if c == ch {
r... | true |
ac9b907d95f2580286e958bace8435ea98065161 | Rust | bitcoinmw/rust-tor | /tor-proto/src/stream/resolve.rs | UTF-8 | 1,033 | 2.734375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Declare a type for streams that do hostname lookups
use super::RawCellStream;
use crate::{Error, Result};
use tor_cell::relaycell::msg::{RelayMsg, Resolved};
/// A ResolveStream represents a pending DNS request made with a RESOLVE
/// cell.
pub struct ResolveStream {
/// The underlying RawCellStream.
s: RawCell... | true |
9a9761aa1fa48bde39badcd4c21e50c5a009c8c2 | Rust | ilia-glushchenko/simple_renderer_rust | /src/core/camera.rs | UTF-8 | 628 | 2.9375 | 3 | [] | no_license | use crate::math;
use std::f32;
#[derive(Clone)]
pub struct Camera {
pub view: math::Mat4x4f,
pub pos: math::Vec3f,
pub pitch: f32,
pub yaw: f32,
pub near: f32,
pub far: f32,
pub aspect: f32,
pub fov: f32,
}
pub fn create_default_camera(width: u32, height: u32) -> Camera {
Camera {
... | true |
fda7cb2be0a54a1e002d5a55559d4ebfa871129d | Rust | dbeckwith/dimensioned | /tests/tests.rs | UTF-8 | 1,551 | 2.6875 | 3 | [
"MIT"
] | permissive | #![cfg(feature = "qc")]
#![feature(plugin)]
#![plugin(quickcheck_macros)]
extern crate quickcheck;
extern crate dimensioned as dim;
mod quickchecking {
use dim::si::*;
use quickcheck::TestResult;
#[quickcheck]
fn add(x: f64, y: f64) -> bool {
x*M + y*M == Meter::new(x + y) &&
x*S +... | true |
8b8b22331400726843ba61313aebc8780bb15c28 | Rust | ir77/leran_rust | /ジェネリクス/src/main.rs | UTF-8 | 269 | 3.328125 | 3 | [] | no_license | fn main() {
println!("Hello, world!");
let x: Option<i32> = Some(5);
println!("{}", x.unwrap_or(0));
struct Point<T> {
x: T,
y: T,
}
let int_origin = Point { x: 0, y: 0 };
let float_origin = Point { x: 0.0, y: 0.0 };
}
| true |
f11f8898c0ea071a66f3a0da7f45c919bf1ad04d | Rust | manhtai/rust-plan | /project-2/src/bin/kvs.rs | UTF-8 | 2,234 | 2.90625 | 3 | [] | no_license | use std::path::Path;
use std::process::exit;
use clap::{App, Arg, SubCommand};
use kvs::{KvStore, Result};
fn main() -> Result<()> {
let matches = App::new("kvs")
.version(env!("CARGO_PKG_VERSION"))
.author("manhtai")
.arg(Arg::with_name("V").help("Show package version"))
.subcomm... | true |
62e7434b590f1272b7d407a050e8740e8260df86 | Rust | Ruin0x11/autotile | /src/atlas/mod.rs | UTF-8 | 9,318 | 2.6875 | 3 | [] | no_license | use std::collections::HashMap;
use std::fs::{self, File};
use std::path::Path;
use glium;
use glium::backend::Facade;
use image::{self, DynamicImage, GenericImage, Rgba};
use texture_packer::Rect;
use texture_packer::SkylinePacker;
use texture_packer::{TexturePacker, TexturePackerConfig};
use texture_packer::importer:... | true |
e69c15497a7fdc71844df173d6d109b5a6e99d05 | Rust | Tootallgavin/switch-i3 | /src/focuswatcher/structures.rs | UTF-8 | 6,019 | 2.640625 | 3 | [
"MIT"
] | permissive | extern crate i3ipc;
use std::hash::{Hash, Hasher};
use std::collections::HashMap;
use super::treewalker::*;
///structure to help keep track of the order of focus of windows and workspaces by i3-id
/// 0 is the currently focused node
/// 1 is the previously focused node
/// n is the last node focused; where n is lengt... | true |
149b8dac3c1e80f025a6dfeecf3cda125a266b2d | Rust | prisma/prisma-engines | /psl/psl-core/src/validate/validation_pipeline/validations/constraint_namespace.rs | UTF-8 | 9,405 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | use crate::datamodel_connector::{walker_ext_traits::*, ConstraintScope};
use parser_database::ast;
use std::{borrow::Cow, collections::HashMap, ops::Deref};
/// A constraint namespace consists of two kinds of namespaces:
///
/// - Global ones can be triggering validation errors between different models.
/// - Local on... | true |
8c96e2ad3dc8343353100deb9860a9c202744d2b | Rust | quirinux/rust-core-utils | /src/bin/util/file_read_strategy.rs | UTF-8 | 2,136 | 3.296875 | 3 | [] | no_license |
#[derive(Debug)]
pub enum FileReadStrategy {
FromByte(usize),
LastBytes(usize),
FromLine(usize),
LastLines(usize),
None(String),
}
impl FileReadStrategy {
pub fn pick(bytes: String, lines: String) -> FileReadStrategy {
let mut from_byte: usize = 0;
let mut last_bytes: usize = ... | true |
bf788f1cbca3d6c325e71364e15831cc4ef57009 | Rust | javiercode/gb | /src/utils.rs | UTF-8 | 143 | 2.859375 | 3 | [] | no_license | pub fn bytes_to_hex(bytes: &[u8]) -> String {
bytes
.iter()
.map(|&b| format!("{:02X}", b))
.collect::<String>()
}
| true |
efbbae2e1b8f667b6f3dad95ed71ba5d4df67815 | Rust | ba3r/oxidize | /src/backend/mod.rs | UTF-8 | 1,462 | 2.9375 | 3 | [
"MIT"
] | permissive | //! A module that contains built in backends for oxidize. Currently I have only plans to support just
//! Mongrel and Rust Http until teepee comes out at which point I'll finally drop support for rust-http
//! and add in teepee support. If someone makes a new backend they wish to add to the repo, just send a pull requ... | true |
9e43a9574697632a40ca7f7b6cd4a7c870a89d84 | Rust | nerdrew/rust-sthttp | /src/request.rs | UTF-8 | 429 | 2.71875 | 3 | [] | no_license | use httparse;
pub struct Request<'a> {
pub method: Option<&'a str>,
pub path: Option<&'a str>,
pub headers: &'a [httparse::Header<'a>],
pub body: &'a [u8],
}
impl<'a> Request<'a> {
pub fn new(req: &'a httparse::Request, body: &'a [u8]) -> Request<'a> {
Request {
method: req.met... | true |
a6491c85e1dfbb8102a05d741f41102873fd86e3 | Rust | MinusGix/hack_chat_types | /src/server.rs | UTF-8 | 24,411 | 2.75 | 3 | [] | no_license | use std::{collections::HashMap, convert::TryFrom};
#[cfg(feature = "json_parsing")]
use crate::util::{as_array, as_object, FromJson, FromJsonError, IntoJson};
#[cfg(feature = "json_parsing")]
use json::JsonValue;
use crate::{
id, util::Color, util::Command, util::MaybeExist, util::ServerCommand, Channel, Hash, Ni... | true |
b497f0f8413cd766d2c474253d74bdca05e7ee90 | Rust | semtexzv/libyuv | /src/lib.rs | UTF-8 | 482 | 2.59375 | 3 | [] | no_license | #[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}
pub unsafe fn convert(buf: &[u8], w: u32, h: u32, dst: &mut [u8]) {
assert_eq!(yuv_sys::I420ToRGBA(
buf.as_ptr(),
w as i32,
buf.as_ptr().offset((w * h) as isize),
(w / 2) as i32,
b... | true |
ea7bf7c14bb333362649df75371f96fa545e4ca9 | Rust | malthe/blend2d-rs | /src/pattern.rs | UTF-8 | 4,874 | 2.90625 | 3 | [
"CC-BY-4.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use core::{fmt, ptr};
use crate::{
error::{errcode_to_result, Result},
geometry::RectI,
image::Image,
matrix::{Matrix2D, Matrix2DOp, MatrixTransform},
variant::WrappedBlCore,
ExtendMode,
};
#[repr(transparent)]
pub struct Pattern {
core: ffi::BLPatternCore,
}
unsafe impl WrappedBlCore for... | true |
6025923153194572d672a2c840d145b31077392f | Rust | Owez/zypo-rs | /zypo-lib/src/parser/scope.rs | UTF-8 | 1,773 | 3.640625 | 4 | [
"MIT"
] | permissive | //! Contains the primary scoping structure and various trait implementations.
//! Please see [Scope] for more infomation.
use std::collections::HashMap;
use std::hash::Hash;
/// Structure for storing an AST node as a hashmap node inside of a vector.
///
/// To use this structure, a node type has to implament [Hash] an... | true |
3d6a567416f56d1c27356b02fa4bf14585a3ef2e | Rust | ergoplatform/sigma-rust | /ergotree-ir/src/mir/extract_bytes.rs | UTF-8 | 1,334 | 2.703125 | 3 | [
"CC0-1.0"
] | permissive | use crate::serialization::op_code::OpCode;
use crate::types::stype::SType;
use super::expr::Expr;
use super::expr::InvalidArgumentError;
use super::unary_op::OneArgOp;
use super::unary_op::OneArgOpTryBuild;
use crate::has_opcode::HasStaticOpCode;
/// Serialized box bytes
#[derive(PartialEq, Eq, Debug, Clone)]
pub str... | true |
6a6425e1f925ef22c1f5b4d977f2e240f7074944 | Rust | einzigartigerName/mac_app_bundler | /src/lib.rs | UTF-8 | 6,503 | 2.890625 | 3 | [
"MIT"
] | permissive | extern crate rust_embed;
use rust_embed::*;
use std::path::PathBuf;
use std::fs::{create_dir_all, create_dir, copy, File};
use std::os::unix::fs::PermissionsExt;
use std::io::{ErrorKind, Error, Write};
use crate::ExitCode::*;
use std::ffi::OsStr;
const DIR_CONTENT: &str = "Contents";
const DIR_RESOURCES: &str = "Reso... | true |
122d227ae9005e9ca97caf28def4e3a7657231ab | Rust | paulpage/bloom-filter-rs | /src/main.rs | UTF-8 | 5,817 | 2.96875 | 3 | [] | no_license | use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
use std::marker::PhantomData;
use std::fs::File;
use std::io::{BufReader, BufRead};
use std::env;
extern crate bit_vec;
extern crate time;
use bit_vec::BitVec;
use time::PreciseTime;
#[derive(Debug)]
struct BloomFilter<T> {
bit_vec: Bi... | true |
2fbba52cbf9ba250e315ea821bfbafdf547b382b | Rust | jamesw201/automated_project_setup | /src/signature_parser.rs | UTF-8 | 8,241 | 2.796875 | 3 | [] | no_license | extern crate nom;
use nom::{
branch::alt,
bytes::complete::{tag, take_while, take_until},
character::complete::{alphanumeric1, char, multispace0, space0},
multi::separated_list0,
sequence::{preceded, separated_pair, terminated},
IResult
};
use crate::domains::function_signature::{
Applicat... | true |
2909afcfb2d67b7ae18234df011861d7549a1e1f | Rust | jamesrweb/rust-coursework | /11 - Common Collections/04 - Assignment/src/main.rs | UTF-8 | 1,558 | 3.6875 | 4 | [] | no_license | use std::{collections::HashMap, io::stdin};
fn trim_newline(s: &mut String) {
if s.ends_with('\n') {
s.pop();
if s.ends_with('\r') {
s.pop();
}
}
}
fn user_value(request_text: &str) -> String {
let mut value = String::new();
println!("{}", request_text);
match ... | true |
12f5b820d2cd175700be32241189d522ee73f29c | Rust | jerry-sl/echo | /src/main.rs | UTF-8 | 1,375 | 3.3125 | 3 | [] | no_license | //使用std中tcp监听和流处理的依赖
use std::net::{TcpListener, TcpStream};
//处理多个tcp的连接需要后台线程
use std::thread;
// 流io处理
use std::io::Read;
use std::io::Write;
fn handle_client(mut stream: TcpStream) {
// 读取20个字节 处理后写会原来的流中
loop {
let mut read = [0; 1028];
//判断读取的流数据是否正确并按情况处理
match stream.read(&mut r... | true |
5d7f27a8b09befc19e09950122fdd26211a2ce05 | Rust | maxtnuk/eosrpc-rust | /eos-type/src/lib.rs | UTF-8 | 2,692 | 3.125 | 3 | [
"MIT"
] | permissive | use std::borrow::Cow;
use std::ops::Index;
use std::ops::{Range, RangeTo, RangeFull, RangeInclusive, RangeFrom, RangeToInclusive};
pub mod errorhandle;
pub use errorhandle::{Errortype, err_print};
pub type ResultData<'a> = Result<Data<'a>, Errortype>;
#[derive(Clone, Default)]
pub struct Data<'a> {
pub bytes: Cow... | true |
da0f1b0c85083c8d5b0f34dc5ff30841fe4011c2 | Rust | Folyd/iced | /winit/src/error.rs | UTF-8 | 881 | 2.84375 | 3 | [
"MIT"
] | permissive | use iced_futures::futures;
/// An error that occurred while running an application.
#[derive(Debug, thiserror::Error)]
pub enum Error {
/// The futures executor could not be created.
#[error("the futures executor could not be created")]
ExecutorCreationFailed(futures::io::Error),
/// The application w... | true |
69013cbc289f1bbd6bba32f46a9e5fc7ca64f8e9 | Rust | david68cu/rust-in-motion-videos | /unit3/module8-methods-on-result-and-option/01-22-antipattern-testing-unwrapping/src/main.rs | UTF-8 | 167 | 3.359375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | fn main() {
let option_value = Some(25);
if option_value.is_some() {
let inner = option_value.unwrap();
println!("inner = {}", inner);
}
}
| true |
c862c50659966a9bf4b85fc09b15f30904e8b6d3 | Rust | iqlusioninc/usbarmory.rs | /firmware/examples/examples/rtic-3-lock.rs | UTF-8 | 2,464 | 3.265625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! RTFM `lock` API
//!
//! This is a replica of the `lock` example in the RTFM book [1].
//!
//! Expected output:
//!
//! ```
//! A
//! B - shared = 1
//! C
//! D - shared = 2
//! E
//! ```
//!
//! [1]: https://rtic.rs/0.5/book/en/by-example/resources.html#lock
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_main]
#![... | true |
2f5b1eb6aae3dbff5e69dc4df3faa614c8028b5e | Rust | the-kenny/rtask | /librtask/src/model.rs | UTF-8 | 11,733 | 3.296875 | 3 | [] | no_license | use std::collections::{BTreeMap, HashMap};
use task::*;
use task_ref::TaskRef;
use std::io;
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum Effect {
AddTask(Task),
ChangeTaskTags {
uuid: Uuid,
added: Tags,
removed: Tags,
},
ChangeTaskState(Uuid, TaskStat... | true |
3df621fe6d95832bf40941f4b461e6968e3b0d29 | Rust | samscott89/cerberust | /src/error.rs | UTF-8 | 3,040 | 2.59375 | 3 | [] | no_license | use gssapi_krb5_sys;
use std::error;
use std::fmt;
use std::result;
use std::str;
use super::buffer::Buffer;
use super::oid::OID;
pub type Result<T> = result::Result<T, Error>;
pub struct Error {
major_status: u32,
minor_status: u32,
mech_type: OID,
}
impl Error {
pub fn new(major_status: u32, minor_... | true |
45ca159c7500024210c9efdf8cff74272198dd2a | Rust | anekos/eitaro | /src/delay.rs | UTF-8 | 579 | 2.984375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive |
use std::time::Duration;
use std::thread::sleep;
use std::sync::Arc;
use std::sync::atomic::{AtomicU64, Ordering};
#[derive(Clone)]
pub struct Delay {
time: Duration,
serial: Arc<AtomicU64>,
}
impl Delay {
pub fn new(time: Duration) -> Self {
Self {
time,
serial: Arc::ne... | true |
976f9b4b8551e53b83a982a49eb1e9bb841251b0 | Rust | 0ndorio/advent-of-code | /2018/aoc03/src/main.rs | UTF-8 | 2,821 | 3.171875 | 3 | [
"Unlicense"
] | permissive | use std::{
collections::{HashMap, HashSet},
error::Error,
io::{self, Read},
str::FromStr,
};
use lazy_static::lazy_static;
use regex::Regex;
type Result<ContentT> = std::result::Result<ContentT, Box<dyn Error>>;
type FabricPlan = HashMap<(u32, u32), Vec<u32>>;
fn main() -> Result<()> {
let mut in... | true |
f5c63379755759d805dbb59b29dab3b9f37b8b6e | Rust | Incomprehensible/Rust-projects | /biggest_palindrome/z_function.rs | UTF-8 | 496 | 3.453125 | 3 | [] | no_license | fn print_vec(arr: &[i32]) {
for i in arr.iter() {
print!("{} ", i);
}
println!();
// println!("{:?}", arr);
}
fn z_function(s: &str, n: usize) -> Vec<i32> {
let mut arr: Vec<i32> = vec![0];
for _ in 0..n-1 {
arr.push(0);
}
for i in 1..n {
let mut j = 0;
let mut ind = i;
while ind < n && s.chars().nth... | true |
b03acb361cdeb75cafa679950cd4395f19c94fef | Rust | lineCode/GameServer_Rust | /tools/src/my_log.rs | UTF-8 | 1,482 | 2.75 | 3 | [] | no_license | use log::{info, LevelFilter};
use simplelog::ColorChoice;
use simplelog::{CombinedLogger, TermLogger, TerminalMode, WriteLogger};
use std::fs::File;
use std::time;
///修改堆栈错误信息格式和颜色让它看起来像以下这样
fn setup() {
if std::env::var("RUST_LIB_BACKTRACE").is_err() {
std::env::set_var("RUST_LIB_BACKTRACE", "1")
}
... | true |
3f4271e1f40041a90ca1e057234efaa17d41a15f | Rust | bbodi/meal_planner | /imgui/src/slider.rs | UTF-8 | 4,251 | 2.9375 | 3 | [] | no_license | extern crate sdl2;
extern crate sdl2_ttf;
use sdl2::pixels::RGB;
use base;
use base::SizeInCharacters;
#[deriving(PartialEq, Clone, Show)]
pub enum Type {
Vertical,
Horizontal
}
pub struct SliderBuilder<'a> {
x: SizeInCharacters,
y: SizeInCharacters,
w: SizeInCharacters,
h: SizeInCharacters,
min_value: SizeI... | true |
62bb7e07d0907bf98bb8f3291621816322957de8 | Rust | sotos89/macaroon-compatibility | /implementations/rust-macaroons/first_party_macaroon_serialized.rs | UTF-8 | 707 | 2.5625 | 3 | [] | no_license | // script arguments: location key id caveat_id
extern crate macaroons;
use std::env;
use std::string::String;
use macaroons::token::Token;
use macaroons::caveat::{Caveat, Predicate};
fn main() {
let args: Vec<_> = env::args().collect();
let location = args[1].clone().into_bytes();
let key = args[2].clone().i... | true |
e02a28961038e695c50bca6aa2b18d80a2b18c30 | Rust | Prototik/zram-generator | /src/setup.rs | UTF-8 | 2,336 | 2.59375 | 3 | [
"MIT"
] | permissive | /* SPDX-License-Identifier: MIT */
use crate::config::Device;
use anyhow::{anyhow, Context, Result};
use std::fs;
use std::io::ErrorKind;
use std::os::unix::process::ExitStatusExt;
use std::path::Path;
use std::process::Command;
pub fn run_device_setup(device: Option<Device>, device_name: &str) -> Result<()> {
le... | true |
a2eea5585db534ae07ab1b99d6523f1193c2d6ff | Rust | fluffels/rust-examples | /tictactoe/src/tictactoe/tests.rs | UTF-8 | 2,243 | 2.859375 | 3 | [] | no_license | #![cfg(test)]
use super::Board;
use super::ai::ai_move;
use super::State;
use super::Tile;
#[test]
fn test_blank() {
let board = Board::new();
for x in 0..2 {
for y in 0..2 {
assert!(board.at(x, y).unwrap() == Tile::EMPTY);
}
}
assert!(board.state() == State::Undecided);
}
... | true |
2a538da9c88aa2fedc2c9a8a2f30a4b5f00e89cf | Rust | oli-obk/geschenke | /src/api/present.rs | UTF-8 | 6,955 | 2.625 | 3 | [] | no_license | use super::UserId;
use chrono::prelude::*;
use diesel::prelude::*;
use diesel::{self, insert_into, update};
use geschenke::schema::{presents, users};
use geschenke::{NewPresent, Present, PresentId};
use pool::DbConn;
use rocket::http::RawStr;
use rocket::request::{Form, FromFormValue};
use rocket::response::Content;
us... | true |
dfe178f3b1637c1ad2d437f6f8222ea2d3be8ebb | Rust | roSievers/tictactoe | /src/board.rs | UTF-8 | 6,026 | 3.3125 | 3 | [
"MIT"
] | permissive | use coord;
use rand::random;
use std::fmt;
use std::fmt::Debug;
use std::ops::{Index, IndexMut};
// TODO: Token<T> { Clear(T), .. }
#[derive(Clone, Copy, Eq, PartialEq)]
pub enum Token {
Clear,
Circle,
Cross,
}
#[derive(Clone, Copy)]
pub enum Player {
Circle,
Cross,
}
#[derive(Clone, Copy, Partia... | true |
c8dc9f1a7ceae1f7413667ac3171556016f90c81 | Rust | jamiebrynes7/spatialos-sdk-rs | /spatialos-sdk/src/ptr.rs | UTF-8 | 2,490 | 3.984375 | 4 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Utilities for handling raw pointers.
use derivative::Derivative;
use std::cmp::Ordering;
/// Wrapper around a raw pointer that ensures the pointer can only be accessed
/// through a mutable reference.
///
/// Some types in the C API can be safely shared between threads as long as they are
/// only accessed by one... | true |
664fe1d399542d755343a708c60484a09b923821 | Rust | lelongg/ros_package_manifest | /src/tags/version.rs | UTF-8 | 1,671 | 2.96875 | 3 | [] | no_license | use once_cell::sync::Lazy;
use regex::Regex;
use roxmltree::Node;
use std::convert::TryFrom;
use thiserror::Error;
static VERSION_REGEX: Lazy<Regex> =
Lazy::new(|| Regex::new(r"^[[:digit:]]+.[[:digit:]]+.[[:digit:]]+$").unwrap());
#[derive(Default, Debug, Clone, PartialEq)]
pub struct Version {
pub version: S... | true |
a5f7254460bf4ec968eb453d25e10051ef242737 | Rust | FIL1994/rust-examples | /1/closures.rs | UTF-8 | 223 | 3.140625 | 3 | [] | no_license | use std::{ i32 };
fn main() {
let sum_num = |x: i32, y: i32| x + y;
println!("7 + 8 = {}", sum_num(7, 8));
let num_ten = 10;
let add_ten = |x: i32| x + num_ten;
println!("3 + 10 = {}", add_ten(3));
}
| true |
fc9b031511a51c08aa423f7a2c67e993230b913c | Rust | wa7sa34cx/traits | /password-hash/src/errors.rs | UTF-8 | 2,796 | 3.1875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | //! Error types.
pub use base64ct::Error as B64Error;
use core::fmt;
/// Result type.
pub type Result<T> = core::result::Result<T, Error>;
/// Password hashing errors.
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum Error {
/// Unsupported algorithm.
Algorithm,
/// "B64" encoding error.
B64(B... | true |
c938616e972f87a4532d10c26ed2b0c4e6d90e3f | Rust | EFanZh/Introduction-to-Algorithms | /src/chapter_17_amortized_analysis/problems/problem_17_3_amortized_weight_balanced_trees.rs | UTF-8 | 19,559 | 3.46875 | 3 | [] | no_license | use std::borrow::Borrow;
use std::cmp::Ordering;
use std::{iter, mem};
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct Node<K, V> {
key: K,
value: V,
left: Option<Box<Self>>,
right: Option<Box<Self>>,
size: usize,
}
fn get_size<K, V>(maybe_node: &Option<Box<Node<K, V>>>) -> usize {
maybe_nod... | true |
3995144bff612806588d982929c7d7046677fe7f | Rust | IThawk/rust-project | /rust-master/src/test/debuginfo/function-call.rs | UTF-8 | 727 | 2.71875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // This test does not passed with gdb < 8.0. See #53497.
// min-gdb-version 8.0
// compile-flags:-g
// === GDB TESTS ===================================================================================
// gdb-command:run
// gdb-command:print fun(45, true)
// gdb-check:$1 = true
// gdb-command:print fun(444, false)
/... | true |
062f118760440fec9cba86f86630112658c2905d | Rust | tttnvndbtdln/CS510-Rust | /main.rs | UTF-8 | 3,777 | 3.5 | 4 | [] | no_license | //Phuong Pham
//CS 510 Rust Programming
//Spring 2019
use std::io::Write;
use std::str::FromStr;
fn sum(x: u64, y: u64) -> u64
{
x + y
}
fn product(x: u64, y: u64) -> u64
{
x * y
}
fn gcd(mut n: u64, mut m: u64) -> u64
{
assert!(n != 0 && m != 0);
while m != 0
{
if m < n
{
let t = m;
... | true |
e271b769ddd05e4c5e1382026a6f131d32363289 | Rust | sogapalag/contest | /codeforces/668/1d.rs | UTF-8 | 2,992 | 2.90625 | 3 | [] | no_license | #[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
let mut ret = String::new();
std::io::stdin().read_line(&mut ret).ok().unwrap();
ret
}
fn get_word() -> String {
let stdin = std::io::stdin();
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.