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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
07f4d433b45f714f08442e1e81ff09de4c4e99b9 | Rust | FrancisMurillo/rust-mal | /mal/tests/step1_test.rs | UTF-8 | 3,495 | 3.109375 | 3 | [] | no_license | use std::fs;
use mal::{parse, Node};
const TEST_FILE: &str = "./tests/step1_read_print.mal";
fn exprs_print(exprs: &[Node]) -> String {
exprs
.iter()
.map(|inner_expr| expr_print(inner_expr))
.collect::<Vec<String>>()
.join(" ")
}
fn expr_print(expr: &Node) -> String {
match ... | true |
ee02f738e23e16ad4bd29f724f478246a0f00066 | Rust | influxdata/flux | /libflux/flux-core/src/parser/mod.rs | UTF-8 | 90,119 | 2.96875 | 3 | [
"MIT"
] | permissive | //! The Flux parser.
use std::{collections::HashMap, mem, str};
use ordered_float::NotNan;
use super::DefaultHasher;
use crate::{ast, ast::*, scanner, scanner::*};
mod strconv;
/// Parses a string of Flux source code.
///
/// Returns a [`File`] with the value of the `name` parameter
/// as the file name.
pub fn pa... | true |
bc824645fef23d74ffb362f904e32d26ff997043 | Rust | microsoft/onefuzz | /src/agent/onefuzz-task/src/tasks/generic/input_poller/tests.rs | UTF-8 | 5,683 | 2.9375 | 3 | [
"LicenseRef-scancode-generic-cla",
"MIT"
] | permissive | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
use anyhow::Result;
use async_trait::async_trait;
use reqwest::Url;
use std::path::Path;
use super::*;
type Msg = u64;
#[derive(Default)]
struct TestQueue {
pending: Vec<Msg>,
popped: Vec<Msg>,
deleted: Vec<Msg>,
}
#[async_trait... | true |
80f12b586b7ac4f76e21eeeddba6ca9e68aa99f1 | Rust | tivrfoa/rust | /trees/SameTree.rs | UTF-8 | 1,515 | 3.671875 | 4 | [] | no_license | use std::rc::Rc;
use std::cell::RefCell;
// Definition for a binary tree node.
#[derive(Debug, PartialEq, Eq)]
pub struct TreeNode {
pub val: i32,
pub left: Option<Rc<RefCell<TreeNode>>>,
pub right: Option<Rc<RefCell<TreeNode>>>,
}
impl TreeNode {
#[inline]
pub fn new(val: i32) -> Self {
TreeNode {
... | true |
80e1d78d5c62dd2cbf9cf6aca9e8d19142301bfe | Rust | PacktPublishing/Mastering-Rust | /Chapter06/borrows-1.rs | UTF-8 | 121 | 2.859375 | 3 | [
"MIT"
] | permissive | fn get_a_borrowed_value<'a>() -> &'a u8 {
let x = 1;
&x
}
fn main() {
let value = get_a_borrowed_value();
}
| true |
25d9619b7e4fe4d1f591c5e6cfb81e63a7f14c16 | Rust | khuey/futures-state-stream | /src/lib.rs | UTF-8 | 15,958 | 3.328125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! A version of the `futures` crate's `Stream` which returns a state value when it completes.
//!
//! This is useful in contexts where a value "becomes" a stream for a period of time, but then
//! switches back to its original type.
#![warn(missing_docs)]
#![doc(html_root_url="https://docs.rs/futures-state-stream/0.2"... | true |
9bcc654f292c64ba1668492eba3a128b1a517336 | Rust | thomasebsmith/armadillo | /src/parsing/tokenize.rs | UTF-8 | 2,793 | 3.46875 | 3 | [] | no_license | use std::str::Chars;
use std::iter::Peekable;
fn is_white_space(c: char) -> bool {
match c {
'\t' => true,
'\u{000B}' => true,
'\u{000C}' => true,
' ' => true,
'\u{00A0}' => true,
'\u{1680}' => true,
'\u{2000}' => true,
'\u{2001}' => true,
'\u... | true |
07f0d8a1c1920f9c16e0f9ca92edc7003b0f7a34 | Rust | semtexzv/rmaps | /common/src/util.rs | UTF-8 | 6,417 | 2.984375 | 3 | [] | no_license | use prelude::*;
use coord::*;
use mercator::*;
/// Structure holding information about Tile IDs needed to cover certain area at zoom level.
/// This structure is used to calculate which tiles need to be rendered
#[derive(Debug, Clone)]
pub struct TileCover(pub BTreeSet<UnwrappedTileCoords>);
impl TileCover {
fn ... | true |
39a4ed9bc168b8c3745c84bd9b461ee4df91755e | Rust | mileswatson/rust-raytracer | /src/tracing/scene.rs | UTF-8 | 1,306 | 3.015625 | 3 | [
"MIT"
] | permissive | use crate::tracing::{Color, Point, Ray, Vec3};
pub struct HitRecord<'a> {
pub point: Point,
pub normal: Vec3,
pub distance: f32,
pub front_face: bool,
pub material: &'a dyn Material,
}
impl HitRecord<'_> {
pub fn new(ray: Ray, distance: f32, normal: Vec3, material: &dyn Material) -> HitRecord ... | true |
ef7ab372dc2da0e72990e661711ea39ce3e5732d | Rust | jimmycuadra/retry | /src/lib.rs | UTF-8 | 11,287 | 4.25 | 4 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Crate `retry` provides utilities for retrying operations that can fail.
//!
//! # Usage
//!
//! Retry an operation using the [`retry`] function. [`retry`] accepts an iterator over
//! [`Duration`]s and a closure that returns a [`Result`] (or [`OperationResult`]; see below). The
//! iterator is used to determine how... | true |
931ddcad2d91880e80e28daf0bd7e6767a175e40 | Rust | chrisliebert/frustum_query | /src/frustum.rs | UTF-8 | 7,569 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | // Copyright (C) 2017 Chris Liebert
// Frustum extracting and testing algorithm used from
// http://www.racer.nl/reference/vfc_markmorley.htm
/// `Frustum`
///
/// A data structure for six planes of the view frustum
///
#[allow(unused)]
#[derive(Debug)]
pub struct Frustum {
// right left bottom top near and far p... | true |
a31c102a9933778560efd91eb93a4f2bccffc60f | Rust | neosam/rusty-blog | /tests/default-setup.rs | UTF-8 | 6,241 | 2.875 | 3 | [] | no_license | use std::{env::set_current_dir, error::Error, fmt::Display, fs::File, process::{self, Command}, thread::sleep, time::Duration};
use std::fmt::Debug;
use std::io::Write;
use std::io::Read;
use std::fs;
use anyhow::Context;
#[derive(Debug, Clone)]
struct TestError {
msg: String,
expected: String,
actual: Str... | true |
73785b22ec60def6613a6f4376f5b1b58e122c2d | Rust | dtolnay/proc-macro-workshop | /seq/tests/07-inclusive-range.rs | UTF-8 | 492 | 3.453125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | // The previous examples all used an exclusive range, MIN..MAX. Now make it work
// for an inclusive range MIN..=MAX that includes the upper range bound!
use seq::seq;
seq!(N in 16..=20 {
enum E {
#(
Variant~N,
)*
}
});
fn main() {
let e = E::Variant16;
let desc = match e... | true |
187952353bc4ac20bfb237df9cc2998a38069f07 | Rust | de-vri-es/sdl2-rust-skeleton | /src/main.rs | UTF-8 | 3,857 | 2.78125 | 3 | [] | no_license | use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::pixels::PixelFormatEnum;
use sdl2::rect::Rect;
use sdl2::render::Canvas;
use sdl2::video::Window;
use sdl2::render::TextureAccess;
use std::time::Instant;
use std::time::Duration;
fn main() -> Result<(), String> {
let context = sdl2::init().map_err(|e| f... | true |
89ccb01f50f13689e5a9672aa21143714b38ba22 | Rust | rust-lang/futures-rs | /futures/tests/io_lines.rs | UTF-8 | 1,662 | 2.8125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use futures::executor::block_on;
use futures::future::{Future, FutureExt};
use futures::io::{AsyncBufReadExt, Cursor};
use futures::stream::{self, StreamExt, TryStreamExt};
use futures::task::Poll;
use futures_test::io::AsyncReadTestExt;
use futures_test::task::noop_context;
fn run<F: Future + Unpin>(mut f: F) -> F::O... | true |
217a35086015003efbb0beea029358a4dd061471 | Rust | NGnius/casl | /src/command.rs | UTF-8 | 8,265 | 2.671875 | 3 | [] | no_license | use crate::speech::MetadataResult;
use crate::config::{Config, CommandConfig};
use std::process::{Command, Stdio};
use std::io::{BufWriter, BufReader, BufRead};
use crate::command_api::{Payload, Response, CommandAction};
use regex::{Regex, RegexBuilder};
use std::path::PathBuf;
const UDP_BUFFER_BYTES: usize = 8192;
p... | true |
d5ad229d697bd412fefaa85d35a54379227e5e74 | Rust | winksaville/fuchsia | /third_party/rust_crates/vendor/futures/src/unsync/mpsc.rs | UTF-8 | 14,815 | 3.015625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"BSD-3-Clause"
] | permissive | //! A multi-producer, single-consumer, futures-aware, FIFO queue with back
//! pressure, for use communicating between tasks on the same thread.
//!
//! These queues are the same as those in `futures::sync`, except they're not
//! intended to be sent across threads.
use std::any::Any;
use std::cell::RefCell;
use std::... | true |
05d8809b2cac5e4b36c85bd48ee3ac661190728e | Rust | techmccat/SODMB | /src/cache/mod.rs | UTF-8 | 4,932 | 2.640625 | 3 | [] | no_license | use crate::commands::utils::handle_io;
use http::Uri;
use serde_json::Value;
use serenity::async_trait;
use songbird::{
input::{cached::Compressed, Metadata},
Event, EventContext, EventHandler,
};
use sqlx::{any::AnyConnection, Connection, Executor, Row};
use std::{fs, path::Path, sync::Arc, time::Duration};
us... | true |
b579f9bd8a72174bd72d878c57f836ad24951e9c | Rust | manishmeganathan/automata | /src/gameoflife/cellgrid.rs | UTF-8 | 11,156 | 3.03125 | 3 | [
"MIT"
] | permissive | use ggez::graphics;
use ggez::GameResult;
use ggez::nalgebra as na;
use crate::simulation::{SimGrid, Automaton};
use crate::commons::cells::BinaryCell;
use crate::commons::grids::CellGrid;
use crate::gameoflife::GameOfLife;
/// Implementation of the Automaton trait for GameOfLife with a CellGrid grid,
impl Automaton ... | true |
fac0f138561c2dca4719efab9aa11106f97f8a59 | Rust | padoyle/advent2020 | /src/day_08.rs | UTF-8 | 4,562 | 3.5625 | 4 | [] | no_license | use std::collections::HashSet;
static INPUT: &'static str = include_str!("assets/day_08_input.txt");
#[derive(Debug, Clone, Copy)]
enum Instruction {
Acc { value: i32 },
Jmp { offset: i32 },
Nop { value: i32 },
}
impl From<&str> for Instruction {
fn from(s: &str) -> Self {
let tokens: Vec<&st... | true |
d1b4f4bc4cd0ff31b2c5d7f99c892ee4d346a768 | Rust | Shinmera/bsc-thesis | /benchmarks/src/operators/session.rs | UTF-8 | 4,144 | 2.90625 | 3 | [
"MIT"
] | permissive | use std::collections::{HashMap};
use std::hash::{Hash, Hasher};
use std::rc::Rc;
use timely::Data;
use timely::dataflow::channels::pact::Exchange;
use timely::dataflow::operators::Unary;
use timely::dataflow::{Stream, Scope};
use super::IntegerTimestamp;
pub trait Session<G: Scope, D: Data+Send> {
fn session<W, H>... | true |
64853638483df00e860a870cacdd846e81fca03e | Rust | Itanq/BlockChainRust | /src/consensus.rs | UTF-8 | 695 | 2.546875 | 3 | [] | no_license | use bigint::uint;
use crate::block::Block;
pub trait ProofOfWork {
fn proof_of_work(&mut self) -> [u8;32];
}
impl ProofOfWork for Block {
fn proof_of_work(&mut self) -> [u8; 32] {
let one = uint::U256::one();
let target = one << ( 256 - self.target_bits as usize );
while self.nonce ... | true |
fa07582b1dd2692139e46ad2cb96b3a505d91691 | Rust | LaplaceKorea/vicis | /src/ir/types/parser.rs | UTF-8 | 3,968 | 2.53125 | 3 | [
"MIT"
] | permissive | use super::super::types::{TypeId, Types};
use crate::ir::{module::name, util::spaces};
use nom::{
branch::alt,
bytes::complete::tag,
character::complete::{char, digit1},
combinator::map,
error::VerboseError,
sequence::preceded,
IResult,
};
pub fn parse<'a>(
source: &'a str,
types: &... | true |
a1ff8594329f5342b83a22caf686a05044bde459 | Rust | knarfytrebil/solang | /tests/variables.rs | UTF-8 | 2,340 | 3.09375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | extern crate solang;
use solang::output;
use solang::{parse_and_resolve, Target};
fn first_error(errors: Vec<output::Output>) -> String {
match errors.iter().find(|m| m.level == output::Level::Error) {
Some(m) => m.message.to_owned(),
None => panic!("no errors found"),
}
}
#[test]
fn test_var... | true |
9ce595ca30cf345c076a68faca6cd762143cda3c | Rust | NickHackman/git_detective-rs | /src/git/tag.rs | UTF-8 | 1,667 | 3.078125 | 3 | [
"MIT",
"GD",
"GPL-3.0-only"
] | permissive | use std::string::FromUtf8Error;
use crate::git::GitReference;
use crate::Error;
use crate::Signature;
/// A wrapper around [`git2::Tag`](https://docs.rs/git2/latest/git2/struct.Tag.html)
///
/// # Example
///
/// ```
/// # use git_detective::Error;
/// use git_detective::GitDetective;
/// # fn main() -> Result<(), Er... | true |
9f9d69204ecf7513c8c4b564dd5e0107ba41ef16 | Rust | paulkirkwood/rs.parcoursdb | /src/switzerland/mod.rs | UTF-8 | 1,653 | 2.59375 | 3 | [] | no_license | use crate::country::Country;
use crate::location::Location;
pub fn basel() -> Location { swiss_location("Basel", None) }
pub fn bern() -> Location { swiss_location("Bern", None) }
pub fn crans_montana() -> Location { swiss_location("Crans-Montana", Some(1670)) }
pub fn fribourg() -> Location { swiss_location("Fribou... | true |
5faacabc7ccec125a62a2918f6eab260708b5b89 | Rust | LiQingMuBai/Euler4Rustlang | /problem_4/src/main.rs | UTF-8 | 501 | 3.328125 | 3 | [] | no_license | fn main() {
println!("Hello, world!");
let mut n:u32 = 100000;
loop {
n += 1;
let array:Vec<u32> = n.to_string()
.chars()
.map(|c| c.to_digit(10).unwrap())
.collect();
if array[0]==array[5] && array[1]==array[4] && array[2]==array[3] {
println!("{:?}",a... | true |
b632836c5ad0a5d5944fb81548a9794acd49688d | Rust | J-AugustoManzano/livro_Rust | /ExerciciosAprendizagem/Cap07/c07ex01/src/main.rs | UTF-8 | 1,070 | 3.40625 | 3 | [] | no_license | use std::io;
use std::io::prelude::*;
fn main() {
let mut a = [0; 10];
let mut b = [0; 10];
let mut valor = String::new();
println!("Exemplo de checagem de índice\n");
// Entrada de dados
for i in 0..10 {
print!("Entre o {:2}o. valor: ", i... | true |
dfb024c940a0245ed6c5c6169f0dd1f4b1ef47b0 | Rust | nfcaspers/rust | /std-data-structures/vector/src/main.rs | UTF-8 | 351 | 3.234375 | 3 | [] | no_license | #![allow(dead_code)]
#![allow(unused_variables)]
enum FlexVector {
Int(i32),
Float(f64),
Str(String),
}
fn main() {
let v1: Vec<i32> = Vec::new();
let v2 = vec![1, 2, 3];
let mut v3 = Vec::new();
v3.push(1);
v3.push(2);
v3.push(3);
let third: Option<&i32> = v3.get(2);
print... | true |
6c2b81982499cba96e5448aa337bd2d1dd2e69fa | Rust | mellowagain/gitoxide | /git-traverse/src/tree/visit.rs | UTF-8 | 2,135 | 3.421875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use git_object::{bstr::BStr, immutable};
/// What to do after an entry was [recorded][Visit::visit_tree()].
#[derive(Clone, Copy, PartialOrd, PartialEq, Ord, Eq, Hash)]
pub enum Action {
/// Continue the traversal of entries.
Continue,
/// Stop the traversal of entries, making this te last call to [`visit_... | true |
83428a2e92f16246636ad877c8e56d43e00b41e0 | Rust | RickHuisman/fusion_old | /src/compiler/compiler.rs | UTF-8 | 3,671 | 3.03125 | 3 | [] | no_license | use crate::compiler::chunk::Chunk;
use crate::compiler::error::CompilerError;
use crate::compiler::instance::CompilerInstance;
use crate::compiler::object::{Function, FunctionType};
use crate::compiler::value::Value;
use crate::parser::ast::Identifier;
use crate::vm::opcode::Opcode;
pub struct Compiler {
current: ... | true |
9f2bc7a63a52d93c57d56b7bf20887df3117a5e1 | Rust | fdumontmd/adventofcode | /2015/day-20/src/main.rs | UTF-8 | 1,261 | 3.140625 | 3 | [] | no_license | use std::collections::BinaryHeap;
const TARGET: i64 = 29000000;
fn first_puzzle() -> i64 {
let mut wheel: BinaryHeap<(i64, i64)> = BinaryHeap::new();
for h in 1.. {
let mut total = h * 10;
while let Some(head) = wheel.pop() {
if head.0 != -h {
wheel.push(head);
... | true |
4b7f1df2bc5d664d7d162f3c7cc17755ebd48ae4 | Rust | rust-skia/rust-skia | /skia-safe/src/svg/canvas.rs | UTF-8 | 3,315 | 2.765625 | 3 | [
"MIT"
] | permissive | use crate::{interop::DynamicMemoryWStream, prelude::*, Data, Rect};
use skia_bindings::{self as sb, SkCanvas};
use std::{
fmt,
ops::{Deref, DerefMut},
pin::Pin,
ptr,
};
pub struct Canvas {
canvas: *mut SkCanvas,
stream: Pin<Box<DynamicMemoryWStream>>,
}
impl Drop for Canvas {
fn drop(&mut ... | true |
451d6bf98866e67b20019262369a893084479bbe | Rust | str4d/girage | /src/encrypt.rs | UTF-8 | 10,675 | 2.59375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use age::{keys::RecipientKey, Encryptor};
use gtk::prelude::*;
use gtk::{FileChooserAction, FileChooserDialog, Inhibit, Orientation::Vertical, ResponseType};
use relm::{Channel, EventStream, Relm, Widget};
use relm_derive::{widget, Msg};
use secrecy::SecretString;
use std::fs::File;
use std::io;
use std::path::PathBuf;... | true |
cd5d43c0f53563574db4b91e436928cd1d29b324 | Rust | mun-lang/mun | /crates/mun_runtime_capi/src/test_util.rs | UTF-8 | 2,769 | 2.546875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use mun_compiler::{Config, DisplayColor, Driver, PathOrInline, RelativePathBuf};
use std::{ffi::CString, io::stderr, path::Path, ptr};
use crate::runtime::{mun_runtime_create, mun_runtime_destroy, Runtime, RuntimeOptions};
/// Combines a compiler and runtime in one. Use of the TestDriver allows for quick testing of M... | true |
73fb4f4544d61fc6e019bcdef337742cb4688447 | Rust | sammhicks/tabletop-interactive-map-creator | /src/grid.rs | UTF-8 | 2,942 | 3.359375 | 3 | [
"MIT"
] | permissive | #![allow(dead_code)]
use std::fmt::Debug;
use crate::list::List;
#[derive(Clone)]
pub struct Grid<T> {
rows: usize,
cols: usize,
cells: List<List<T>>,
}
impl<T> Grid<T> {
pub fn new() -> Self {
Self::default()
}
pub fn rows(&self) -> usize {
self.rows
}
pub fn cols(... | true |
1c624ecfc8537929a507d853c22d513c95b96898 | Rust | mukundbhudia/rs-pos | /src/main.rs | UTF-8 | 5,954 | 3.3125 | 3 | [] | no_license | use std::collections::HashMap;
fn main() {
println!("Hello, world!");
}
#[allow(dead_code)]
fn checkout(items: Vec<&str>, price_map: HashMap<&str, u16>) -> u16 {
let mut total = 0;
let mut checkout_map: HashMap<&str, u16> = HashMap::new();
let mut offers_map: HashMap<&str, u16> = HashMap::new();
... | true |
7f39137ff086897653bc146bb17c517e934ad085 | Rust | srhickma/padd | /src/core/spec/region.rs | UTF-8 | 4,095 | 3.3125 | 3 | [
"Apache-2.0"
] | permissive | use {
core::{
parse::Tree,
spec::{self, lang::SpecSymbol},
},
std::{collections::HashSet, error, fmt},
};
#[derive(PartialEq, Eq, Hash, Clone, Debug)]
pub enum RegionType {
Injectable,
Ignorable,
Alphabet,
CDFA,
Grammar,
}
lazy_static! {
/// The list of required reg... | true |
499d38f1b119471093ba8c793545528c120221bc | Rust | archer884/ccp | /src/error.rs | UTF-8 | 586 | 3.015625 | 3 | [] | no_license | use std::{fmt::Display, io};
#[derive(Debug)]
pub enum Error {
Data,
Io(io::Error),
Threading,
}
impl Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Error::Data => f.write_str("copying multiple files to one path; probable data ... | true |
7b725e150eb3544e6deb8504d1d5c3b9f05ba9cf | Rust | 0xack13/oran | /src/value/var_type.rs | UTF-8 | 240 | 2.546875 | 3 | [
"MIT"
] | permissive | #[derive(PartialEq, Eq, Debug, Clone, Copy)]
pub enum VarType {
Constant,
VariableFirstAssigned,
VariableReAssigned
}
#[derive(PartialEq, Eq, Debug, Clone, Copy, Hash)]
pub enum FunctionOrValueType {
Value,
Function,
}
| true |
015bf38fc7b8d9fbac686c15423d2f5740d5c127 | Rust | VladimirMarkelov/rterm | /examples/hello.rs | UTF-8 | 533 | 2.765625 | 3 | [
"MIT"
] | permissive | extern crate rterm;
fn main() {
let mut cb = rterm::Terminal::new();
cb.clear();
loop {
cb.put_string(5, 3, "Hello, ");
cb.put_string_with_attrs(12, 3, "World!", rterm::COLOR_GREEN, rterm::COLOR_DEFAULT);
cb.flush();
if let Some(ev) = cb.get_event() {
match ev... | true |
78c8ddf7413b7a1f058fe2f09dfb2df22e95945b | Rust | HarryCU/rust-jvmti | /tests/bc/constant.rs | UTF-8 | 2,373 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | extern crate jvmti;
#[cfg(test)]
mod tests {
mod constant_pool {
use jvmti::bytecode::constant::*;
#[test]
fn get_idx_should_consider_long_entries() {
let cp_empty = ConstantPool::from_vec(vec![]);
assert_eq!(0, cp_empty.len());
// Inputs starting wit... | true |
540027714fdbafaeb8b2b7c8b3a3ba9fd006d382 | Rust | Takasakiii/KurosawaDia | /src/database/models/guild.rs | UTF-8 | 674 | 3.1875 | 3 | [
"MIT"
] | permissive | #[derive(Debug)]
pub struct DbGuild {
pub discord_id: u64,
pub name: String,
pub prefix: String,
pub guild_type: u32,
}
pub enum DbGuildType {
Normal = 0,
Loli = 1,
Owner = 2,
}
impl From<u32> for DbGuildType {
fn from(el: u32) -> Self {
match el {
... | true |
c49a9adf892d28625cfaa4ad9194472bcb933ad2 | Rust | benma/bitbox02-firmware | /src/rust/bitbox02-rust/src/util.rs | UTF-8 | 4,169 | 3.234375 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2019 Shift Cryptosecurity AG
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ... | true |
d8472dc2a9f8799cea9920ddd6c6f9e455faad0a | Rust | qubitrenegade/habitat-1 | /components/sup/src/manager/action.rs | UTF-8 | 2,775 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | //! Defines types for sending information about "actions" from one
//! part of the Supervisor to another.
use super::service::ServiceSpec;
#[cfg(unix)]
use habitat_core::os::process::ShutdownSignal;
use habitat_core::os::process::ShutdownTimeout;
use std::sync::mpsc;
/// Defines the parameters by which a service proc... | true |
c02ebe2cbdb7c7a3508760aa5b33898810b48e90 | Rust | tapirbug/litter | /src/transform.rs | UTF-8 | 505 | 2.921875 | 3 | [
"MIT"
] | permissive | use aitios_geom::Vector3;
use aitios_scene::Entity;
use std::rc::Rc;
pub fn translate(entity: &mut Entity, offset: Vector3<f32>) {
// Clone mesh, if shared with other entities, otherwise edit in place.
offset_position_vector(&mut Rc::make_mut(&mut entity.mesh).positions, offset);
}
fn offset_position_vector(p... | true |
5a76043df5e4c7e7e5aab66ee55cf6b9abdc715a | Rust | Vamshi399/Algorithms-2 | /src/sort/quick_sort.rs | UTF-8 | 2,063 | 3.375 | 3 | [
"MIT"
] | permissive | // TODO: implement more variants; add debug output to help explain clearly
use rand::{thread_rng, Rng};
pub fn quick_sort<T: Ord>(v: &mut [T]) {
let mut rng = thread_rng();
_quick_sort(v, &mut rng);
}
fn _quick_sort<T: Ord, R: Rng>(v: &mut [T], rng: &mut R) {
let n = v.len();
if n <= 1 {
retu... | true |
622f96d43e58c74d1823fbe8161533987db709f5 | Rust | imhof/matsano-crypto | /set1/challenge2/src/main.rs | UTF-8 | 560 | 2.578125 | 3 | [
"Unlicense"
] | permissive |
extern crate codec;
extern crate challenge2;
#[cfg(not(test))]
fn main() {
let test = codec::from_hex("AABB99");
println!("Hello, world! {}", test);
}
#[test]
fn matsano_test() {
use challenge2::fixed_xor;
let input1 = codec::from_hex("1c0111001f010100061a024b53535009181c").ok().unwrap();
let input2 = codec::... | true |
f6c81ba8c7d70b15bb03dcf32f4dab5b93fcd5c7 | Rust | prownsix/portal | /src/registry/state/http.rs | UTF-8 | 473 | 2.640625 | 3 | [
"MIT"
] | permissive | use super::Global;
use rocket::State;
use std::sync::Arc;
use std::sync::Mutex;
pub fn serve(global: Arc<Mutex<Global>>) {
rocket::ignite()
.manage(global)
.mount("/", routes![query])
.launch();
}
#[get("/<id>")]
fn query(id: String, global: State<Arc<Mutex<Global>>>) -> &'static str {
... | true |
1b7fec6f291ece62704585bc21e70feaf1b9fabe | Rust | nervosnetwork/ckb | /network/src/peer_store/ban_list.rs | UTF-8 | 2,467 | 2.875 | 3 | [
"MIT"
] | permissive | //! Ban list
use crate::peer_store::types::{ip_to_network, BannedAddr};
use crate::peer_store::Multiaddr;
use ckb_systemtime::unix_time_as_millis;
use ipnetwork::IpNetwork;
use p2p::utils::multiaddr_to_socketaddr;
use std::collections::HashMap;
use std::net::IpAddr;
pub(crate) const CLEAR_INTERVAL_COUNTER: usize = 102... | true |
912c602508a4f01a1d630353a9c4853ebba9ce85 | Rust | alessioalex/rustbook | /src/10.1_generics_2.rs | UTF-8 | 331 | 3.953125 | 4 | [] | no_license | struct Point<T, U> {
x: T,
y: U,
}
impl<T, U> Point<T, U> {
fn x(&self) -> &T {
&self.x
}
}
fn main() {
let both_integer = Point { x: 5, y: 10 };
let both_float = Point { x: 1.0, y: 4.0 };
let integer_and_float = Point { x: 5, y: 4.0 };
println!("point.x = {}", integer_and_flo... | true |
3e2d87e74b14deffd522ca33af2b5d5c7a851d4c | Rust | wycharry/tfs | /atomic-hashmap/src/lib.rs | UTF-8 | 2,223 | 3.15625 | 3 | [
"MIT"
] | permissive | //! Implementation of a lock-free, atomic hash table.
//!
//! This crate provides a high-performance implementation of a completely
//! lock-free (no mutexes, no spin-locks, or the alike) hash table.
//!
//! The only instruction we use is CAS, which allows us to atomically update
//! the table.
//!
//! # Design
//!
//!... | true |
ed759bd2a523b7bdc02b25cc2eee3112c0cda081 | Rust | jean553/treasure-island-server | /treasure-island-server/src/tiles.rs | UTF-8 | 2,837 | 3.1875 | 3 | [] | no_license | //! Contains the tiles routines.
use crate::sprites::get_sprite_index_from_tile_value;
use rand::thread_rng;
use rand::Rng;
use std::collections::VecDeque;
/// Refactored code that loads all tiles of the map randomly. Only used once but refactored here for readability.
pub fn load_tiles() -> [u8; 400] {
cons... | true |
ac700ba7945e81279b72657d79ecd57eca6a4a08 | Rust | tylerwhall/rust | /src/test/compile-fail/coherence-overlap-all-t-and-tuple.rs | UTF-8 | 779 | 2.578125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-other-permissive",
"MIT",
"Unlicense",
"BSD-3-Clause",
"bzip2-1.0.6",
"NCSA",
"ISC",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause"
] | permissive | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | true |
0b82a9ec98c6fe5d8e538617828fb335185ae642 | Rust | kingeta/triangle_tracing | /src/material.rs | UTF-8 | 1,687 | 3.3125 | 3 | [] | no_license | /* Materials */
#![allow(dead_code, unused_imports)]
use super::vector::*;
//use super::colour::*;
/// Holds the material types I guess; this is
/// perhaps a hack. I'd prefer much more general
/// material types by either storing a function pointer
/// or having materials as traits, but it seems
/// it won't be so.... | true |
6ff78a4094c54ca94669ceb6dcdf343874691d1e | Rust | brother-wolf/aws-services-lib | /src/datapipelines/models/pipeline.rs | UTF-8 | 7,410 | 2.84375 | 3 | [] | no_license | use std::collections::HashMap;
use ::serde_derive::Serialize;
use chrono::{DateTime,Utc,TimeZone};
use crate::datapipelines::models::pipeline_task_status::PipelineTaskStatus;
use crate::datapipelines::models::pipeline_tasks::PipelineTasks;
use crate::utilities::get_or_blank;
#[derive(Serialize, Debug, Clone)]
pub stru... | true |
74c604c40c60cef790b739d1d0201edb8e5b9672 | Rust | andrey-yantsen/plex-api.rs | /crates/plex-api/src/media_container/preferences/mod.rs | UTF-8 | 1,179 | 2.671875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | mod deserializer;
use super::MediaContainer;
use serde::Deserialize;
#[derive(Debug, Deserialize, Clone)]
#[cfg_attr(
all(test, feature = "tests_deny_unknown_fields"),
serde(deny_unknown_fields)
)]
pub struct Preferences {
#[serde(rename = "Setting", default)]
pub settings: Vec<Setting>,
#[serde(f... | true |
dee1faf8ad42a3d166a43436a649ccef88bbfea8 | Rust | lukasl93/msp430fr59941 | /src/ramctl.rs | UTF-8 | 942 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | #[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - RAM Controller Control 0"]
pub rcctl0: RCCTL0,
}
#[doc = "RAM Controller Control 0\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`... | true |
6a1f959d3faa87324026a5c834a70c4e3e2acd03 | Rust | kvark/naga | /src/back/hlsl/storage.rs | UTF-8 | 16,053 | 2.796875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Logic related to `ByteAddressBuffer` operations.
//!
//! HLSL backend uses byte address buffers for all storage buffers in IR.
use super::{super::FunctionCtx, BackendResult, Error};
use crate::{
proc::{NameKey, TypeResolution},
Handle,
};
use std::{fmt, mem};
const STORE_TEMP_NAME: &str = "_value";
#[de... | true |
865635d5c46d8a37e46758fa9275d805addf44ae | Rust | gereeter/btree-rewrite | /tests/test.rs | UTF-8 | 8,912 | 2.953125 | 3 | [] | no_license | #![feature(collections, collections_bound, range_inclusive)]
extern crate btree_rewrite;
extern crate collections;
extern crate rand;
use collections::Bound::{self, Included, Excluded, Unbounded};
use btree_rewrite::map::*;
use btree_rewrite::map::Entry::*;
use std::iter::range_inclusive;
use std::rc::Rc;
#[test]
fn... | true |
70f608341549968c71eb290fad8b2a9c2a2b29a7 | Rust | rozaliev/rustler | /src/future/future.rs | UTF-8 | 4,166 | 3.09375 | 3 | [] | no_license | use super::core::{Core, State};
use super::promise::Promise;
pub struct Future<T: Send + 'static, E: Send + 'static> {
core: Core<T, E>,
}
impl<T: Send+'static, E: Send+'static> Future<T,E> {
pub fn from_core(core: Core<T, E>) -> Future<T, E> {
Future { core: core }
}
pub fn value(v: T) -> Fu... | true |
56c420bdbf1c43fd3f64e43eff2f6da484504de3 | Rust | cwfietz/Rust.StarterProject | /src/lib.rs | UTF-8 | 232 | 2.890625 | 3 | [] | no_license | pub enum Health {
Alive,
Dead
}
pub fn is_alive_next_round(live_neighbors : i32, is_alive: Health) -> Health {
match live_neighbors {
3 => Health::Alive,
2 => is_alive,
_ => Health::Dead
}
}
| true |
d406d00e5b43ffaa19a49c12ed287c1bb53e5a3f | Rust | Computer-Sciences/rust-workshop | /compute_average/src/main.rs | UTF-8 | 223 | 3.15625 | 3 | [
"Unlicense"
] | permissive | fn main() {
let a = 33;
let b = 4.9;
let c: f32 = 123.5;
let average = (a as f32 + b as f32 + c) / 3.0;
println!("average is {}", average);
assert_eq!(average, 53.8);
println!("test passed.");
}
| true |
76a4c72d2598c661611b660a4797ccb9e50ca73d | Rust | BookOwl/trusty | /src/frontend.rs | UTF-8 | 6,896 | 3.390625 | 3 | [
"MIT"
] | permissive | use std::io::{Read, Write, Stdin, stdin, Stdout, stdout};
use std::ops::Drop;
use termion;
use termion::{clear, color};
use termion::raw::IntoRawMode;
use left_pad::leftpad;
use cursor::Cursor;
// The Frontend is responsible for rendering the state of the editor
// to the screen and interacting with the user.
pub stru... | true |
073ee2088024a09755fc9fa65c516994c5efb16b | Rust | richardanaya/posterity_ukiyoe | /ukiyoe/src/visualroot.rs | UTF-8 | 1,808 | 2.953125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::*;
use shoji::*;
use std::rc::Rc;
use std::cell::RefCell;
// TODO Why isn't Visual Root implementing CanDoLayoutStuff?
pub struct VisualRoot {
element_tree: Option<Box<dyn Element>>,
layout_tree:Rc<RefCell<shoji::Shoji>>,
root_layout_node:shoji::NodeIndex,
}
impl VisualRoot {
pub fn new() -> Self {
... | true |
998f40cda55bd9791c13317e0db6ae64a02899ad | Rust | ramshaanadeem/rust_workspace | /gcd/src/main.rs | UTF-8 | 834 | 3.640625 | 4 | [] | no_license | use std::io;
fn main() {
let mut first_number = String::new();
let mut second_number = String::new();
println!("Enter two numbers: ");
io::stdin()
.read_line(&mut first_number)
.expect("Failed to read number");
let mut first_number: u32 = match first_number.trim().parse() {
Ok(first_number) => first_numb... | true |
d26b74151ba247dae81cb99879845bda233feaf9 | Rust | chops76/AoC2018 | /src/day12.rs | UTF-8 | 2,549 | 3.34375 | 3 | [] | no_license | use std::fs::File;
use std::io::{BufRead, BufReader};
use std::time::Instant;
use std::collections::HashMap;
use std::cmp;
type Input = (String, HashMap<String, u8>);
fn parse_input(path: &str) -> Input {
let mut subs = HashMap::new();
let f = File::open(path).unwrap();
let mut lines = BufReader::new(f).lines().f... | true |
a63f0ffefabd8ed6e322c8ccdd266c9d268f4d3d | Rust | NickDriscoll/galaxy_monkey | /src/main.rs | UTF-8 | 12,510 | 2.671875 | 3 | [] | no_license | extern crate sdl2;
use sdl2::pixels::Color;
use sdl2::event::Event;
use sdl2::GameControllerSubsystem;
use sdl2::controller::GameController;
use sdl2::controller::Button;
use sdl2::render::Canvas;
use sdl2::render::Texture;
use sdl2::render::TextureCreator;
use sdl2::rect::Point;
use sdl2::rect::Rect;
use sdl2::control... | true |
facca342544abe49f2050d8782202763803214ac | Rust | hstarorg/learning-rust | /rust-study-base/src/bin/91.rs | UTF-8 | 755 | 3.53125 | 4 | [
"MIT"
] | permissive | // 错误&异常
use std::fs::File;
use std::io::ErrorKind;
fn main() {
// 不可恢复的错误,panic
let arr = vec![1, 2, 3];
// 会直接 panic
// println!("arr[10]={}", arr[10]);
// 也可以直接触发 panic
// panic!("Error");
// 可恢复的错误,Result 类型来处理
let f = File::open("non_file.txt");
let f2 = match f {
O... | true |
f719b735cc80bcac98a297d50e4ce47fc2f001f6 | Rust | troyunverdruss/advent-of-code-2020 | /src/day03.rs | UTF-8 | 1,483 | 3.140625 | 3 | [] | no_license | use crate::util::{GridData, inputs, Point};
pub fn run() {
let lines = inputs::day_input(3);
let input = GridData::parse_input(lines);
let trees = run_through_trees(&input, &Slope { dx: 3, dy: 1 });
println!("Part 1, tree collisions count: {}", trees);
let slopes = vec![
Slope { dx: 1, dy... | true |
5a923fc0fbee38e1e1ef7171bb8996835e606554 | Rust | s1ck/assert-graph-iso | /src/graph.rs | UTF-8 | 1,306 | 2.84375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::{
fmt::{Debug, Display},
hash::Hash,
};
pub type NodesIterator<'a, T> = Box<dyn Iterator<Item = T> + 'a>;
pub type LabelIterator<'a, T> = Box<dyn Iterator<Item = T> + 'a>;
pub type PropertyIterator<'a, K, V> = Box<dyn Iterator<Item = (K, V)> + 'a>;
pub trait Graph {
type NodeId: Debug + Hash + Eq... | true |
dea5893dfb40aa76fe05139b001f17d1f70f2c41 | Rust | nfschmidt/cryt | /cryt/src/criteria.rs | UTF-8 | 2,114 | 3.484375 | 3 | [
"MIT"
] | permissive | use std::collections::HashSet;
use std::iter::FromIterator;
pub type BytesCriterion = Fn(&[u8]) -> f32;
const TEXT_BYTES: [u8; 59] = ['a' as u8, 'b' as u8, 'c' as u8, 'd' as u8, 'e' as u8, 'f' as u8, 'g' as u8, 'h' as u8, 'i' as u8, 'j' as u8, 'k' as u8, 'l' as u8, 'm' as u8, 'n' as u8, 'o' as u8, 'p' as u8, 'q' as u... | true |
fbd3f76dcd7b64ed930fc2ef0a37ba274cf2e3b2 | Rust | macote/hshchk | /src/tty/windows.rs | UTF-8 | 1,260 | 2.53125 | 3 | [
"MIT"
] | permissive | use super::{Height, Width};
/// Returns the size of the terminal, if available.
///
/// Note that this returns the size of the actual command window, and
/// not the overall size of the command window buffer
pub fn terminal_size() -> Option<(Width, Height)> {
use winapi::um::handleapi::INVALID_HANDLE_VALUE;
us... | true |
45dad3216a7cc27eba26dddfc140ec866d0df0fc | Rust | nzsc-org/nzsc_core | /src/characters.rs | UTF-8 | 2,418 | 3.171875 | 3 | [
"MIT"
] | permissive | use std::str::FromStr;
use std::fmt;
use super::helpers;
use super::moves::Move;
use super::boosters::Booster;
#[derive(Clone, Copy, PartialEq)]
pub enum Character {
Ninja = 0,
Zombie = 1,
Samurai = 2,
Clown = 3
}
impl Character {
pub fn to_u8(self) -> u8 {
self as u8
}
pub fn get... | true |
0a2f44bb8b5350089689b5b0746590d80e594b53 | Rust | jli/rustlearn | /src/bin/strs.rs | UTF-8 | 1,327 | 3.796875 | 4 | [] | no_license | // The str type, also called a 'string slice', is the most primitive string
// type. It is usually seen in its borrowed form, &str. It is also the type of
// string literals, &'static str.
const GLOB_STR: &str = "global str";
fn strs() {
// uh, how does && work, and how come they all print? maybe just println.
... | true |
9af1fc33cb8567e6c116bb934c394addd4fdd592 | Rust | shaneutt/krustlet | /crates/kubelet/src/grpc_sock/client.rs | UTF-8 | 1,865 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | // This is heavily adapted from https://github.com/hyperium/tonic/blob/f1275b611e38ec5fe992b2f10552bf95e8448b17/examples/src/uds/client.rs
#[cfg_attr(target_family = "windows", path = "windows/mod.rs")]
#[cfg(target_family = "windows")]
pub mod windows;
use std::path::Path;
#[cfg(target_family = "windows")]
use crat... | true |
9787fc4ea64b1a4a451a341bcf49a5dc9323acb6 | Rust | rust9x/rust | /src/test/ui/error-codes/E0107.rs | UTF-8 | 611 | 3.234375 | 3 | [
"MIT",
"BSD-3-Clause",
"Apache-2.0",
"BSD-2-Clause",
"LicenseRef-scancode-other-permissive",
"NCSA"
] | permissive | struct Foo<'a>(&'a str);
struct Buzz<'a, 'b>(&'a str, &'b str);
enum Bar {
A,
B,
C,
}
struct Baz<'a, 'b, 'c> {
buzz: Buzz<'a>,
//~^ ERROR this struct takes 2 lifetime arguments but only 1 lifetime argument was supplied
//~| HELP add missing lifetime argument
bar: Bar<'a>,
//~^ ERROR t... | true |
bd4619961468152ddb261841fb4c510bf4b6b5d0 | Rust | GuillemCastro/v-man | /src/main.rs | UTF-8 | 2,084 | 2.59375 | 3 | [
"MIT"
] | permissive | include!(concat!(env!("OUT_DIR"), "/templates.rs"));
use config::ConfigFile;
use structopt::StructOpt;
use color_eyre::eyre::{Result};
use crate::vm::{VirtualMachine, create_disk, open_viewer};
use virt::connect::Connect;
use std::fs;
mod vm;
mod config;
#[derive(Debug, StructOpt)]
#[structopt(name = "vman", about ... | true |
483c7e731296b4262ac73f46db645081093e4e53 | Rust | niilz/Automate-the-Boring-Stuff-with-Rust | /ch_05/ex04_get/src/main.rs | UTF-8 | 1,480 | 3.890625 | 4 | [] | no_license | use std::collections::HashMap;
fn main() {
// RETRIEVE values with get()
let mut picnicItems = HashMap::new();
picnicItems.insert("apples", 5);
picnicItems.insert("cups", 2);
println!("I am bringing {:?} cups", picnicItems.get("cups"));
// get in RUST returns a Result type (Some(val) or None)
... | true |
4853916e4e33faa1266de034cb91e91bc620ba14 | Rust | emotechlab/emo-audio | /src/stft.rs | UTF-8 | 16,070 | 2.953125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use ndarray::{prelude::*, s};
use num_traits::{Bounded, Num, NumCast};
use rustfft::{num_complex::Complex, FftPlanner};
use std::f32::consts::PI;
/// Padding mode for the audio signal
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub enum PadMode {
/// Don't apply any padding
NoPad,
/// Reflect the si... | true |
c3a4277380aa665b736473f643c7a27ebbac676c | Rust | jfrikker/db-migrate | /src/sync/mod.rs | UTF-8 | 4,906 | 2.65625 | 3 | [] | no_license | pub mod sqlite;
use std::collections::HashMap;
use std::hash::Hash;
use super::{ExecutedMigrationInfo, MigrationInfo};
use super::types::compare_versions;
pub trait Connection {
type Err;
type Trans: Transaction<Err = Self::Err>;
fn ensure_migration_table(&self) -> Result<(), Self::Err>;
fn load_exis... | true |
ffed3d48e2ffc0d294bc989baee77e9145f3b9bb | Rust | JarnaChao09/Innovation_PL_Rust | /src/language/token.rs | UTF-8 | 2,649 | 3.546875 | 4 | [
"MIT"
] | permissive | #[derive(Debug)]
pub struct Token {
pub token_type: TokenType,
pub lexme: String,
pub line: i32
}
#[derive(Debug, Eq, PartialEq)]
pub enum TokenType {
LeftParen, RightParen,
LeftBrace, RightBrace,
LeftBracket, RightBracket,
Comma,
Dot,
Plus,
Minus,
Star,
Slash,
Sem... | true |
521a5d4a2b072d5498ca349ce19d9978937d2fb5 | Rust | prisma/prisma-engines | /prisma-fmt/src/native.rs | UTF-8 | 1,586 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | use psl::datamodel_connector::NativeTypeConstructor;
pub(crate) fn run(schema: &str) -> String {
let validated_configuration = match psl::parse_configuration(schema) {
Ok(validated_configuration) => validated_configuration,
Err(_) => return "[]".to_owned(),
};
if validated_configuration.da... | true |
a52ef1c662fb761f041e5cbeed91eaee11dbe85a | Rust | dora-gt/tower-web | /src/service/new_service.rs | UTF-8 | 1,980 | 2.71875 | 3 | [
"MIT"
] | permissive | use crate::error::Catch;
use crate::routing::{Resource, RoutedService};
use crate::service::WebService;
use crate::util::Never;
use crate::util::http::{HttpMiddleware};
use futures::future::{self, FutureResult};
use http;
use tower_service::NewService;
use std::fmt;
/// Creates new `WebService` values.
///
/// Insta... | true |
b2ab8652592d4ffae6258f795920786bd25d1c9e | Rust | virtuehive/rusty-loader | /src/macros.rs | UTF-8 | 1,315 | 2.734375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright (c) 2017 Stefan Lankes, RWTH Aachen University
// Colin Finck, RWTH Aachen University
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your opt... | true |
cdf9ba5952c0e8321a4e4837bf2be3d239003b87 | Rust | reesmanp/evil_penguin | /src/components/entities/coin.component.rs | UTF-8 | 548 | 2.6875 | 3 | [] | no_license | use amethyst::{
ecs::{
Component,
VecStorage
}
};
#[derive(Component, Default)]
#[storage(VecStorage)]
pub struct CoinComponent {
pub id: usize,
pub total_amount: usize,
pub frame: usize,
pub frames: usize,
pub time_per_frame: f32,
pub time_elapsed: f32
}
impl CoinCompo... | true |
f78d4f9a99a45a3ce69d95a045511af00b422334 | Rust | StephenWassell/exercism | /rust/pascals-triangle/src/lib.rs | UTF-8 | 348 | 3.171875 | 3 | [] | no_license | pub struct PascalsTriangle {
count: u32,
}
impl PascalsTriangle {
pub fn new(row_count: u32) -> Self {
Self { count: row_count }
}
pub fn rows(&self) -> Vec<Vec<u32>> {
let mut rows = Vec::<Vec<u32>>::new();
for i in 0..self.count {
rows.push(Vec::<u32>::new());
... | true |
43529e6ca78087541cccc6077b57177e6cfc97fc | Rust | jedahan/rustboy | /src/memory.rs | UTF-8 | 4,824 | 2.921875 | 3 | [] | no_license | use gameboy;
use cart;
const WRAM_SIZE: usize = 0xDFFF - 0xC000 + 1;
const VRAM_SIZE: usize = 0x9FFF - 0x8000 + 1;
const XRAM_SIZE: usize = 0xBFFF - 0xA000 + 1;
const HRAM_SIZE: usize = 0xFFFE - 0xFF80 + 1;
const IO_SIZE: usize = 0xFF7F - 0xFF01 + 1;
use std::ops::{Index, IndexMut, Range};
pub struct Memory {
cou... | true |
1615f8340b7730a1995a23fbab9cc2a38a39b2a5 | Rust | okdewit/asana-sdk | /src/models.rs | UTF-8 | 2,514 | 3.59375 | 4 | [] | no_license | use serde::{Deserialize};
use serde::de::DeserializeOwned;
/// A macro for generating Asana model structs
///
/// # Examples
///
/// The example below will generate a `User` struct, linked to the `/users` Asana endpoint.
///
/// * It will include & deserialize the `email` & `name` fields as Strings.
/// * The fields `... | true |
46154f4dee85efb8298e3f1a8f932483459e3aab | Rust | davidsetyanugraha/blockchain-supply-chain | /sawtooth-sabre/contracts/sawtooth-pike/addresser/src/lib.rs | UTF-8 | 1,346 | 2.921875 | 3 | [
"Apache-2.0",
"CC-BY-4.0"
] | permissive | // Copyright 2018 Cargill Incorporated
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agre... | true |
29373836759b180aecf586aafccf3f2bbec378a4 | Rust | numerodix/rust-book-examples | /trait-objects/src/main.rs | UTF-8 | 618 | 2.90625 | 3 | [] | no_license | pub trait Draw {
fn draw(&self);
}
pub struct Button {
}
impl Draw for Button {
fn draw(&self) {
println!("drawing button")
}
}
pub struct TextField {
}
impl Draw for TextField {
fn draw(&self) {
println!("drawing textfield")
}
}
pub struct Screen {
pub components: Vec<Bo... | true |
713a32d3cba5d4e8a90e1dddcd514129cd37467c | Rust | lilith645/DelinquentFood | /src/modules/food/pineapple.rs | UTF-8 | 2,011 | 2.90625 | 3 | [] | no_license | use crate::modules::food::{Food, FoodData};
use crate::modules::map::Map;
use cgmath::{Vector2, Vector3};
const MAX_HEALTH: i32 = 60;
#[derive(Clone)]
pub struct Pineapple {
data: FoodData,
is_inner: bool,
}
impl Pineapple {
pub fn new(id: i32, position: Vector2<f32>, path: Vec<u32>, location: Vector2<i32>) -... | true |
f498bf1cdc45ef8662fea3e81cca058bafaaa0f9 | Rust | SSebo/log4rs | /src/append/rolling_file/policy/compound/roll/mod.rs | UTF-8 | 2,771 | 2.984375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | //! Rollers
use std::{error::Error, fmt, fs, io, path::Path};
#[cfg(feature = "background_rotation")]
use std::path::PathBuf;
#[cfg(feature = "file")]
use crate::file::Deserializable;
#[cfg(feature = "delete_roller")]
pub mod delete;
#[cfg(feature = "fixed_window_roller")]
pub mod fixed_window;
#[cfg(feature = "tim... | true |
bfe9f31243dfde8b1965d0a930b215ee98e3ab2f | Rust | suxiaoshao/compiler-lab | /src/parser/goto.rs | UTF-8 | 1,045 | 2.796875 | 3 | [] | no_license | use std::collections::HashMap;
use super::{
canonical_collection::CanonicalCollection, non_terminator::NonTerminator,
production::ProductionRight,
};
/// action表
/// 行是项目集序号
/// 列是非终结符
#[derive(Debug)]
pub(in crate::parser) struct Goto(pub(crate) Vec<HashMap<NonTerminator, Option<usize>>>);
impl Goto {
//... | true |
12426a0d07c243243a918f8800b8cb13aeb24bfd | Rust | deathlyfrantic/project-euler | /5.rs | UTF-8 | 579 | 3.4375 | 3 | [
"BSD-2-Clause"
] | permissive | /* 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
* What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
*/
fn main() {
let mut smallest: i32 = 1;
while !divisible(smallest) {
smallest += 1;
... | true |
fab52133eb33d015d58e9f77f39df44fb6406662 | Rust | davidkern/mju-bits | /src/bitfield.rs | UTF-8 | 3,391 | 3.078125 | 3 | [
"Apache-2.0"
] | permissive | /*
bitfield.rs - Type defining a range of bits for an owning type
Copyright 2019-2020 David Kern <david@mju.io>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/L... | true |
e74be5dcb77f0d2398a52c84f38be7f9aaffefec | Rust | dimastark/advent-of-code | /year2020/src/task4.rs | UTF-8 | 2,379 | 3.171875 | 3 | [] | no_license | use regex::Regex;
use std::collections::HashMap;
fn rng_validator(from: i32, to: i32) -> impl Fn(&str) -> bool {
move |s| rng_validate(from, to, s)
}
fn reg_validator(pattern: &str) -> impl Fn(&str) -> bool {
let reg = Regex::new(pattern).unwrap();
move |s| reg.is_match(s)
}
fn rng_validate(from: i32, to... | true |
4dbbfee51a879236e432ab82a5b73926080da155 | Rust | garkimasera/tenuki-ui | /src/widgets/frame.rs | UTF-8 | 2,353 | 2.96875 | 3 | [
"MIT"
] | permissive |
use std::cell::{RefCell, Ref};
use std::rc::Rc;
use prelude::*;
use uicontext;
use ::sdl2::video::WindowRef;
//use ::sdl2::video::WindowBuilder;
/// Top level widget
pub struct Frame {
renderer: RefCell<Renderer<'static>>,
child: RefCell<Option<AnyWidget>>,
}
impl Frame {
pub fn new(title: &str, width: ... | true |
91f1e2cfc18baea1817b7b719d1168cc758dea73 | Rust | blakehawkins/rightscrapex | /src/main.rs | UTF-8 | 4,654 | 2.640625 | 3 | [] | no_license | use std::fs::File;
use std::io::{Result, Write};
use oops::Oops;
use select::document::Document;
use select::predicate::{Attr, Name};
use serde::Serialize;
use stdinix::stdinix;
use clap::{ArgGroup, Parser};
use ureq;
/// A rightmove property page scraper.
#[derive(Parser, Debug)]
#[command(name = "rightscrapex", gro... | true |
d155813a9af5398832420a845e7a3e96984df335 | Rust | rust-cli/man | /src/mod.rs | UTF-8 | 7,994 | 3.390625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | mod author;
mod custom;
mod environment;
mod flag;
mod option;
use self::author::Author;
use self::custom::Para;
use self::environment::Env;
use self::flag::Flag;
use self::option::Opt;
use roff::{bold, italic, list, Roff, Troffable};
use std::convert::AsRef;
/// Man page struct.
#[derive(Debug, Clone)]
pub struct Ma... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.