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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
300a65c745335d13a6f167402cceda684d73c6c0 | Rust | AloeareV/json_typegen | /json_typegen_cli/src/main.rs | UTF-8 | 3,207 | 2.859375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use clap::{App, Arg};
use json_typegen_shared::{codegen, codegen_from_macro, parse, Options, OutputMode};
use std::fs::OpenOptions;
use std::io::{self, Read, Write};
fn main_with_result() -> Result<(), Box<dyn std::error::Error>> {
let matches = App::new("json_typegen CLI")
.version(env!("CARGO_PKG_VERSION... | true |
6626e1999f7739c9dbf9f8818a7636eb954766f8 | Rust | alex-chew/z3d-rs | /z3d-examples/src/bin/trio.rs | UTF-8 | 7,264 | 2.71875 | 3 | [
"MIT"
] | permissive | //! # Trio puzzle
//!
//! Solves the Alphametics puzzle "VIOLIN + VIOLIN + VIOLA = TRIO + SONATA" as described in Dennis
//! Yurichev's "SAT/SMT by example" document.
#![feature(proc_macro_hygiene)]
use std::env;
use z3::{ast, Config, Context, Model, Solver};
use z3d::{dec, exp};
struct Vars<'a> {
num_a: ast::I... | true |
4d01b49426fd91f28883eee77cf556bebd13cc9b | Rust | jfoucher/rust-6502 | /src/old.rs | UTF-8 | 21,104 | 2.765625 | 3 | [] | no_license | use std::env;
//use std::convert::TryInto;
use std::fs;
use std::time;
use std::thread;
use std::error::Error;
use cursive::align::HAlign;
use cursive::traits::*;
use cursive::views::{Dialog, DummyView, LinearLayout, TextView, OnEventView, Canvas, IdView};
use cursive::Cursive;
use std::sync::{Arc, Mutex};
use std::syn... | true |
efbecbcab539fc0367e92ae17fccc3f0870f66d5 | Rust | couchbaselabs/couchbase-rs | /couchbase/examples/ping.rs | UTF-8 | 772 | 3.203125 | 3 | [
"Apache-2.0"
] | permissive | use couchbase::*;
use futures::executor::block_on;
/// Ping Examples.
///
/// This sample file shows how to do simple ping operations. You can see how each method
/// takes options (use the `::default()`) implementation if you do not need custom options)
/// and returns a `CouchbaseResult` that you need to match on.
p... | true |
da12c4ac5197681cc749ff410825bfbbfbedc35d | Rust | x7c1/plus | /libs/aws/plus-aws/src/auth/account/secret_key.rs | UTF-8 | 1,455 | 3.328125 | 3 | [
"MIT"
] | permissive | use crate::verbs::AsBytes;
use characters::{AsStr, MultiByte};
use std::fmt;
use std::str::FromStr;
pub struct SecretKey(String);
impl SecretKey {
pub fn new<A: Into<String>>(value: A) -> Self {
Self(value.into())
}
}
impl AsBytes for SecretKey {
fn as_bytes(&self) -> &[u8] {
self.0.as_by... | true |
73580273f91e563ed51b482d2d5a3232b666f56b | Rust | Giovanni-Tedesco/rust-tsp | /src/tour/utils.rs | UTF-8 | 516 | 3.03125 | 3 | [] | no_license | use std::collections::HashMap;
use rand::Rng;
use crate::city::City;
pub fn generate_random_permutation(n: usize) -> Vec<usize> {
let mut v: Vec<f64> = Vec::new();
let mut rng = rand::thread_rng();
for _ in 0..n {
let x: f64 = rng.gen();
v.push(x);
}
let mut indicies: Vec<usize... | true |
6ae28efe0741521a0568be62f1891febc10ff816 | Rust | jjmark15/happynum_rust | /src/happynum.rs | UTF-8 | 1,644 | 3.671875 | 4 | [
"MIT"
] | permissive | use rayon::prelude::*;
/// Returns the sum of the square of all digits in `n`
fn square_sum(n: usize) -> usize {
let mut ss = 0;
let mut val = n;
while val > 0 {
ss += (val % 10).pow(2);
// take advantage of losing decimal values in an integer value
val /= 10;
}
ss
}
fn i... | true |
12c5c32410ba022032062f7b61ca4c95d5c5d442 | Rust | jtavera235/MultiClassMapper | /src/common/file_operations/file_operations.rs | UTF-8 | 1,763 | 2.953125 | 3 | [] | no_license | use crate::common::{handle_result_error, MError};
use colored::Colorize;
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
pub fn write_file(file: &mut File, buffer: &str) {
file.write_all(buffer.as_bytes())
.expect("unable to write to file");
}
pub fn open_file(file: &str) -> File {
pr... | true |
aed855b1d65cf48fb957cd3034fbeb69bcd01a6f | Rust | drewchandler/raytracer | /src/object.rs | UTF-8 | 253 | 2.75 | 3 | [] | no_license | use super::color::Color;
use super::ray::Ray;
use super::shapes::Shape;
pub struct Object {
pub shape: Box<Shape>,
pub color: Color
}
impl Object {
pub fn intersect(&self, r: &Ray) -> Option<f64> {
self.shape.intersect(&r)
}
}
| true |
1e9f568fac7076e053969370ae25caf35915fa24 | Rust | vectorizer-labs/packattack-derive | /src/attributes/mod.rs | UTF-8 | 3,723 | 2.890625 | 3 | [] | no_license | use crate::util::{ get_meta_attribute, lit_from_meta_attribute, ident_from_lit, ident_from_str };
pub mod enums;
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ParentDataType
{
FromReader,
FromBytes,
FromBits,
FromSlice
}
impl From<&ParentDataType> for FieldDataType
{
fn from(ty : &ParentDataT... | true |
afc92d5b77dc5b768e593a5e8f8dd9ac0353278a | Rust | hawkinsw/domain | /domain-core/src/rdata/rfc5155.rs | UTF-8 | 8,017 | 2.640625 | 3 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Record data from [RFC 5155].
//!
//! This RFC defines the NSEC3 and NSEC3PARAM resource records.
//!
//! [RFC 5155]: https://tools.ietf.org/html/rfc5155
use std::fmt;
use bytes::BufMut;
use ::bits::charstr::CharStr;
use ::bits::compose::{Compose, Compress, Compressor};
use ::bits::parse::{Parse, ParseAll, ParseAll... | true |
86c789d6a80dc295fcd2ce6a0a2491884265ecdd | Rust | software-opal/metlink-cancellation-tweetbot | /gtfs/metlink_gtfs_lib/src/db/stops.rs | UTF-8 | 1,623 | 2.890625 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
use crate::gtfs::data::stop::StopLocationType;
#[derive(Debug, Deserialize, Serialize)]
pub struct Stop {
pub id: String,
pub code: String,
pub name: String,
pub desc: String,
pub lat: f64,
pub lon: f64,
pub zone_id: String,
p... | true |
bc23c843bfd5a3614321c30992436aa01d8db7b4 | Rust | janpauldahlke/fhir-rs | /src/model/ClinicalImpression_Finding.rs | UTF-8 | 7,990 | 2.984375 | 3 | [
"MIT"
] | permissive | #![allow(unused_imports, non_camel_case_types)]
use crate::model::CodeableConcept::CodeableConcept;
use crate::model::Element::Element;
use crate::model::Extension::Extension;
use crate::model::Reference::Reference;
use serde_json::json;
use serde_json::value::Value;
use std::borrow::Cow;
/// A record of a clinical a... | true |
f81530aed608167c7940f555d497af9e1b56f831 | Rust | acidburn0zzz/ruffle | /core/src/avm2/method.rs | UTF-8 | 5,681 | 3.28125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! AVM2 methods
use crate::avm2::activation::Activation;
use crate::avm2::object::Object;
use crate::avm2::script::TranslationUnit;
use crate::avm2::value::Value;
use crate::avm2::Error;
use crate::collect::CollectWrapper;
use gc_arena::{Collect, CollectionContext, Gc, MutationContext};
use std::fmt;
use std::rc::Rc;... | true |
ec2a45485db04571864453229b477d9e28170940 | Rust | OneFourth/advent2020 | /src/lib/days/day10.rs | UTF-8 | 1,410 | 3.109375 | 3 | [] | no_license | use crate::lib::{advent::Result, utils::parse_lines};
use crate::Day;
#[derive(Default)]
pub struct Day10 {
numbers: Vec<usize>,
}
fn length_to_count(len: usize) -> usize {
(0..(2u32.pow(len as u32)))
.map(|v| format!("{:01$b}", v, len))
.filter(|s| !s.contains("000"))
.count()
}
impl... | true |
c7a8f07208e4480d4133f11fe44791e156217fde | Rust | dtolnay/cxx | /gen/build/src/cargo.rs | UTF-8 | 4,262 | 2.703125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::gen::{CfgEvaluator, CfgResult};
use once_cell::sync::OnceCell;
use std::borrow::Borrow;
use std::cmp::Ordering;
use std::collections::{BTreeMap as Map, BTreeSet as Set};
use std::env;
static ENV: OnceCell<CargoEnv> = OnceCell::new();
struct CargoEnv {
features: Set<Name>,
cfgs: Map<Name, String>,
}... | true |
c20d7af1675783c3cb940d2836050da6ffd91238 | Rust | gramlang/gram | /src/type_checker.rs | UTF-8 | 65,463 | 2.984375 | 3 | [
"MIT"
] | permissive | use {
crate::{
de_bruijn::{open, unsigned_shift},
error::{listing, throw, Error},
format::CodeStr,
parser::PLACEHOLDER_VARIABLE,
term::{
Term,
Variant::{
Application, Boolean, Difference, EqualTo, False, GreaterThan,
Gre... | true |
88f8150fbfcea1f22955ed5639b2c8628d064d41 | Rust | ubitux/pokanalysis | /extractor/src/text.rs | UTF-8 | 4,690 | 2.953125 | 3 | [
"ISC"
] | permissive | use std::iter;
use crate::{
addresses::{get_name_pointer, NamePointer},
reader::{Addr, Reader},
};
fn get_pkmn_chr<'a>(c: u8) -> &'a str {
match c {
0x49 => "\n", // pokédex desc sentence separator
0x4E => "\n", // pokédex desc normal \n
0x4F => "\n",
0x51 => "\n\n",
... | true |
ddb2769f36964ee8f902d2af90163ab1814e8a9b | Rust | Taidgh-Robinson/html_text_highlighting | /src/main.rs | UTF-8 | 3,247 | 2.828125 | 3 | [] | no_license | //I would like to source the html5ever example file for help with this, a good chunk of this code is just implmenting the dom and printing the elments in it and they have a great example on how to do that. I modified it to print the full html document, including closing blocks and opening an html file. I also removed s... | true |
ecc7cf82a048ffdcdd17de96cf5e2d83a014ca56 | Rust | RZaga09/rust_cheat_sheet | /src/others.rs | UTF-8 | 425 | 3.34375 | 3 | [] | no_license | pub fn ye() {
println!("from other file");
println!("{} like to {} {}", "Ashley", "eat", "cake");
println! (
"{0} has {1} {2}",
"Eduard", "many", "commitments"
);
println! (
"If {yeet} loses we {agh}",
yeet = "Arvin",
agh = "riot!"
);
println!("Binary: {:b} Hex: {:x} Octal: {:... | true |
386397aacdca4b453ed66c00ca64840b4726106d | Rust | ResidentMario/cosine-similarity | /src/lib.rs | UTF-8 | 3,345 | 3.359375 | 3 | [] | no_license | use json::JsonValue;
use std::fs::File;
use std::io::prelude::*;
use std::collections::HashSet;
fn media_trope_str(media_name: &str, media_type: &str) -> Result<String, std::io::Error> {
// Result::Ok(json::parse("{}").unwrap())
// Q: why not use ? operator here?
//
// A: the ? operator forwards the er... | true |
31b921072574251cba294ae241941b7d8a608041 | Rust | baldwinmatt/rust-gol | /src/lib.rs | UTF-8 | 4,200 | 3.328125 | 3 | [
"MIT"
] | permissive | use std::convert::TryInto;
use std::error::Error;
use std::fmt;
use std::fs;
use std::path::Path;
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum Cell {
Dead = 0,
Alive = 1,
}
pub struct Universe {
width: u32,
height: u32,
cells: Vec<Cell>,
}
/// Wrap around subtraction of 1 from input, bou... | true |
3b889c8d7e35c6f2129cacefb749c8fee55d234c | Rust | waynexia/tp-pna | /src/error.rs | UTF-8 | 2,130 | 2.984375 | 3 | [
"MIT"
] | permissive | use serde_json::error as serde_json_error;
use std::error;
use std::fmt;
use std::io;
use std::result;
/// Error types for kvs
#[derive(Debug)]
pub enum KvsError {
/// IO error
IO(io::Error),
/// Error from crate `serde_json`
Serde(serde_json_error::Error),
/// Error from crate `sled`
Sled(sled... | true |
b3aa0f99e3f3dbed38d49f7c894b1cb0a333e144 | Rust | hawkw/async-workshop | /vendor/futures-preview/tests/async_await_macros.rs | UTF-8 | 5,333 | 2.75 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #![recursion_limit="128"]
#![feature(async_await)]
use futures::{Poll, pending, pin_mut, poll, join, try_join, select};
use futures::channel::{mpsc, oneshot};
use futures::executor::block_on;
use futures::future::{self, FutureExt};
use futures::stream::StreamExt;
use futures::sink::SinkExt;
#[test]
fn poll_and_pendin... | true |
ba5c508c05c183b04110f32c19542bf97358d1e7 | Rust | qiniu/rust-sdk | /http/src/callback.rs | UTF-8 | 4,032 | 2.9375 | 3 | [
"MIT"
] | permissive | use anyhow::Result as AnyResult;
use http::{header::HeaderName, HeaderValue, StatusCode};
use std::{
fmt::{self, Debug},
ops::Deref,
};
macro_rules! impl_callback {
($name:ident, $name_str:literal, $callback:path) => {
impl<'r> $name<'r> {
/// 创建回调函数
#[inline]
pu... | true |
831ca6b9ed853e41f85952dafdcf15f3dab57157 | Rust | GraCosPA/rustcmb | /examples/core_torus.rs | UTF-8 | 1,295 | 2.640625 | 3 | [
"MIT"
] | permissive | extern crate rustcmb;
use rustcmb::core::torus;
const SIZE: usize = 4;
fn main() {
let default_field = torus::Field::default();
let field = torus::Field::new(SIZE);
let mut mut_field = torus::Field::new(SIZE);
println!("default_field: {:?}", default_field);
println!("field: {:?}", field);
pr... | true |
de1c94d3ebc4ef81a86299790e42ebafe4d88f8b | Rust | leeola/hash-roll | /tests/simple.rs | UTF-8 | 740 | 2.640625 | 3 | [] | no_license | extern crate hash_roll;
use hash_roll::Splitter;
#[test]
fn simple() {
let x = hash_roll::Rsyncable::with_window_and_modulus(4, 8);
let d_ = b"32266fsdasas";
let d = d_;
let mut c = 0;
let l = x.find_chunk_edge(d);
c += l;
assert_eq!(l, 5);
let d = &d[l..];
let l = x.find_chunk_edge... | true |
8773ba939329aee88a1ce84754f9fa171e2195af | Rust | SilanSurfer/pngme | /src/operation.rs | UTF-8 | 2,405 | 2.890625 | 3 | [] | no_license | use crate::arg;
use crate::chunk;
use crate::chunk_type;
use crate::error;
use crate::png;
use std::convert::TryFrom;
use std::fs;
use std::str::FromStr;
pub fn run(args: arg::PngMeCliArgs) -> Result<(), error::PngMeError> {
match args {
arg::PngMeCliArgs::Encode(arg) => encode(arg)?,
arg::PngMeCli... | true |
4ed1610d4b56154952e90ce12ed3de86b63c08f1 | Rust | M4urici0GM/port-scanner | /src/main.rs | UTF-8 | 817 | 2.6875 | 3 | [
"MIT",
"curl"
] | permissive | mod scanner;
use std::env;
use std::time::Instant;
use scanner::argument_parser::ArgumentParser;
use scanner::port_scanner::PortScanner;
fn main() {
let args: Vec<String> = env::args().collect();
let argument_parser = ArgumentParser::new(args);
let parsed_arguments = argument_parser.parse();
let curren... | true |
bc730df20f56684049a2644c0fe184bded872473 | Rust | khrynczenko/rtsc | /src/parser/mod.rs | UTF-8 | 2,729 | 3.046875 | 3 | [
"MIT"
] | permissive | pub mod combinators;
mod expression;
mod statement;
use super::ast::Ast;
use crate::parser::combinators as cmb;
use crate::parser::expression as exp;
use crate::parser::statement as stmt;
use combinators::Parser;
pub fn make_full_parser<'a>() -> impl Parser<'a, Ast> {
cmb::map(
cmb::and(
exp:... | true |
3ebb03b44cbc3438d037609b6732d682689b3d2a | Rust | felipecsl/ferrocarril | /mruby/src/macros.rs | UTF-8 | 5,373 | 3.09375 | 3 | [
"MIT"
] | permissive | //! This module defines macros for working with interpreters and `Value`s. This
//! source module is included first in `lib.rs`, which means the macros are
//! available to all modules within the mruby crate in addition to being
//! exported.
/// Extract an [`Mrb`](interpreter::Mrb) instance from the userdata on a
///... | true |
443870a5fb0f0e17dfa9e3d7d9158697a57f79cb | Rust | Jekshmek/podcore | /src/html.rs | UTF-8 | 6,335 | 3.375 | 3 | [] | no_license | use std::default::Default;
use std::io::BufReader;
use std::string::String;
use html5ever::parse_document;
use html5ever::rcdom::{Handle, NodeData, RcDom};
use html5ever::tendril::TendrilSink;
pub fn sanitize(s: &str) -> String {
let mut buf = BufReader::new(s.as_bytes());
let mut out = String::new();
le... | true |
9131440be3eb66f1375762e6dacd6b1f76f57eab | Rust | necauqua/entropic | /src/input.rs | UTF-8 | 9,306 | 2.96875 | 3 | [
"MIT"
] | permissive | use std::{io, thread};
use std::io::{ErrorKind, Read};
use crossbeam_channel;
use crossbeam_channel::Receiver;
use crate::state::Position;
#[derive(Copy, Clone, Debug)]
pub enum MouseButton {
Left,
Middle,
Right,
}
#[derive(Copy, Clone, Debug)]
pub enum MouseWheelDirection {
Up,
Down,
}
#[deriv... | true |
5f7a4dd7377bbd101d0551b8616431a19fd6c4e1 | Rust | Disasm/rpi-os-fs | /fat32/src/vfat/file_system_object.rs | UTF-8 | 1,382 | 2.9375 | 3 | [] | no_license | use vfat::{VFatFile, VFatDir};
use vfat::VFatEntry;
use vfat::ArcMutex;
use vfat::VFatFileSystem;
use traits::FileSystemObject;
pub struct VFatObject {
vfat: ArcMutex<VFatFileSystem>,
first_cluster: u32,
size: u32,
is_dir: bool,
}
impl VFatObject {
pub fn from_entry(vfat: ArcMutex<VFatFileSystem>,... | true |
08ad8d7d99b1b5a4d8b4b9038a35313d9dbdaf2d | Rust | tbarrella/crypto-pure | /src/hmac.rs | UTF-8 | 9,174 | 3.375 | 3 | [
"Apache-2.0"
] | permissive | //! Module for creating and verifying HMAC tags.
use crate::sha2::{HashFunction, Sha224, Sha256, Sha384, Sha512, MAX_DIGEST_SIZE};
use crate::util;
use core::ops::Deref;
/// A function for creating and verifying HMAC tags given a hash function `H`.
///
/// # Examples
///
/// ```
/// use crypto_pure::hmac::{verify, Hma... | true |
35a3121513462f288e53ecd662bd0bf156b2323c | Rust | Wilfred/difftastic | /src/options.rs | UTF-8 | 26,163 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | //! CLI option parsing.
use std::{env, ffi::OsStr, path::Path, path::PathBuf};
use clap::{crate_authors, crate_description, Arg, Command};
use const_format::formatcp;
use crossterm::tty::IsTty;
use itertools::Itertools;
use crate::{
display::style::BackgroundColor,
exit_codes::EXIT_BAD_ARGUMENTS,
parse::... | true |
59fd0ec8f9f5c6294912ff7cb2395d9e71eefd4c | Rust | coreylowman/projectEuler | /src/problems/problem032.rs | UTF-8 | 1,181 | 3.28125 | 3 | [] | no_license | fn has_all(mut a: u64, mut b: u64) -> bool {
let mut c = a * b;
let mut digs = [0; 10];
while a > 0 {
digs[(a % 10) as usize] += 1;
a /= 10;
}
while b > 0 {
digs[(b % 10) as usize] += 1;
b /= 10;
}
while c > 0 {
digs[(c % 10) as usize] += 1;
... | true |
a68e47d854b0d46e09f162b93a7689e1a0e8dcbf | Rust | diegopy/teloxide | /tests/sqlite.rs | UTF-8 | 2,151 | 2.640625 | 3 | [
"MIT"
] | permissive | use std::{
fmt::{Debug, Display},
future::Future,
sync::Arc,
};
use teloxide::dispatching::dialogue::{Serializer, SqliteStorage, Storage};
#[tokio::test(flavor = "multi_thread")]
async fn test_sqlite_json() {
let storage =
SqliteStorage::open("./test_db1.sqlite", teloxide::dispatching::dialogue... | true |
16dc1ddad5321dcaef63cf6ac58d9588b7c08bfd | Rust | marco-c/gecko-dev-wordified | /third_party/rust/flate2/examples/compress_file.rs | UTF-8 | 987 | 2.5625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | extern
crate
flate2
;
use
flate2
:
:
write
:
:
GzEncoder
;
use
flate2
:
:
Compression
;
use
std
:
:
env
:
:
args
;
use
std
:
:
fs
:
:
File
;
use
std
:
:
io
:
:
copy
;
use
std
:
:
io
:
:
BufReader
;
use
std
:
:
time
:
:
Instant
;
fn
main
(
)
{
if
args
(
)
.
len
(
)
!
=
3
{
eprintln
!
(
"
Usage
:
.
/
compress_file
source... | true |
3805f631d00e996b67fec3684309837202a6fb59 | Rust | mabels/ipaddress | /rust/src/rle.rs | UTF-8 | 2,617 | 3.1875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use std::collections::HashMap;
use core::hash::Hash;
use core::cmp::Eq;
use core::fmt::Display;
use core::clone::Clone;
use core::fmt::LowerHex;
use std::fmt;
#[derive(Copy, Clone)]
pub struct Rle<T> {
pub part: T,
pub pos: usize,
pub cnt: usize,
pub max: bool
}
impl<T: Display + LowerHex> fmt::Debug ... | true |
f191e8bd5019d0958917c1c64975229b09f9f2cd | Rust | 0xazure/sidecar | /src/lib.rs | UTF-8 | 6,971 | 2.84375 | 3 | [] | no_license | use anyhow::{bail, Context, Result};
use counter::{Counter, TagCount};
use std::collections::HashMap;
use std::fs::{self, File};
use std::io::{BufRead, BufReader, Write};
use std::path::{Path, PathBuf};
use structopt::StructOpt;
mod counter;
mod parser;
#[derive(StructOpt, Debug)]
pub struct CommonOpts {
#[struct... | true |
455b832957283bcc399962f5d3411deba515c883 | Rust | solana-labs/solana | /core/src/consensus/tower_storage.rs | UTF-8 | 14,255 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | use {
crate::consensus::{
tower1_14_11::Tower1_14_11, tower1_7_14::SavedTower1_7_14, Result, Tower, TowerError,
TowerVersions,
},
solana_sdk::{
pubkey::Pubkey,
signature::{Signature, Signer},
},
std::{
fs::{self, File},
io::{self, BufReader},
p... | true |
a4d9d0ee891c6309b228c3af7fffd14782942956 | Rust | kaj/ructe | /examples/simple/src/main.rs | UTF-8 | 7,799 | 3.109375 | 3 | [] | no_license | #![allow(dead_code)] // Most templates here are only used in tests.
use std::io;
include!(concat!(env!("OUT_DIR"), "/templates.rs"));
use crate::templates::*;
fn main() {
page::page_html(&mut io::stdout(), "sample page").unwrap();
}
fn r2s<Call>(call: Call) -> String
where
Call: FnOnce(&mut Vec<u8>) -> io::... | true |
6af75d0cc0d62d9e164a6863885c2caea0a721b8 | Rust | tylerreisinger/rust-float-duration | /src/duration.rs | UTF-8 | 33,454 | 3.578125 | 4 | [
"MIT"
] | permissive | //! Floating-point duration type `FloatDuration` and helpers.
use std::time;
use std::fmt;
use std::ops;
use std::f64;
use std::u64;
use std::iter::Sum;
#[cfg(feature = "chrono")]
use chrono;
#[cfg(feature = "approx")]
use approx::ApproxEq;
#[cfg(feature = "serde")]
use serde::{Serialize, Deserialize, Serializer, Des... | true |
a62379264a83ac2b8ec12dcacc4801de248ffe3e | Rust | vexy/monogo-rust | /src/mongoclient.rs | UTF-8 | 1,844 | 2.984375 | 3 | [
"MIT"
] | permissive | use mongodb::{Client, options::ClientOptions, Collection};
#[derive(Clone, Debug)]
pub struct MongoClient {
pub collection: Collection
}
impl MongoClient {
pub async fn proxy_for(database: &str, collection: &str) -> Self {
// build connection options
let connection_string = parse_environment_v... | true |
c6a4379a00df6175d14c82a0c4452e972e6c3a1f | Rust | orb1t-ua/core-os-riscv | /user/src/print.rs | UTF-8 | 898 | 2.640625 | 3 | [
"MIT"
] | permissive | // Copyright (c) 2020 Alex Chi
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
use core::fmt::{Write, Error, self};
use crate::syscall;
struct StdIO {}
impl StdIO {
pub fn new() -> Self {
StdIO {}
}
}
impl Write for StdIO {
fn write_str(&mut self, ou... | true |
21e205e52759dc387dc134eadc3bb28a6b2d961f | Rust | harpsword/tex-rs | /src/tex_the_program/section_0217.rs | UTF-8 | 822 | 2.78125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! @ Conversely, when \TeX\ is finished on the current level, the former
//! state is restored by calling |pop_nest|. This routine will never be
//! called at the lowest semantic level, nor will it be called unless |head|
//! is a node that should be returned to free memory.
//
// @p procedure pop_nest; {leave a seman... | true |
dfe0413e0c4a9423f81c5518c4394ac8f9ad06fe | Rust | kognise/avigraph | /src/arinc424/fields/p041_region_code.rs | UTF-8 | 1,107 | 3.203125 | 3 | [] | no_license | use crate::arinc424::utils::parseable::Parseable;
use crate::arinc424::utils::string_reader::StringReader;
/**
The "Region Code" permits the categorization of waypoints and holding patterns
as either enroute or terminal area waypoints. In the latter case the terminal
area airport is identified in the field.
The field... | true |
0085e9ec066f53a76f528ec1817836cdcf319e29 | Rust | MindFlavor/azure-sdk-for-rust | /sdk/storage/src/table/clients/table_service_client.rs | UTF-8 | 3,342 | 2.71875 | 3 | [
"MIT",
"LicenseRef-scancode-generic-cla",
"LGPL-2.1-or-later"
] | permissive | use crate::core::clients::{StorageAccountClient, StorageClient};
use crate::table::requests::ListTablesBuilder;
use bytes::Bytes;
use http::method::Method;
use http::request::{Builder, Request};
use std::sync::Arc;
use url::Url;
pub trait AsTableServiceClient {
fn as_table_service_client(&self) -> Result<Arc<Table... | true |
a4105c8dddcff091e67ef1eb7f21815c5274d097 | Rust | ml47-srl/b.3-linbot | /src/idea.rs | UTF-8 | 1,385 | 2.765625 | 3 | [] | no_license | use super::action::Action;
use libsrl::cell::Cell;
use libsrl::db::Database;
use super::chance::gen_range;
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Idea {
actions : Vec<Action>
}
impl Idea {
pub fn proof(&self, rule : &Cell, db : &mut Database) -> bool {
let mut count : usize = 0;
for action i... | true |
3e5478a56ffe7a83000d3d163b7200716be87f0e | Rust | runec/advent-of-code-2020 | /solutions/day07.rs | UTF-8 | 3,619 | 3 | 3 | [] | no_license | use crate::helpers;
use std::error::Error;
use std::collections::HashMap;
const INPUT_FILE: &str = "input/day07";
type BagRules = HashMap<String, Vec<(String, u32)>>;
pub fn solve() -> Result<(), Box<dyn Error>> {
let rules = parse_input()?;
let reversed_rules = get_reversed_rules(&rules);
solve_part_one(&rul... | true |
8aa468c6bcd85d112fb360a6be64336f5fe74b62 | Rust | lar-rs/hal | /src/pump.rs | UTF-8 | 777 | 2.828125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | /// Lamp UV
use embedded_hal::digital::v2::OutputPin;
// use embedded_hal::timer::CountDown;
// use embedded_hal::timer::Periodic;
// use nb::block;
use super::error::Error;
pub trait Pump {
fn start( &mut self) -> nb::Result<(), Error>;
fn stop( &mut self) -> nb::Result<(), Error>;
}
/// GearPump
pub struc... | true |
1cf4891f64cab5a7e4af0ed0164bb7dc3ff12a68 | Rust | monocodus-demonstrations/flowbetween | /render/src/metal_renderer/matrix_buffer.rs | UTF-8 | 1,801 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | use super::bindings::*;
use crate::buffer::*;
use metal;
use cocoa::foundation::{NSRange};
use std::ptr;
use std::mem;
use std::ops::{Deref};
use std::ffi::{c_void};
///
/// Manages a metal buffer containing a matrix
///
pub struct MatrixBuffer {
/// The buffer that this is managing
buffer: metal::Buffer
}
... | true |
5eb7dd62c48fbf143654dec91062aa7445db4fc6 | Rust | povilasb/rust-playground | /binary-tree/src/tree.rs | UTF-8 | 6,572 | 3.5 | 4 | [] | no_license | use std::mem;
use std::cmp::max;
use std::fmt;
#[derive(Debug)]
pub struct Node {
pub left: Option<Box<Node>>,
pub right: Option<Box<Node>>,
pub value: u64,
index: usize,
}
impl Node {
fn new(value: u64, index: usize) -> Node {
Node{left: None, right: None, value: value, index: index}
... | true |
36b274870fda4416fdea6449af87a7a5da6d9cfa | Rust | aschuhardt/mud_response | /src/response.rs | UTF-8 | 1,451 | 2.9375 | 3 | [] | no_license | //response.rs
use std::net;
use rustc_serialize::json;
use std::io::Write;
pub const CODE_TOKEN_ACKNOWLEDGE: u8 = 0;
pub const CODE_CONNECT_ACCEPT: u8 = 1;
pub const CODE_CONNECT_REJECT: u8 = 2;
pub const CODE_DISCONNECT_ACK: u8 = 3;
#[derive(Clone)]
pub struct Response {
pub code: u8,
pub addr: net::SocketA... | true |
5053fa970735052f7b009cfbcea89c440032f4bc | Rust | topmop2/gateway-rs | /src/keyed_uri.rs | UTF-8 | 1,333 | 3.03125 | 3 | [
"Apache-2.0"
] | permissive | use crate::PublicKey;
use http::Uri;
use serde::{de, Deserialize, Deserializer};
use std::{fmt, sync::Arc};
/// A URI that has an associated public key
#[derive(Clone, Deserialize, Eq)]
pub struct KeyedUri {
#[serde(with = "http_serde::uri")]
pub uri: Uri,
#[serde(deserialize_with = "deserialize_pubkey")]
... | true |
196bb9702049b1a15c0659b4ec34f569519e3460 | Rust | decentriq/rustlearn | /src/svm/libsvm/ffi.rs | UTF-8 | 12,849 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | //! Internals of the `libsvm` FFI.
//!
//! Objects whose names start with `Libsvm` are for the most part
//! things that we pass or get directly from `libsvm`, and are highly
//! fragile.
//!
//! Their safe, memory-owning counterparts start with `Svm`.
use std::ffi::CStr;
use std::os::raw::c_char;
use std::slice;
use... | true |
2b3c58716bc63a2aec9a2c2ea443605e109aece9 | Rust | drakeor/rust-neural-net | /src/main.rs | UTF-8 | 2,680 | 3.15625 | 3 | [] | no_license | extern crate rulinalg;
extern crate rand;
use rulinalg::matrix::BaseMatrix;
use rulinalg::matrix::Matrix;
use rulinalg::matrix::BaseMatrixMut;
// Primary neural network structure
pub struct NeuralNetwork {
inputLayerSize : i32,
outputLayerSize : i32,
hiddenLayerSize : i32,
w1: Matrix<f32>,
w2: Mat... | true |
e2ed7092bca99d9cfc69cbfa7ebef037a9e3966a | Rust | simonalong/rust-learn | /greeting/src/lang/closure.rs | UTF-8 | 3,254 | 4.03125 | 4 | [] | no_license |
fn main() {
test_closure_1();
test_closure_2();
test_closure_3();
test_closure_4();
test_closure_5();
}
// 作为函数直接调用
fn test_closure_1() {
let data = || 42;
println!("test_closure_1 data1 {}", data());
let data = |x| 42 + x;
println!("test_closure_1 data2 {}", data(1));
let da... | true |
343ffe4b48c76f70169bfeeecb946edcc8a1f47b | Rust | SecInTheShell/tecuzzor | /syscall-fuzzer-U/fuzzer_types/src/types/stdimpl.rs | UTF-8 | 1,725 | 2.828125 | 3 | [
"MIT"
] | permissive | //! traits implementations for primitive types and the types defined in std lib
use super::*;
use std::cell::Cell;
use std::rc::Rc;
impl Generate for u8 {
fn generate(gen: &mut StdRng) -> u8 {
gen.gen_range(0..127) as u8
}
}
impl Generate for c_int {
fn generate(gen: &mut StdRng) -> i32 {
... | true |
15e9b2bc80aa9c0ad37fc052469843d1dce8c7cb | Rust | ConnorBP/xorstring | /src/lib.rs | UTF-8 | 2,359 | 3.734375 | 4 | [
"BSD-3-Clause"
] | permissive | //! XOR encrypted strings for Rust.
//!
//! These are simply a port of LeFF's C++11 compile-time hacky XOR strings.
#![feature(proc_macro_hygiene)]
/// The XOR string proc-macro used under the hood.
///
/// This is available in the case that a raw byte array of the encrypted string
/// is preferred over an auto-decry... | true |
9b1e8ab93d6cc0351d9614097747f6f829611483 | Rust | decadevvv/influxdb_iox | /server/src/query_tests/utils.rs | UTF-8 | 3,514 | 2.734375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use data_types::{
chunk::{ChunkStorage, ChunkSummary},
database_rules::DatabaseRules,
server_id::ServerId,
DatabaseName,
};
use object_store::{disk::File, ObjectStore};
use query::{exec::Executor, Database};
use crate::{db::Db, JobRegistry};
use std::{convert::TryFrom, sync::Arc};
use tempfile::TempDir... | true |
b7aac58ec2691a551f03e4b917a74b8e5833c28b | Rust | G1gg1L3s/ies | /signal/src/bin/lab2-cmp.rs | UTF-8 | 750 | 2.640625 | 3 | [] | no_license | use signal::{correlation, gen_signal};
use std::time::{Duration, Instant};
const HARMONICS: usize = 1024;
const FREQUENCY: usize = 1024;
const INTERVALS: usize = 1 << 19;
const DT: f64 = 0.01;
fn test(a: &[f64], b: &[f64]) -> Duration {
let timer = Instant::now();
let corr = correlation(a, b);
fn id<T>(x:... | true |
b1930117684b0da6334d8f57883e8aae1aeb0cfa | Rust | mdnmdn/todux | /src/database.rs | UTF-8 | 923 | 2.703125 | 3 | [
"MIT"
] | permissive | use crate::todo::TodoData;
use std::fs::{self, File};
use crate::sys;
use crate::log;
pub fn read(db_filename: &str) -> TodoData {
match File::open(db_filename) {
Ok(db_file) => serde_json::from_reader(db_file).expect("Invalid json"),
Err(_) => create(db_filename)
}
}
fn create(db_filename: &s... | true |
919933aee6f14b696f09560ef8fc17172b22974f | Rust | gereeter/rust-rays | /src/vec.rs | UTF-8 | 1,769 | 3.625 | 4 | [
"MIT"
] | permissive | use std::ops::{Add, Sub, Neg, Mul, Div};
#[derive(Copy, Clone)]
pub struct Vec3 {
vals: [f32; 3]
}
impl Vec3 {
pub fn new(x: f32, y: f32, z: f32) -> Vec3 {
Vec3 {
vals: [x, y, z]
}
}
pub fn dot(self, other: Vec3) -> f32 {
self.vals[0] * other.vals[0] + self.vals[1] * other.vals[1] + self.val... | true |
5eb923941d3962177ec322f918c01e37a1fde2d4 | Rust | visioncortex/polypartition | /visioncortex/src/sat.rs | UTF-8 | 7,279 | 3.546875 | 4 | [] | no_license | use crate::{ColorImage, PointI32};
/// A data structure to efficiently compute summed pixel values over regions in an image (repeatedly).
pub struct SummedAreaTable {
pub sums: Vec<u32>,
pub width: usize,
pub height: usize,
}
impl SummedAreaTable {
/// Creates an SAT of the same size of image, where e... | true |
648204ccb26c88ebd42d755aed1bddc39fac659a | Rust | 223kazuki/rust-exercise | /rust-book/6/workspace/src/main.rs | UTF-8 | 1,173 | 3.34375 | 3 | [] | no_license | enum IpAddrKind {
V4,
V6,
}
struct IpAddr {
kind: IpAddrKind,
address: String,
}
fn route(ip_type: IpAddrKind) {
}
enum IpAddr2 {
V4(u8, u8, u8, u8),
V6(String),
}
#[derive(Debug)]
enum UsState {
Alabama,
Alaska,
}
fn plus_one(x: Option<i32>) -> Option<i32> {
match x {
... | true |
cd2578bc9cb982b3ba8d3130abd305e3faf7e746 | Rust | exercism/rust | /exercises/practice/matching-brackets/.meta/example.rs | UTF-8 | 2,100 | 3.34375 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
pub fn brackets_are_balanced(string: &str) -> bool {
Brackets::from(string).are_balanced()
}
struct Brackets {
raw_brackets: Vec<char>,
pairs: MatchingBrackets,
}
impl<'a> From<&'a str> for Brackets {
fn from(i: &str) -> Self {
Brackets::new(i, None)
}
}
im... | true |
6f6c500968e0f467909184854966464bad010298 | Rust | BeastNeedsMoreTorque/football-simulator | /src/core/src/simulator.rs | UTF-8 | 7,473 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | use crate::context::{GlobalContext, SimulationContext};
use crate::continent::{Continent, ContinentResult};
use crate::league::League;
use crate::shared::SimulatorDataIndexes;
use crate::transfers::TransferPool;
use crate::utils::Logging;
use crate::{Club, Country, Player, Team};
use chrono::{Duration, NaiveDateTime};
... | true |
9f0e1fb2a1fcfe655cbab6783601411209cb55bd | Rust | Specy/s68k | /src/semantic_checker.rs | UTF-8 | 37,661 | 2.578125 | 3 | [
"MIT"
] | permissive | //TODO some instructions might accept indirect and also displacement, check that
use crate::{
lexer::{LexedLine, LexedOperand, LexedRegisterType, LexedSize, ParsedLine},
utils::{num_to_signed_base, parse_absolute_expression}, instructions::Label,
};
use bitflags::bitflags;
use serde::{Deserialize, Serialize};
... | true |
892d6963c8071241c054f0cbb2434118264d090c | Rust | mxxo/kalman-planes | /src/bin.rs | UTF-8 | 1,704 | 2.765625 | 3 | [] | no_license | extern crate approx;
extern crate nalgebra; // helper linear algebra library // relative_eq! macros for floating point comparisons
use nalgebra::{Affine3, Point2, Point3, Rotation3, Translation3, Vector2, Vector3};
// add our geo module
extern crate geo;
use geo::{Plane, RectBounds};
fn main() {
let plane1 = geo... | true |
f3c502f09f29c7b4dd0e0a75edfaa2bb9f0d220a | Rust | birkenfeld/ads-rs | /examples/timing.rs | UTF-8 | 1,017 | 2.6875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | fn dumb() {
let mut sock = std::net::TcpStream::connect("127.0.0.1:48999").unwrap();
use std::io::{Read, Write};
let now = std::time::Instant::now();
for _ in 0..5000 {
let mut buf = [0; 50];
sock.write_all(b"\
\0\0(\0\0\0\x7f\0\0\x01\x01\x01\0\0\x01\x02\x03\x04\x05\x06S\x03\... | true |
099e142846870bb7231a47050f4cc6afa760e301 | Rust | lambdaxymox/fuchsia | /third_party/rust_crates/vendor/paste/src/doc.rs | UTF-8 | 2,785 | 3.203125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"BSD-2-Clause"
] | permissive | use proc_macro::{Delimiter, Span, TokenStream, TokenTree};
use std::iter;
use std::str::FromStr;
pub fn is_pasted_doc(input: &TokenStream) -> bool {
#[derive(PartialEq)]
enum State {
Init,
Doc,
Equal,
First,
Rest,
}
let mut state = State::Init;
for tt in inp... | true |
2d63f85b2b3adc46d43be2d4405b97645cd5bb28 | Rust | meganehouser/pwwr | /src/rawio.rs | UTF-8 | 1,198 | 3.09375 | 3 | [
"MIT"
] | permissive | use std::io::{Read, Seek, SeekFrom, Write};
use std::fs::{File, OpenOptions};
use std::path::PathBuf;
use errors::*;
pub trait RawStore {
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize>;
fn write_all(&mut self, buf: &[u8]) -> Result<()>;
}
pub struct FileRawStore {
file: File,
}
impl FileRa... | true |
0d73fd5626e952c11d1e414373965474b2bf4af9 | Rust | agerasev/hypertrace | /types/src/entity.rs | UTF-8 | 1,652 | 3.015625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::{
hash::DefaultHasher,
io::{CntRead, CntWrite},
source::SourceTree,
Config,
};
use std::{
any::TypeId,
hash::{Hash, Hasher},
io,
};
/// Identifiable entity.
pub trait EntityId: 'static + Sized {
/// Type name and prefix.
fn name() -> (String, String);
/// Type unique... | true |
40b0ee69a4757ad417d24c6fd2c8c293a79e7a15 | Rust | partim/cloudship | /src/util/abnf/core.rs | UTF-8 | 11,734 | 3.421875 | 3 | [] | no_license | //! Core Rules
//!
//! These are defined in RFC 5234, appendix B.1.
//!
use nom::{self, Err, ErrorKind, Needed};
use nom::IResult::{Error, Done, Incomplete};
use super::{IResult, Result};
//------------ Test and Translation Functions -------------------------------
/// Test for ALPHA
///
/// > ALPHA = %x4... | true |
473af3fa8452d8218aa990addeb7df7b745e4e8e | Rust | ReSpeak/rust-ts3plugin | /src/lib.rs | UTF-8 | 28,114 | 2.796875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! A crate to create TeamSpeak3 plugins.
//!
//! # Example
//!
//! A fully working example, which creates a plugin that does nothing:
//!
//! ```
//! #[macro_use]
//! extern crate ts3plugin;
//!
//! use ts3plugin::*;
//!
//! struct MyTsPlugin;
//!
//! impl Plugin for MyTsPlugin {
//! fn name() -> String { S... | true |
f0ab0dc59fb11d974fae37c9df0d7d72a0eeafdf | Rust | matter-labs/zksync | /core/lib/types/src/helpers.rs | UTF-8 | 9,275 | 2.734375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use num::{BigUint, FromPrimitive};
use zksync_crypto::params;
use zksync_crypto::primitives::FloatConversions;
use crate::{Account, AccountMap, AccountUpdates};
/// Given the account map, applies a sequence of updates to the state.
pub fn apply_updates(accounts: &mut AccountMap, updates: AccountUpdates) {
for (id... | true |
fb3919fbdf25f3a4e216c65eec99909945c80cee | Rust | mkhan45/rocket_sim | /src/error.rs | UTF-8 | 306 | 2.59375 | 3 | [] | no_license | use std::error::Error;
#[derive(Debug)]
pub enum GameError {}
impl std::fmt::Display for GameError {
fn fmt(
&self,
formatter: &mut std::fmt::Formatter<'_>,
) -> std::result::Result<(), std::fmt::Error> {
write!(formatter, "GameError")
}
}
impl Error for GameError {}
| true |
5f868e42a3159a5a5e0dd00b0914a3a07d270765 | Rust | azriel91/autexousious | /crate/asset_derive/src/lib.rs | UTF-8 | 4,918 | 2.875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | #![recursion_limit = "128"]
//! Provides the `#[derive(Asset)]` macro to implement the `amethyst::assets::Asset` trait.
//!
//! # Examples
//!
//! ```rust,edition2018
//! use asset_derive::Asset;
//!
//! #[derive(Asset, Clone, Debug)]
//! pub struct MyAsset {
//! pub value: u32,
//! }
//! ```
//!
//! Effectively g... | true |
3a363fef522fb59c27126aaa879530ab51803685 | Rust | rustyforks/tendril-wiki | /libs/www/src/handlers/sinks.rs | UTF-8 | 5,090 | 2.515625 | 3 | [] | no_license | use persistance::fs::{get_file_path, read, ReadPageError};
use render::{
link_page::LinkPage, new_page::NewPage, tag_index_page::TagIndex, wiki_page::WikiPage, Render,
};
use std::{collections::HashMap, time::Instant};
use tasks::CompileState;
use build::RefBuilder;
use logging::log;
use markdown::{
parsers::{... | true |
940f19084523b65f2948467835c84e03e667e636 | Rust | darrenldl/blockyarchive | /src/stdin_error.rs | UTF-8 | 1,574 | 3.015625 | 3 | [
"MIT"
] | permissive | use std::fmt;
pub use std::io::ErrorKind;
#[derive(Clone, Debug)]
pub struct StdinError {
pub kind: ErrorKind,
}
impl StdinError {
pub fn new(kind: ErrorKind) -> StdinError {
StdinError { kind }
}
}
pub fn to_err(e: StdinError) -> super::Error {
use super::{Error, ErrorKind};
Error::new(E... | true |
fbe1f270886bd8e94892bad6de36cf0dd84af5a1 | Rust | kevinw/encasa | /src/homepage_data/src/datetools.rs | UTF-8 | 733 | 3.0625 | 3 | [] | no_license |
pub enum DateWhen {
Past,
Future,
Today,
}
pub fn duration_relative_to_today(date: &::chrono::NaiveDate) -> ::time::Duration {
let today_naive = ::chrono::Local::today().naive_local();
today_naive.signed_duration_since(*date)
}
impl DateWhen {
pub fn for_duration(d: ::time::Durat... | true |
0b3a60e5d42e5aabfa792c85b25ad168c894a49b | Rust | aromatt/pushfour-rust | /src/diag_lookup.rs | UTF-8 | 3,122 | 3.09375 | 3 | [] | no_license | use util::*;
#[derive(Clone, Copy, Debug)]
struct DiagLookup {
main: [[Coord; BOARD_SIZE]; BOARD_SIZE],
rot: [[Coord; BOARD_SIZE]; BOARD_SIZE]
}
impl DiagLookup {
/* This struct contains lookup tables for translating regular board coordinates to
* coordinates in two diagonal rotations of the board ('... | true |
9c226eefeee42c274c44b91f69734aeff943a7dd | Rust | andresovela/probe-run | /src/dep/rust_std/toolchain.rs | UTF-8 | 4,338 | 3.21875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::borrow::Cow;
use colored::Colorize;
#[derive(Debug, Eq, PartialEq)]
pub enum Toolchain<'p> {
One52(One52<'p>),
Verbatim(&'p str),
}
impl<'p> Toolchain<'p> {
pub fn from_str(input: &str) -> Toolchain {
if let Some(toolchain) = One52::from_str(input) {
Toolchain::One52(toolchai... | true |
e06cae7f40d8f24aec08f52482ff3fecab031a2c | Rust | mhnghfv/cargo-licensepull | /src/main.rs | UTF-8 | 2,062 | 2.84375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"0BSD"
] | permissive | use cargo_metadata::{MetadataCommand};
use regex::Regex;
fn main() {
let mut argsi = std::env::args();
argsi.next();
argsi.next();
let args: Vec<String> = argsi.collect();
let metadata = MetadataCommand::new()
.other_options(args)
.exec()
.unwrap();
for package in metadata.packages ... | true |
bef89f83f3fa8b08923e6515048ffea86976dba1 | Rust | blueluna/microbit | /microbit-common/src/display/nonblocking/control.rs | UTF-8 | 4,910 | 3.03125 | 3 | [
"0BSD",
"BSD-3-Clause"
] | permissive | //! Implementation of [`DisplayControl`] for the micro:bit's GPIO peripheral.
//!
//! This controls the micro:bit's 5×5 LED display.
//!
//! [`DisplayControl`]: tiny_led_matrix::DisplayControl
use tiny_led_matrix::DisplayControl;
use crate::{
gpio::{NUM_COLS, NUM_ROWS},
pac,
};
const fn pin_bits(pins: &[usiz... | true |
3da3ada197d19eb008a6fc857533047fb81b1cf6 | Rust | MakotoE/rust-fah-pauser | /src/process.rs | UTF-8 | 5,912 | 2.8125 | 3 | [
"MIT"
] | permissive | use super::*;
extern crate test;
#[cfg(windows)]
extern crate winapi;
#[cfg(windows)]
use winapi::um::handleapi::INVALID_HANDLE_VALUE;
#[cfg(windows)]
use winapi::um::tlhelp32::{
CreateToolhelp32Snapshot, Process32First, Process32Next, PROCESSENTRY32, TH32CS_SNAPPROCESS,
};
#[cfg(target_family = "unix")]
pub fn f... | true |
cdd9c33b6bf12b5ef0ec0e35fdee14f4b761f09b | Rust | mattdeboard/rs-pugbot | /src/pugbot/commands/remove.rs | UTF-8 | 3,644 | 2.875 | 3 | [
"MIT"
] | permissive | use crate::models::game::GameContainer;
use crate::{queue_size, traits::has_members::HasMembers};
use serenity::framework::standard::macros::command;
use serenity::model::channel::Message;
use serenity::model::user::User;
use serenity::prelude::Context;
use serenity::{
builder::CreateEmbedAuthor, framework::standard:... | true |
8cbce3536d7592cd9bec5d64c3e2e735977894ff | Rust | thienhv/notes-1 | /rust/code/generic_programming_book/src/main.rs | UTF-8 | 1,628 | 3.78125 | 4 | [] | no_license | /**
* Goal:
*
* Make the fastest possible multiplication (assuming we can't use built-in `*`)
*
*/
use std::mem;
fn main() {
println!("Answer from multiple_1: {}", multiply_1(59, 41));
// println!("Answer from multiple2: {}", multiply2(59, 41));
// println!("Answer from multiple3: {}", multiply3(59, ... | true |
5512ed8eff5439fa77ad50ce3f31be362b033ea5 | Rust | kiwiyou/kiwitu | /front/src/module/roomlist.rs | UTF-8 | 1,754 | 2.875 | 3 | [] | no_license | use bridge::*;
use std::collections::HashMap;
use yew::prelude::*;
#[derive(Clone, PartialEq)]
pub struct RoomListProps {
pub rooms: HashMap<RoomId, RoomBrief>,
pub onclick: Option<Callback<RoomId>>,
}
pub enum Msg {
Clicked(RoomId),
}
pub struct RoomList {
rooms: HashMap<RoomId, RoomBrief>,
oncl... | true |
01900ce402b11294e082f0c6ef7b30732fd18124 | Rust | alsuren/jsonapis.rs | /src/entities/data.rs | UTF-8 | 4,170 | 3.328125 | 3 | [
"MIT"
] | permissive | use super::*;
impl Entity for Data {}
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum Data {
Single(Resource),
Multiple(Vec<Resource>),
}
impl Serialize for Data {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
match self {
Self... | true |
ea4d9fef8510aeb1cb90a225a1050144ef53cb71 | Rust | AlephAlpha/muicss-yew | /src/panel.rs | UTF-8 | 934 | 2.515625 | 3 | [] | no_license | use yew::prelude::*;
use yewtil::NeqAssign;
#[derive(Clone, Debug, PartialEq, Properties)]
pub struct Props {
#[prop_or_default]
pub children: Children,
#[prop_or_default]
pub class: Classes,
}
#[derive(Clone, Debug)]
pub struct Panel {
props: Props,
}
impl Component for Panel {
type Message ... | true |
d8a469d6aeb9d448caeda3334e62a07c3d7ff76b | Rust | jaynus/old-survival | /survival/src/goap.rs | UTF-8 | 13,975 | 2.578125 | 3 | [] | no_license | use amethyst::ecs::{
storage::UnprotectedStorage, world::Index, DenseVecStorage, Entity, World,
};
use hibitset::BitSet;
use indexmap::IndexSet;
use rayon::prelude::*;
use std::collections::HashMap;
use crate::assets::item::Property as ItemProperty;
use crate::actions::Action as ActionEvent;
use crate::components:... | true |
194a40b398187b25a33718c4a439e8a18374e26d | Rust | TheRealBluesun/cauchy_wasm | /src/cwasm/vm.rs | UTF-8 | 1,391 | 2.875 | 3 | [] | no_license | use super::*;
use std::io::{BufReader, Read};
enum StackItem {
ValueType,
}
pub struct VM {
stack: Vec<StackItem>,
}
impl VM {
pub fn new() -> VM {
VM {
stack: Vec::<StackItem>::new(),
}
}
pub fn run(&mut self, cwasm: &CWasm) {
// For now, just execute the firs... | true |
114ec1825174d3ce7296f324f04a7509e8c97276 | Rust | m9s/xmc1000 | /xmc1000/src/vadc_g0/bfl/mod.rs | UTF-8 | 34,127 | 2.71875 | 3 | [] | no_license | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::BFL {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut W... | true |
4e996c864ed2c61fea784c25de08f1363835e733 | Rust | mdowell12/advent-of-code-2020 | /solutions_fer/day4/src/main.rs | UTF-8 | 4,091 | 2.96875 | 3 | [] | no_license | use std::collections::HashMap;
use std::io::{self, BufRead};
extern crate regex;
use regex::Regex;
const REQUIRED_FIELDS: [&str; 7] = ["byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"];
struct Passport {
fields: HashMap<String, String>,
}
impl Passport {
pub fn new() -> Self {
Self {
field... | true |
c60e15a94ac8afe21b95283a35784b6c0b64540d | Rust | cezhang52111/mywasmi | /executor-test/src/lib.rs | UTF-8 | 1,011 | 2.609375 | 3 | [] | no_license | extern crate executor;
extern crate wasm_std as ext;
#[cfg(test)]
mod tests {
// Include wasm_kernel.wasm. It's wasm binary which contains all tests.
// See build.rs to see how it is built.
const WASM_KERNEL: &'static [u8] =
include_bytes!(concat!(env!("OUT_DIR"), "/wasm_kernel.wasm"));
use std... | true |
bb6dac0af39207658faa58624aba58ad10320801 | Rust | erictapen/nettle-rs | /src/cipher/insecure_do_not_use/arcfour.rs | UTF-8 | 2,700 | 3.15625 | 3 | [] | no_license | use nettle_sys::{
arcfour_ctx,
nettle_arcfour_set_key,
nettle_arcfour_crypt,
};
use std::mem::zeroed;
use std::os::raw::c_void;
use Cipher;
use cipher::RawCipherFunctionPointer;
/// Ron Rivest's RC4 stream cipher.
/// # Note
/// RC4 is no longer considered a secure cipher. Only use it for legacy applicatio... | true |
1258befe798f7c215a1d942405c9c070e25cf222 | Rust | 1011X/rever | /src/interpret/scope.rs | UTF-8 | 1,390 | 3.09375 | 3 | [
"0BSD"
] | permissive | use std::collections::HashMap;
use super::*;
pub struct StackFrame {
args: HashMap<String, Value>,
vars: Vec<(String, Value)>,
//items: HashMap<String, Value>,
}
impl StackFrame {
pub fn new(args: HashMap<String, Value>) -> Self {
Self {
args,
vars: Vec::new(),
//items: module,
}
}
pub fn pus... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.