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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
b29cb7527d4083d5bc7a0cc218da83180c572d15 | Rust | katopz/solana-feed-rs | /crates/webapp/src/app.rs | UTF-8 | 3,869 | 2.703125 | 3 | [] | no_license | use log::info;
use message_feed_data::*;
use solana_bindgen::{Connection, PublicKey};
use solana_sdk::account::Account;
use solana_sdk::pubkey::Pubkey;
use std::str::FromStr;
use std::time::Duration;
use wasm_bindgen::prelude::*;
use yew::html;
use yew::prelude::*;
use yew::services::{Task, TimeoutService};
pub struct... | true |
672476975dbe5d19099ef50088f0ed363c1668ce | Rust | dylanmckay/javabc | /src/raw/constant.rs | UTF-8 | 4,739 | 2.828125 | 3 | [
"MIT"
] | permissive | use {Error, ErrorKind};
use raw;
use std::io::prelude::*;
use byteorder::{BigEndian, ReadBytesExt};
pub const TAG_UTF8: u8 = 1;
pub const TAG_INTEGER: u8 = 3;
pub const TAG_FLOAT: u8 = 4;
pub const TAG_LONG: u8 = 5;
pub const TAG_DOUBLE: u8 = 6;
pub const TAG_CLASS: u8 = 7;
pub const TAG_STRING: u8 = 8;
pub const TA... | true |
2b26b2365fb8b5e541be26c2b057c632563692a6 | Rust | DigitalShooting/DSC-Rust | /src/discipline/discipline.rs | UTF-8 | 1,497 | 2.828125 | 3 | [] | no_license | use std::collections::HashMap;
use super::interface::Interface;
use super::target::Target;
use super::part::DisciplinePart;
use super::time::Time;
use super::error::Error as DisciplineError;
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Discipline {
pub id: String,
pub title: String,
pub in... | true |
1811de05ab665d4197b93e3f21d4afb33c8423e4 | Rust | olson-sean-k/fool | /src/zip.rs | UTF-8 | 714 | 2.734375 | 3 | [
"MIT"
] | permissive | #![cfg(feature = "zip")]
use itertools::izip;
pub trait Zip {
type Output;
fn zip(self) -> Self::Output;
}
macro_rules! impl_zip {
() => (
impl_zip!(items => (A, B));
impl_zip!(items => (A, B, C));
impl_zip!(items => (A, B, C, D));
impl_zip!(items => (A, B, C, D, E));
... | true |
f8f495d1dd03887fdeb04b1ad5d473549565a38a | Rust | fits/try_samples | /rust/sync/mutex_sample.rs | UTF-8 | 3,252 | 3.390625 | 3 | [] | no_license |
use std::thread;
use std::sync::{Arc, Mutex, RwLock};
struct Data(i32);
fn no_lock() {
let mut hs = Vec::new();
let ds = Arc::new(Vec::new());
for i in 0..100 {
let mut ds = ds.clone();
hs.push(
thread::spawn(move || {
//ds.push(Data(i)) // compile error: can... | true |
2f0fbdb6be3e6c20b77d3878c90a408cb4aa913f | Rust | therealprof/mkw41z | /src/i2c0/s2/mod.rs | UTF-8 | 9,820 | 2.984375 | 3 | [
"BSD-3-Clause",
"0BSD"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u8,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u8,
}
impl super::S2 {
#[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 |
fbd66287734b31961034ea584cea861013242595 | Rust | IThawk/rust-project | /rust-master/src/test/ui/rfcs/rfc-2005-default-binding-mode/constref.rs | UTF-8 | 942 | 2.9375 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // run-pass
const CONST_REF: &[u8; 3] = b"foo";
trait Foo {
const CONST_REF_DEFAULT: &'static [u8; 3] = b"bar";
const CONST_REF: &'static [u8; 3];
}
impl Foo for i32 {
const CONST_REF: &'static [u8; 3] = b"jjj";
}
impl Foo for i64 {
const CONST_REF_DEFAULT: &'static [u8; 3] = b"ggg";
const CONST_... | true |
95a5739aa71544317da195076707151ee95dfdcf | Rust | favu100/b2program | /btypes_big_integer/src/main/rust/btypes/src/bboolean.rs | UTF-8 | 1,487 | 3.359375 | 3 | [] | no_license | use std::hash::Hash;
use crate::bobject::BObject;
use std::fmt;
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct BBoolean {
val: bool,
}
impl fmt::Display for BBoolean {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.val)
}
}
... | true |
4d1533e001f4bea727dbca341afa01a555a2b25a | Rust | wujunze/tikv | /src/raftstore/store/fsm/router.rs | UTF-8 | 19,940 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2018 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to i... | true |
56ebea2b07eca829d55bb2e93d43aba65ec3b580 | Rust | woelper/parallel-getter | /examples/example.rs | UTF-8 | 692 | 2.625 | 3 | [
"MIT"
] | permissive | extern crate parallel_getter;
use parallel_getter::ParallelGetter;
use std::fs::File;
fn main() {
let url = "http://apt.pop-os.org/proprietary/pool/bionic/main/\
binary-amd64/a/atom/atom_1.31.1_amd64.deb";
let mut file = File::create("atom_1.31.1_amd64.deb").unwrap();
let result = ParallelGetter::... | true |
1641acdbe009e15506e4c34561c8874e81c7e04a | Rust | rust-lang/rust | /tests/ui/coherence/const-generics-orphan-check-ok.rs | UTF-8 | 956 | 2.984375 | 3 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"BSD-2-Clause",
"LicenseRef-scancode-unicode",
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | // check-pass
// aux-build:trait-with-const-param.rs
extern crate trait_with_const_param;
use trait_with_const_param::*;
// Trivial case, const param after local type.
struct Local1;
impl<const N: usize, T> Trait<N, T> for Local1 {}
// Concrete consts behave the same as foreign types,
// so this also trivially works.... | true |
f08ab52c9e4cfb67ce008e86f7d9d5009d4f4b4c | Rust | dvc94ch/rust-c-wasm-lib | /fib_c/src/lib.rs | UTF-8 | 946 | 3.015625 | 3 | [
"ISC"
] | permissive | use fib::Fib;
use std::ffi::c_void;
#[repr(C)]
pub struct FibHandle(*mut c_void);
#[no_mangle]
pub unsafe extern "C" fn fib_new() -> FibHandle {
FibHandle(Box::into_raw(Box::new(Fib::new())) as *mut _)
}
#[no_mangle]
pub unsafe extern "C" fn fib_next(fib: &FibHandle) -> u64 {
let ptr = fib.0 as *mut Fib;
... | true |
c1ac535b785c9c92adcc0e9c12cf5b25425164cf | Rust | No9/advisory-poc | /locker/src/main.rs | UTF-8 | 369 | 2.96875 | 3 | [
"MIT"
] | permissive | use std::fs::File;
use std::{thread, time};
use advisory_lock::{AdvisoryFileLock, FileLockMode, FileLockError};
fn main() -> Result<(), FileLockError>{
println!("Hello, world!");
let exclusive_file = File::create("/tmp/share/foo.txt").unwrap();
exclusive_file.lock(FileLockMode::Exclusive)?;
thread::sle... | true |
2f8bf10a01b9791134f8eacd79c16ba70fe80dda | Rust | apiraino/poor-postman | /src/app.rs | UTF-8 | 10,568 | 2.71875 | 3 | [
"MIT"
] | permissive | use std::cell::RefCell;
use std::error;
use gio::{self, prelude::*};
use gtk::{self, prelude::*};
use crate::utils::*;
use crate::header_bar::*;
use crate::about_dialog::*;
#[derive(Clone)]
pub struct App {
main_window: gtk::ApplicationWindow,
pub header_bar: HeaderBar,
url_input: gtk::Entry
}
#[derive(... | true |
e2de5a4224c26c7b0f40aefdf93580750430d795 | Rust | Elinvynia/bot | /src/data/db.rs | UTF-8 | 2,202 | 3.203125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::prelude::*;
use std::convert::TryFrom;
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum LogType {
MessageDeleted = 1 << 1,
MessageEdited = 1 << 2,
UserJoined = 1 << 3,
UserLeft = 1 << 4,
UserBanned = 1 << 5,
ChannelCreated = 1 << 6,
ChannelDeleted = 1 << 7,
CategoryCreated =... | true |
d37afc788ccc0b866bbe1311c7172d496b0c787b | Rust | briarpatch1337/fast-and-feudalist | /src/drawing.rs | UTF-8 | 25,113 | 3.0625 | 3 | [] | no_license |
use render_gl;
use freetype;
pub fn draw_triangle(gl: &gl::Gl, shader_program: &render_gl::Program) {
// Activate this program
shader_program.set_used();
let triangle_width = 1_f32;
let triangle_height = 3_f32.sqrt() / 2_f32;
// Some vertices for our triangle
let vertices: Vec<f32> = vec![
... | true |
06a172256d19a8012eb45127dee2ef16d62739eb | Rust | fengjixuchui/luago-book | /code/rust/ch02/src/main.rs | UTF-8 | 2,861 | 2.859375 | 3 | [
"MIT"
] | permissive | mod binary;
use std::env;
use std::fs::File;
use std::io;
use std::io::prelude::*;
fn main() -> io::Result<()> {
if env::args().count() > 1 {
let filename = env::args().nth(1).unwrap();
let mut file = File::open(filename)?;
let mut data = Vec::new();
file.read_to_end(&mut data)?;
... | true |
1e251694ede81f77735f98973b32578d5e45ecb5 | Rust | mesalock-linux/crates-sgx | /vendor/mio/src/io.rs | UTF-8 | 1,032 | 2.9375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // Re-export the io::Result / Error types for convenience
pub use std::io::{Read, Write, Result, Error, ErrorKind};
// TODO: Delete this
/// A helper trait to provide the map_non_block function on Results.
pub trait MapNonBlock<T> {
/// Maps a `Result<T>` to a `Result<Option<T>>` by converting
/// operation-wo... | true |
3b12accfa6732b3a4590fd85a3666fdc77fbcaf8 | Rust | wg/wasabi | /wasabi/src/mem.rs | UTF-8 | 3,318 | 2.78125 | 3 | [] | no_license | use bytes::{as_i32_le, as_i64_le, i32_as_u8_le, i64_as_u8_le, u32_as_u8_le};
use std::{slice, str};
use wasmtime_runtime::VMMemoryDefinition;
#[derive(Debug)]
pub struct Mem {
pub definition: Option<*mut VMMemoryDefinition>,
}
impl Mem {
pub fn new() -> Self {
Self { definition: None }
}
}
pub tr... | true |
20e9a9027788a7bf112bf7ed98ea44995b88dc66 | Rust | esturcke/cryptopals-rust | /src/challenge10.rs | UTF-8 | 1,583 | 3.40625 | 3 | [] | no_license | use crate::bytes::*;
use crate::crypt::*;
use std::fs;
/// # Implement CBC mode
///
/// [Set 2 / Challenge 10](https://cryptopals.com/sets/2/challenges/10)
///
/// CBC mode is a block cipher mode that allows us to encrypt irregularly-sized messages, despite the fact that a block cipher natively only transforms individ... | true |
bf15281668568dca5f5f8291a6de4d1c6b6b60a7 | Rust | angelodag/szyszka | /src/update_records.rs | UTF-8 | 3,133 | 2.5625 | 3 | [
"MIT"
] | permissive | use crate::file_entry::ResultEntries;
use crate::help_function::{get_list_store_from_tree_view, ColumnsResults};
use crate::rules::Rules;
use glib::Value;
use gtk::prelude::GtkListStoreExtManual;
use gtk::{TreeModelExt, TreeView};
use std::cell::RefCell;
use std::ops::DerefMut;
use std::rc::Rc;
#[allow(dead_code)]
pub... | true |
8d29e938ab03b4659e368ce8c7d376ea99d5544e | Rust | ahabhgk/monkey-rs | /src/evaluator.rs | UTF-8 | 31,437 | 3.40625 | 3 | [
"MIT"
] | permissive | use crate::{
ast::{Expression, HashLiteral, Infix, Prefix, Program, Statement},
environment::Environment,
object::{Builtin, Function, HashObject, Object},
};
use std::{cell::RefCell, collections::HashMap, fmt, rc::Rc};
#[derive(Debug)]
pub struct EvalError {
pub message: String,
}
impl fmt::Display fo... | true |
d282aa3611f140a6af899184f3237d3907915937 | Rust | glademiller/openapiv3 | /src/external_documentation.rs | UTF-8 | 757 | 2.734375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use indexmap::IndexMap;
use serde::{Deserialize, Serialize};
/// Allows referencing an external resource for extended documentation.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
pub struct ExternalDocumentation {
/// A short description of the target documentation.
/// CommonMark syntax ... | true |
b5e31141d0c1dc11d4c764fe70e86cdd216bfc3d | Rust | dignifiedquire/forest | /node/db/src/errors.rs | UTF-8 | 841 | 2.5625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2020 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT
use encoding::error::Error as CborError;
use std::fmt;
#[derive(Debug, PartialEq)]
pub enum Error {
InvalidBulkLen,
Database(String),
Encoding(String),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<... | true |
a6c4f19c03b601747b36c86c0a72e4eda3110fac | Rust | YuichiroSato/Scratch | /rust/CheatSheets/std_read_lines.rs | UTF-8 | 477 | 3.078125 | 3 | [
"MIT"
] | permissive | use std::io::*;
fn main() {
let mut buf = String::new();
stdin().read_to_string(&mut buf).unwrap();
let mut lines = buf.lines();
let first = lines.next().unwrap().to_string();
let second = lines.next().unwrap().to_string();
let mut splitted = second.split_whitespace();
let second_head = sp... | true |
0fd975dda9739b59ea7862f12bb08e41f9b8ec79 | Rust | rphmeier/Snorkium | /src/ecs/query.rs | UTF-8 | 7,716 | 3.578125 | 4 | [] | no_license | //! Queries and filters.
use std::marker::PhantomData;
use std::sync::RwLock;
use super::*;
use super::set::LockGroup;
/// Filters are used to test properties of entities' data.
///
/// The most common kind of filter is to test whether an entity has a specific
/// component. This is implemented with the `Has` filter... | true |
9de19a2427e4e0ff8a496d9160fd02e81ad3e609 | Rust | timglabisch/rust_cli_php_consumer | /src/main.rs | UTF-8 | 1,340 | 2.75 | 3 | [] | no_license | extern crate scoped_threadpool;
use scoped_threadpool::Pool;
use std::process::{Command, Stdio};
use std::io::{BufWriter, Write};
fn main() {
println!("Hello, world!");
let mut worker = 0;
let mut hashmap = (0..40_000_000).collect::<Vec<i32>>();
let data_chunks = hashmap.chunks_mut(5_000_000);
l... | true |
0addccb24ee39f6b1d6050d465c650d4ef224a7e | Rust | youngqqcn/RustNotes | /rust-by-example/15-作用域规则/17-static.rs | UTF-8 | 1,050 | 3.625 | 4 | [] | no_license |
// Author: yqq
// Date: 2022-11-13 16:33:01
// Description: static
/*
'static 生命周期是可能的生命周期中最长的,它会在整个程序运行的时期中存在。
'static 生命周期也可被强制转换成一个更短的生命周期。有两种方式使变量拥有
'static 生命周期,它们都把数据保存在可执行文件的只读内存区:
- 使用 static 声明来产生常量(constant)。
- 产生一个拥有 &'static str 类型的 string 字面量。
*/
// 'static 生命周期的常量
static NUM: i32 = 18;
// 返回一个指向 `... | true |
024a065fceb33efff6e331aa496857e7dad48895 | Rust | krithin/adventofcode2020 | /day3/src/main.rs | UTF-8 | 930 | 3.296875 | 3 | [] | no_license | use std::{io, io::prelude::*};
fn count_trees(trees: &Vec::<String>, xinc: usize, yinc: usize) -> u64 {
let mut tree_count: u64 = 0;
let width = trees[0].len();
let mut x = 0;
let mut y = 0;
while y < trees.len() {
if trees[y].chars().nth(x).unwrap() == '#' {
tree_count += 1;
... | true |
71abe80529e0ab9688c3d7207f1638e3632ce37e | Rust | tobixdev/i32_bfp | /i32_bfp/src/runtime.rs | UTF-8 | 6,980 | 2.84375 | 3 | [
"Unlicense"
] | permissive | use std::time;
use crate::ast::{Expr};
use crate::compiled_executor::CompiledExecutor;
use crate::interpreted_executor::InterpretedExecutor;
use crate::parser::parse;
use crate::ast;
#[derive(Debug)]
enum ExecutorType {
Compiled,
Interpreted,
}
impl ExecutorType {
fn from(value: &str) -> ExecutorType {
... | true |
0ee5439e9b2f37dcf5431cf13217b518c4553c96 | Rust | Azure/iotedge | /edgelet/edgelet-settings/src/base/module.rs | UTF-8 | 3,412 | 2.8125 | 3 | [
"MIT"
] | permissive | // Copyright (c) Microsoft. All rights reserved.
#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct Settings<ModuleConfig> {
name: String,
r#type: String,
#[serde(default, rename = "imagePullPolicy")]
image_pull_policy: ImagePullPolicy,
config: ModuleConfig,
#[serde(default)]... | true |
850311b8ad7b0bee37dad3b7c1898ed98b7e070f | Rust | vinhnx/vrust | /hello_world/literals_operators.rs | UTF-8 | 536 | 3.765625 | 4 | [] | no_license | fn main() {
println!("1 + 2 = {}", 1u32 + 2);
println!("1 - 2 = {}", 1i32 - 2);
// AND: &&
// OR: &&
// negative: !
// bitwise operations
println!("0011 AND 0101 is {:04b}", 0b0011u32 & 0b0101);
println!("0011 OR 0101 is {:04b}", 0b0011u32 | 0b0101);
println!("0011 XOR 0101 is {:04b}", 0b0011u32 ^ ... | true |
fc7e81dddb4b4e1b898dd4705e932e4a965fa1ad | Rust | Resonious/mkdesktop | /src/main.rs | UTF-8 | 2,270 | 2.75 | 3 | [
"MIT"
] | permissive | #[macro_use]
extern crate clap;
extern crate desktop_lib;
use desktop_lib::{cli, desktop, gui};
fn main() {
let arg_matches: clap::ArgMatches = clap_app!(myapp =>
(name: env!("CARGO_PKG_NAME"))
(version: env!("CARGO_PKG_VERSION"))
(author: "Nigel Baillie <metreckk@gmail.com>")
(a... | true |
c2a20ec0dd0501e947d78215f7997711ad75a9c6 | Rust | belst/Advent-of-Code-2017 | /src/bin/day8.rs | UTF-8 | 2,293 | 3.203125 | 3 | [] | no_license | use std::io::{self, Read};
use std::collections::HashMap;
struct Guard<'a> {
target: &'a str,
ammount: isize,
op: &'a str,
}
impl<'a> Guard<'a> {
fn eval(&self, state: &HashMap<&str, isize>) -> bool {
match self.op {
"<" => state[self.target] < self.ammount,
... | true |
b3e06945a6f7f91fadb34333e4b123bccbd2b4d8 | Rust | naoki-tomita/todo-wasm | /server/src/error.rs | UTF-8 | 1,397 | 2.734375 | 3 | [] | no_license | use crate::drivers::todo_driver::TodoEntity;
use std::sync::RwLockReadGuard;
use std::sync::PoisonError;
use failure::_core::fmt;
use failure::_core::fmt::Display;
use failure::{Context, Fail};
#[derive(Debug)]
pub struct Error {
inner: Context<ErrorKind>,
}
// impl Fail for Error {
// fn name(&self) -> Optio... | true |
7617d5cf6faef03c6f13b02834089343646d8b72 | Rust | RacleRay/Self-build-tools | /AirWarInTerm/src/frame.rs | UTF-8 | 439 | 2.796875 | 3 | [] | no_license | use crate::{NUM_ROWS, NUM_COLS};
pub type Frame = Vec<Vec<&'static str>>;
pub fn new_frame() -> Frame {
let mut rows = Vec::with_capacity(NUM_ROWS);
for _ in 0..NUM_ROWS {
let mut row = Vec::with_capacity(NUM_COLS);
for _ in 0..NUM_COLS {
row.push(" ");
}
rows.push(... | true |
b50ba9d5afab2cf57c19e94a6f7c57642633056c | Rust | ry3s/atcoder | /abc178/e.rs | UTF-8 | 1,626 | 3.296875 | 3 | [] | no_license | use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
#[allow(dead_code)]
struct Scanner<'a> {
cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
fn new(cin: StdinLock<'a>) -> Scanner<'a> {
Scanner { cin: cin }
}
fn read<T: FromStr>(&mut self) -> Option<T> {
let t... | true |
4229b374d92729cb7421c2c3fd3c50e754582c87 | Rust | hannobraun/cargo-task | /src/env_loader.rs | UTF-8 | 8,740 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | use crate::{_cargo_task_util::*, CARGO_TASK_DIR, *};
use std::{
collections::BTreeMap,
ffi::OsStr,
path::{Path, PathBuf},
};
fn set_env<N: AsRef<OsStr>, V: AsRef<OsStr>>(n: N, v: V) {
std::env::set_var(n, v);
}
/// Delete any / all 'CT_' environment variables,
/// in preparation for setting new ones.... | true |
337fa8e0e387222df12ca5e8ac0fabb0f8bf3f3c | Rust | dyoshikawa/sqlx | /sqlx-core/src/mysql/value.rs | UTF-8 | 1,541 | 3.09375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::error::UnexpectedNullError;
use crate::mysql::{MySql, MySqlTypeInfo};
use crate::value::RawValue;
#[derive(Debug, Copy, Clone)]
pub enum MySqlData<'c> {
Binary(&'c [u8]),
Text(&'c [u8]),
}
#[derive(Debug)]
pub struct MySqlValue<'c> {
type_info: Option<MySqlTypeInfo>,
data: Option<MySqlData<... | true |
5488db66827ffff10d14e0022da25c193e6d985e | Rust | hurryabit/homer | /compiler/src/tests/parser/type_.rs | UTF-8 | 5,217 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | use crate::*;
use syntax::Type;
fn parse_output(input: &str) -> Type {
super::parse_output_impl(Type::parse_test, input)
}
fn parse_error(input: &'static str) -> String {
super::parse_error_impl(Type::parse_test, input)
}
#[test]
fn type_var() {
insta::assert_debug_snapshot!(parse_output("A"), @r###"
... | true |
118a76b23fdfe94fd0baef6e7a6b450d65893c2c | Rust | Zeroeh/Clientless | /realmlib/tests/tests.rs | UTF-8 | 496 | 2.671875 | 3 | [
"MIT"
] | permissive | #[cfg(test)]
mod tests {
use realmlib::network;
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
#[test]
fn test_net() {
network::netstat();
}
#[test]
fn test_stat_fn() {
//test stats and make sure our functions on them work as intended
let x = netwo... | true |
147813dd95c6331e7d53ec96eb8d88228d6705ed | Rust | shirshak55/dog | /dns/src/record/cname.rs | UTF-8 | 1,158 | 3.171875 | 3 | [
"MIT"
] | permissive | use crate::strings::ReadLabels;
use crate::wire::*;
/// A **CNAME** _(canonical name)_ record, which aliases one domain to another.
///
/// # References
///
/// - [RFC 1035 §3.3.1](https://tools.ietf.org/html/rfc1035) — Domain Names, Implementation and Specification (November 1987)
#[derive(PartialEq, Debug, Clone)]
... | true |
d510e6c02a231d2bd42c373f2000b7482d9c6b07 | Rust | Niedzwiedzw/minecraftrs | /mc/worldgen/src/feature/tree/mod.rs | UTF-8 | 7,447 | 2.59375 | 3 | [] | no_license | //! Tree-related features for Minecraft, these algorithms might seems a little weird
//! because they are translated from a Java decompilation by MCP. The main goal is to
//! be as accurate as possible.
use mc_core::block::{Block, BlockState, GlobalBlocks};
use mc_core::rand::JavaRandom;
use mc_core::pos::Axis;
use m... | true |
0940a96ad4dc774321f8ccceda69cb76ff962464 | Rust | AlecDivito/rustbitmap | /examples/saving_file.rs | UTF-8 | 380 | 2.90625 | 3 | [
"MIT"
] | permissive | extern crate rustbitmap;
use rustbitmap::BitMap;
fn main() {
let bitmap = BitMap::new(24, 24);
// the bitmap will be saved as a 24 bit image
bitmap.save_as("24_bit_white_square.bmp").unwrap();
// because the image is just a white square, it will be saved as a 1 bit image
bitmap
.simplify... | true |
449a503e02eb292a96b87f3a1012fcb0c7d2fce3 | Rust | BrunoWallner/voxel | /src/controll.rs | UTF-8 | 5,236 | 2.609375 | 3 | [
"MIT"
] | permissive | use bevy::prelude::*;
pub struct Builder {
x: f32,
y: f32,
z: f32,
distance: f32,
}
impl Builder {
pub fn new(x: f32, y: f32, z: f32) -> Self {
Builder {x: x, y: y, z: z, distance: 5.0}
}
pub fn chpos(&mut self, direction: [f32; 3]) {
self.x += direction[0];
self.y ... | true |
86d451d46ca1b47915d6b54237fc750c02bf709e | Rust | SKyletoft/containers | /vector/src/lib.rs | UTF-8 | 13,540 | 3 | 3 | [] | no_license | use std::{
alloc,
alloc::Layout,
fmt,
fmt::Debug,
iter::FromIterator,
mem,
ops::{Index, IndexMut},
ptr,
ptr::NonNull,
};
#[cfg(test)]
pub mod test_box;
#[cfg(test)]
pub mod test_i32;
#[cfg(test)]
pub mod test_zst;
pub mod iterator;
use iterator::{BorrowedVectorIterator, BorrowedVectorIteratorMut, VectorIte... | true |
ea002f82c8be61c6c03793d16c004b7a40cebb24 | Rust | robjtede/async-graphql | /src/types/external/string.rs | UTF-8 | 1,356 | 2.78125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::parser::types::Field;
use crate::{
registry, ContextSelectionSet, InputValueError, InputValueResult, OutputValueType, Positioned,
Result, Scalar, ScalarType, Type, Value,
};
use std::borrow::Cow;
/// The `String` scalar type represents textual data, represented as UTF-8 character sequences. The Stri... | true |
7a64fd4e23831e8a4e855019e8dd273c286c9034 | Rust | razvanoita/electrum | /src/world/mod.rs | UTF-8 | 5,054 | 2.890625 | 3 | [] | no_license |
use crate::components;
pub struct World {
pending_mask: Option<u32>,
pending_components: Vec<components::Component>,
last_build_entity: Option<components::Entity>,
pub transform_storage: Vec<components::TransformStorageEntry>,
pub mesh_storage: Vec<components::MeshStorageEntry>,
pub velocity_... | true |
4a23de79f8a42fef52289161ad1079ea99d06097 | Rust | Logicalshift/safas | /src/parse/parser.rs | UTF-8 | 14,921 | 3.171875 | 3 | [
"Apache-2.0"
] | permissive | use super::error::*;
use super::tokenizer::*;
use super::read_buffer::*;
use super::file_location::*;
use crate::meta::*;
use smallvec::*;
use std::result::{Result};
///
/// Parses a file in SAFAS format and returns the resulting cell
///
pub fn parse_safas<Chars: Iterator<Item=char>>(code: &mut TokenReadBuffer<Char... | true |
a3c6f28f37f35b2c1d52ad126a642b898f266b81 | Rust | Frozen/rustnode1 | /src/crypto/signature.rs | UTF-8 | 1,104 | 3.265625 | 3 | [] | no_license | use crate::errors::ConvertError;
use rust_base58::{FromBase58, ToBase58};
use std::convert::TryFrom;
const SIGNATURE_SIZE: usize = 64;
pub struct Signature([u8; SIGNATURE_SIZE]);
impl TryFrom<&str> for Signature {
type Error = ConvertError;
fn try_from(value: &str) -> Result<Self, Self::Error> {
let... | true |
19c80e0f6efd9f706de52880fd7a7d8b46c5d419 | Rust | poetinger/Web-Engineering | /backend/src/bin/dump_db.rs | UTF-8 | 5,456 | 2.625 | 3 | [] | no_license | extern crate rocket_corgis;
use corgis_dataset::airlines;
use diesel::prelude::*;
use diesel::result::DatabaseErrorKind::UniqueViolation;
use diesel::result::Error::DatabaseError;
use log::info;
use rocket_corgis::database::*;
fn main() -> Result<(), diesel::result::Error> {
// Initialize the logger.
pretty_e... | true |
0dd679c5ffe972edba4c4a2b4cdf99b30e53e78e | Rust | rustonaut/prompty | /src/plugin_impl/terminal.rs | UTF-8 | 11,177 | 2.625 | 3 | [] | no_license | use std::{
io::{self, Write},
ops::Range,
cmp::min,
iter::Peekable
};
use crate::{
iface::{TerminalPlugin, FormatLike},
config
};
use smallvec::{smallvec, SmallVec};
use terminfo::{expand, Database, capability as cap};
// pub const CORNER_SW: char = '╗';
const CORNER_SE: char = '╔';
const COR... | true |
38b2735f55410b798f3d32022ef8be885041f0ce | Rust | wolfiestyle/rtk | /core/src/geometry/rect.rs | UTF-8 | 7,483 | 3.28125 | 3 | [
"MIT"
] | permissive | use crate::geometry::{Border, Point, Position, Size};
/// Defines a rectangle.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
#[repr(C)]
pub struct Rect {
/// Position of the top left corner.
pub pos: Position,
/// Rectangle size.
pub size: Size,
}
impl Rect {
#[inline]
pub fn new... | true |
14e2895e0f19813d2743f8cbcc823939e71b0208 | Rust | oshunter/fuchsia | /src/sys/pkg/lib/fuchsia-archive/src/write.rs | UTF-8 | 5,415 | 2.5625 | 3 | [
"BSD-3-Clause"
] | permissive | // Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
crate::{
align, DirectoryEntry, Error, Index, IndexEntry, CONTENT_ALIGNMENT, DIRECTORY_ENTRY_LEN,
DIR_CHUNK, DIR_NAMES_CHUNK, IND... | true |
002e08ed99d15c14e8d3ae499287fbdb60f8af43 | Rust | Felmoks/diesel | /diesel/src/query_dsl/filter_dsl.rs | UTF-8 | 2,653 | 3.265625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use expression_methods::*;
use helper_types::Filter;
use query_builder::{AsQuery, Query};
use query_source::*;
/// Adds to the `WHERE` clause of a query. If there is already a `WHERE` clause,
/// the result will be `old AND new`. This is automatically implemented for the
/// various query builder types.
///
/// # Exam... | true |
26c91ee4e886d144d91b9cdc14f8a358659fa547 | Rust | endlmk/nand2tetris | /08/VMtranslator/src/main.rs | UTF-8 | 3,550 | 2.796875 | 3 | [] | no_license | use std::fs;
use std::env;
use std::path;
mod parser;
mod codeWriter;
fn main() -> Result<(), std::io::Error> {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
println!("not enough arguments");
return Ok(());
}
let input = path::Path::new(&args[1]);
if input.is_... | true |
a84aab709a3a97bdf9e8c9702e51d741c57074f1 | Rust | TimoFreiberg/live-coding-channel | /src/channel.rs | UTF-8 | 756 | 3.1875 | 3 | [] | no_license | use std::sync::Arc;
use crate::ring_buffer::RingBuffer;
#[derive(Clone)]
// this is bad
pub struct Channel<T> {
buffer: Arc<RingBuffer<T>>,
}
impl<T> Channel<T> {
pub fn new(capacity: usize) -> Self {
Self {
buffer: Arc::new(RingBuffer::new(capacity)),
}
}
pub fn try_send(... | true |
737133f774289161b7f6bb016576fc25d30dc72b | Rust | rob-solana/rse-benchmark | /reed-solomon-erasure/src/matrix.rs | UTF-8 | 7,511 | 3.09375 | 3 | [
"MIT"
] | permissive | #![allow(dead_code)]
use smallvec::SmallVec;
use galois;
#[derive(Debug)]
pub enum Error {
SingularMatrix,
}
macro_rules! acc {
(
$m:ident, $r:expr, $c:expr
) => {
$m.data[$r * $m.col_count + $c]
}
}
pub fn flatten<T>(m : Vec<Vec<T>>) -> Vec<T> {
let mut result : Vec<T> =
... | true |
2234591cc01c419d87bee19107b16087951d1bc2 | Rust | winterthediplomat/hrm-interpreter | /src/operators/outbox.rs | UTF-8 | 393 | 2.53125 | 3 | [] | no_license | use operators::Operator;
use state::InternalState;
pub struct OutboxOp {
}
impl Operator for OutboxOp {
fn changes_instruction_counter(&self) -> bool { false }
fn apply_to(&self, s: &mut InternalState) -> Result<(), String> {
if let Some(value) = s.register {
s.output_tape.push(value);
Ok(())
}
else {
... | true |
baafd05a9868fa118851e104edbb8e546edd5e7b | Rust | spaihippo/cryptopals | /src/attacks/block.rs | UTF-8 | 10,997 | 3 | 3 | [] | no_license | //! Implementations of cryptographic attacks against block ciphers.
use utils::data::Data;
use utils::metrics;
use victims::block::{EcbOrCbc, EcbWithSuffix, EcbWithAffixes, EcbUserProfile, CbcCookie};
/// Determine whether a block cipher is using ECB or CBC mode.
///
/// Given a black box which encrypts (padded) user... | true |
96983b61e38e97cbb09d044a77c8a4f7456f7016 | Rust | DoctorAlpaca/rust-sfml | /src/network/tcp_listener.rs | UTF-8 | 5,118 | 2.6875 | 3 | [
"Zlib"
] | permissive | /*
* Rust-SFML - Copyright (c) 2013 Letang Jeremy.
*
* The original software, SFML library, is provided by Laurent Gomila.
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from
* the use of this software.
*
* Permission... | true |
8efed94ca824e6412a4cfdd54de596455b52b4d1 | Rust | lopez86/rust-mlearn | /src/metrics.rs | UTF-8 | 1,762 | 3.109375 | 3 | [] | no_license | //! # Metrics
//!
//! `metrics` provides various evaluation metrics.
extern crate ndarray;
extern crate ndarray_linalg;
use ndarray::{ArrayBase, Data, Ix1, NdFloat};
/// Calculate the mean squared error (L2 loss) between two arrays.
pub fn mean_squared_error<T, S1, S2>(
truth: &ArrayBase<S1, Ix1>,
... | true |
44a73f1618f1a03dda4e4dee99af11567fe923ce | Rust | jpbogle/nexus | /solana-string/program/src/lib.rs | UTF-8 | 2,047 | 2.875 | 3 | [] | no_license | use borsh::{BorshDeserialize, BorshSerialize};
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint,
entrypoint::ProgramResult,
log::{sol_log_params, sol_log_slice},
msg,
program_error::ProgramError,
pubkey::Pubkey,
borsh::try_from_slice_unchecked,
};
pub tra... | true |
ae1dcbcc9a39a51c687be725a5e409631a66990b | Rust | silvia-odwyer/gdl | /crate/src/resize.rs | UTF-8 | 3,728 | 3.28125 | 3 | [
"Apache-2.0"
] | permissive | //! Resize images to specific sizes/for various social media platforms.
use crate::{helpers, PhotonImage};
use image::GenericImageView;
use wasm_bindgen::prelude::*;
/// Resize an image for a particular format on social media.
/// Available formats include: pinterest, fb_ad, fb_post, instagram_post, twitter_header, l... | true |
9f8439fb9a83469891e60b1456ba63081c0cf7f8 | Rust | marc47marc47/leetcode-cn | /697findShortestSubArray/find_shortest_sub_array/src/lib.rs | UTF-8 | 1,391 | 3.171875 | 3 | [] | no_license | use std::collections;
use collections::HashMap;
/*
* @Description:
* @Version: 2.0
* @Author: kingeasternsun
* @Date: 2021-02-20 11:55:00
* @LastEditors: kingeasternsun
* @LastEditTime: 2021-02-20 16:12:45
* @FilePath: \697findShortestSubArray\find_shortest_sub_array\src\lib.rs
*/
pub struct Solution;
impl S... | true |
93ef00cba336439c45c4d6be323ae437641f8d35 | Rust | mongodb/mongo-odbc-driver | /core/src/err.rs | UTF-8 | 4,978 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | use constants::{
GENERAL_ERROR, INVALID_CURSOR_STATE, INVALID_DESCRIPTOR_INDEX, NO_DSN_OR_DRIVER,
TIMEOUT_EXPIRED, UNABLE_TO_CONNECT,
};
use mongodb::error::{BulkWriteFailure, ErrorKind, WriteFailure};
use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Error, Debug, Clone)]
pub... | true |
9b78841e9bd3930ae9e7652fc3e7d1564b3f37e5 | Rust | Perseus101/RustDAG | /lib/resources/test/contracts/source/api_test.rs | UTF-8 | 2,710 | 2.625 | 3 | [] | no_license | mod api {
mod sys {
extern {
pub fn api_get_u32(index: u32) -> u32;
pub fn api_get_u64(index: u32) -> u64;
pub fn api_get_f32(index: u32) -> f32;
pub fn api_get_f64(index: u32) -> f64;
pub fn api_get_mapping(index: u32, key: u64) -> u64;
... | true |
04da1c20299c496908850a682e8cf2de85587b22 | Rust | odidev/advent-of-code | /crates/core/src/year2020/day16.rs | UTF-8 | 5,902 | 2.96875 | 3 | [
"MIT"
] | permissive | use crate::input::Input;
pub fn solve(input: &mut Input) -> Result<u64, String> {
const MAX_FIELD_VALUE: u32 = 1024;
let mut parts = input.text.splitn(3, "\n\n");
let on_error = || "Invalid input".to_string();
let map_error = |_| on_error();
let ticket_fields_str = parts.next().ok_or_else(on_erro... | true |
962066783021000255dd6765e9a2bca53ce600e9 | Rust | victormasson/MidiMaker | /src/midi/music/note_duration.rs | UTF-8 | 720 | 3.65625 | 4 | [
"MIT"
] | permissive | #[derive(Debug)]
pub enum NoteDuration {
Whole,
Half,
Quarter,
Eighth,
Sixteenth,
ThirtySecond,
SixtyFourth,
HundredTwentyEighth,
}
impl NoteDuration {
pub fn get_value(self, tempo: u8) -> u8 {
match self {
NoteDuration::Whole => (tempo * 1),
NoteDura... | true |
4e26e49023f860abf40173d275f84ca867dff6d9 | Rust | fteychene/lottery-jug-actix | /lottery/src/eventbrite/events.rs | UTF-8 | 3,763 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | use reqwest;
use failure::Error;
use super::errors::EventbriteError;
use super::model::{Event, EventsResponse};
use super::EVENTBRITE_BASE_URL;
fn events_url(organizer: &str, token: &str) -> String {
format!("{base_url}/v3/organizations/{organizer}/events/?status=live&order_by=start_desc&token={token}", base_url ... | true |
d9a450955fb18edfeb3979f7a2a595900f4278c5 | Rust | gmadrid/fdown | /src/args.rs | UTF-8 | 4,242 | 3.125 | 3 | [] | no_license | use clap::{App, Arg, ArgMatches};
use result::{FdownError, Result};
use std::env;
use std::ffi::OsString;
const CONFIG: &'static str = "config";
const COUNT: &'static str = "count";
const CATEGORY: &'static str = "category";
const DEFAULT_CONFIG: &'static str = "~/.fdown";
const SUBS: &'static str = "subs";
const UNSA... | true |
dd0dd0418ac6d6b8e350c55fc658436686bf8a44 | Rust | badboy/glean-gen | /glean/src/metrics.rs | UTF-8 | 236 | 2.9375 | 3 | [] | no_license | #[derive(Debug)]
pub struct StringMetric;
impl StringMetric {
pub fn new() -> Self {
Self
}
pub fn set<S: Into<String>>(&self, value: S) {
println!("Setting string metric to: {:?}", value.into());
}
}
| true |
78ae8151c69b172c4e01f5b30297c3fd5dfcc337 | Rust | Dentosal/aw-server-rust | /aw-models/src/duration.rs | UTF-8 | 634 | 3.03125 | 3 | [] | no_license | use chrono;
// Max duration of a i64 nanosecond is 2562047.7880152157 hours
// ((2**64)/2)/1000000000/60/60
fn get_nanos(duration: &chrono::Duration) -> f64 {
return (duration.num_nanoseconds().unwrap() as f64)/1000000000.0
}
#[derive(Serialize, Deserialize)]
#[serde(remote = "chrono::Duration")]
pub struct Dura... | true |
bffcddc0f7ac4eb8699201983daea60e3e3bafb8 | Rust | nhsconnect/prm-deductions-support-infra | /redactor/src/digit_sequence_finder.rs | UTF-8 | 422 | 2.96875 | 3 | [] | no_license | pub fn find_digit_sequences(num_digits: usize, line: & String) -> Vec<usize> {
let mut sequences = Vec::new();
let mut digits = 0;
for (i, c) in line.chars().enumerate() {
if c.is_digit(10) {
digits += 1;
}
else {
if digits == num_digits {
sequ... | true |
be9dbab5812eabe225b811acf86c8870bc1eb9f1 | Rust | hinagis/abl | /src/bin/c.rs | UTF-8 | 1,430 | 2.921875 | 3 | [] | no_license | use proconio::{input, marker::Usize1};
fn main() {
input! {
n: usize,
m: usize,
}
let mut dsu = DSU::new(n + 1);
for _ in 0..m {
input!{a: Usize1, b: Usize1}
dsu.merge(a, b);
}
let mut h = std::collections::HashSet::new();
for i in 0..n {
h.insert(ds... | true |
a56c7401f4c7450e138bb1a79e3905f6b69e07cc | Rust | gefjon/sir | /src/cli.rs | UTF-8 | 3,568 | 2.890625 | 3 | [
"MIT"
] | permissive | use calculations::{SirInteger, SirNumeric};
use clap::{App, Arg, ArgGroup};
use std::path::PathBuf;
pub struct Args {
pub beta: SirNumeric,
pub gamma: SirNumeric,
pub susceptible: Option<SirNumeric>,
pub infected: SirNumeric,
pub total_pop: Option<SirNumeric>,
pub n_days: SirInteger,
pub fi... | true |
b8190b3a47637b975e34c02eae8f8cb414e7b405 | Rust | orrinjelo/rust-learning-projects | /beginner/triangle/src/main.rs | UTF-8 | 630 | 2.6875 | 3 | [] | no_license | use rustop::opts;
fn main() {
let (args, _rest) = opts! {
synopsis "Print a starry triangle.";
opt skip:bool, desc:"Skip lines.";
opt reverse:bool, desc:"Reverse the triangle";
param num:u32, desc:"Max stars in large side of triangle.";
}.parse_or_exit();
for i in 1..args.n... | true |
4cdaf1bcc7278ec6f7e909853c71a866c467408f | Rust | xinaesthete/shp-contour-wasm | /src/lib.rs | UTF-8 | 8,854 | 2.515625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | mod utils;
mod math;
use std::io;
// use std::io::*; //woe betide
// use std::time::{Duration, SystemTime, UNIX_EPOCH};
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use wasm_bindgen_futures::JsFuture;
use web_sys::{DedicatedWorkerGlobalScope, Request, RequestInit, RequestMode, Response};
use shapefile::dbas... | true |
49456f79d3429716b7a6788c0612ce8e22532258 | Rust | nickx720/base64_implementation_encoder_decoder | /src/encoder.rs | UTF-8 | 1,486 | 3.40625 | 3 | [] | no_license | use crate::alphabet::{Alphabet, Classic};
use std::iter::FromIterator;
pub fn encode(data: &[u8]) -> String {
let classic_alphabet = &Classic {};
encode_using_alphabet(classic_alphabet,data)
}
fn split(chunk: &[u8]) -> Vec<u8> {
// shuffling bits around
match chunk.len(){
1 => vec![
... | true |
24294045697fa5f860f45dd7a79fbf33dd677a12 | Rust | ziyi-yan/enarx | /sallyport/src/lib.rs | UTF-8 | 6,569 | 3 | 3 | [
"Apache-2.0"
] | permissive | // SPDX-License-Identifier: Apache-2.0
//! This crate represents the hypervisor-microkernel boundary. It contains a number
//! of a shared structures to help facilitate communication between the two entities.
#![deny(missing_docs)]
#![deny(clippy::all)]
#![no_std]
//! The `proxy` module contains structures used to f... | true |
9ca83aa08ed805114fc0c128f63230b069431812 | Rust | IThawk/rust-project | /rust-master/src/test/ui/iterators/iter-map-fold-type-length.rs | UTF-8 | 826 | 3.328125 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // run-pass
//! Check that type lengths don't explode with `Map` folds.
//!
//! The normal limit is a million, and this test used to exceed 1.5 million, but
//! now we can survive an even tighter limit. Still seems excessive though...
#![type_length_limit = "256000"]
// Custom wrapper so Iterator methods aren't specia... | true |
2c7c14a9670d9d0e88b519e468a0379cd9d05dca | Rust | soydos/pusoy_dos2 | /src/game/round.rs | UTF-8 | 54,161 | 2.953125 | 3 | [
"MIT"
] | permissive | use super::{
compare_hands,
Hand,
Player,
Trick,
TrickType,
Ruleset,
};
use crate::cards::{Card, PlayedCard, Rank, Suit};
use serde::{Deserialize, Serialize};
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub enum SubmitError {
FirstRoundPass,
FirstHandMustContainLowestCard,
H... | true |
8f404dc718581ba04019e6df922ccb61affc7585 | Rust | scratchyone/roux.rs | /src/subreddit/mod.rs | UTF-8 | 3,133 | 3.53125 | 4 | [
"MIT"
] | permissive | //! # Subreddit
//! A read-only module to read data from a specific subreddit.
//!
//! # Usage
//! ```rust,no_run
//! use roux::Subreddit;
//! let subreddit = Subreddit::new("subreddt_name");
//! // Now you are able to:
//! // Get moderators.
//! let moderators = subreddit.moderators();
//! // Get hot posts with limit ... | true |
17b05112b9b021ed3c5cfc42619f8eadd7c595a4 | Rust | cw2030/rbatis | /src/plugin/slow_sql.rs | UTF-8 | 1,908 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | use std::collections::LinkedList;
use std::fs;
use std::fs::File;
use std::io::{BufRead, BufReader};
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct SqlLog {
pub sql: String,
pub return_data: String,
pub second: i64,
}
pub fn fi... | true |
218c20e7e438b31b6e2083bd85e9e3281dda29ac | Rust | jzhang113/rust-term | /src/term/term.rs | UTF-8 | 8,550 | 2.890625 | 3 | [
"MIT"
] | permissive | extern crate image;
use glium::glutin;
use glium::Surface;
use std::fs::File;
use std::io::prelude::*;
use crate::term::layer::Cell;
use crate::term::layer::Layer;
pub struct Term {
front: Layer,
back_color: [f32; 4],
pub width: u32,
pub height: u32,
pub cell_width: f64,
pub c... | true |
a4c1bd46d23bb43b9bbc7740ecfb804dc8bcf2dc | Rust | sccommunity/crates-sgx | /crates/sval/json/src/lib.rs | UTF-8 | 2,845 | 3.296875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | /*!
JSON support for `sval`.
This library is no-std, so it can be run in environments
that don't have access to an allocator.
# Getting started
Add `sval_json` to your `Cargo.toml`:
```toml,ignore
[dependencies.sval_json]
version = "0.5.1"
```
# Writing JSON to `fmt::Write`
```no_run
# #[cfg(not(feature = "std"))... | true |
bc74f3167d4e5a3267292af09493232b3f143b04 | Rust | mapkts/ray-tracing | /src/macros.rs | UTF-8 | 693 | 2.53125 | 3 | [
"MIT"
] | permissive | //! Macro definitions.
#[allow(unused)]
use crate::prelude::{Point3, Rgb, Vec3};
/// A convenient macro to generate Vec3<f64>.
#[macro_export]
macro_rules! v3 {
($x:literal $(,)? $y:literal $(,)? $z:literal $(,)?) => {
Vec3::new($x as f64, $y as f64, $z as f64)
};
}
/// A convenient macro to generate ... | true |
0203ed202dd60cc3de3da93e9c07b89bf94adaeb | Rust | aoowweenn/osu-rs | /src/traits.rs | UTF-8 | 2,587 | 3.046875 | 3 | [
"MIT"
] | permissive | use std;
pub trait StructMap {
fn from_hashmap(&std::collections::HashMap<&str, &str>) -> Self;
fn from_vec(v: Vec<&str>) -> Self;
fn from_tuples(pairs: Vec<(&str, &str)>) -> Self
where Self: std::marker::Sized
{
let map: std::collections::HashMap<&str, &str> = pairs.into_iter().collect... | true |
e4318d0f82a9a9e27c0397559200a55bae9ba975 | Rust | gridaphobe/rsat | /src/lib.rs | UTF-8 | 13,722 | 3.625 | 4 | [] | no_license | #[derive(Debug, PartialEq, Eq)]
pub enum Term {
Lit(bool),
Var(String),
Not(Box<Term>),
And(Box<Term>, Box<Term>),
Or(Box<Term>, Box<Term>),
}
use Term::*;
pub fn lit(b: bool) -> Term {
Lit(b)
}
pub fn var(x: &str) -> Term {
Var(x.to_string())
}
pub fn not(t: Term) -> Term {
Not(Box::n... | true |
050d8baca2ba163c6d9b3f099fa8a095e294aa3d | Rust | qipanyang/in-app-messaging-rust | /src/handlers/message.rs | UTF-8 | 3,689 | 2.765625 | 3 | [] | no_license | use crate::database::PoolType;
use crate::errors::ApiError;
use crate::helpers::{respond_json, respond_ok};
use crate::models::content::{create as createContent, NewContent};
use crate::models::message::{create, find, Message, NewMessage};
use crate::models::user::find as findUser;
use crate::validate::validate;
use ac... | true |
cdbe6eb8883775ca5f6db5e2cfb0a6b10fdf6150 | Rust | lore-lml/bioenpro4to_gateway | /src/database/models/actors.rs | UTF-8 | 1,719 | 2.5625 | 3 | [] | no_license | use tokio_pg_mapper_derive::PostgresMapper;
use serde::{Serialize, Deserialize};
use bioenpro4to_channel_manager::channels::Category;
#[derive(PostgresMapper, Serialize, Deserialize)]
#[pg_mapper(table="bioenpro4to.actors")]
pub struct Actor{
id: String,
#[serde(skip_serializing)]
psw: String,
did: Str... | true |
b7e867efdc8461ffd91098a546bc50ef694942b8 | Rust | iCodeIN/soft-rend | /src/geometry.rs | UTF-8 | 1,913 | 3.546875 | 4 | [] | no_license | use std::io::BufReader;
use std::io::prelude::*;
use std::fs::File;
pub struct Point<T> {
pub x: T,
pub y: T,
}
impl<T> Point<T> {
pub fn new(x: T, y: T) -> Self {
Self { x, y }
}
}
impl Point<i32> {
pub fn convert_to_f32(&self) -> Point<f32> {
Point {
x: self.x as f3... | true |
a3cc85e710c4ee5d2766381f577989c13a8d1028 | Rust | amethyst/ludumdare42 | /amethyst/amethyst_core/src/frame_limiter.rs | UTF-8 | 8,470 | 3.984375 | 4 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Frame rate limiting.
//!
//! An amethyst [`Application`] runs in a loop, executing game update logic each frame. In
//! order to reduce CPU usage and keep frame timing predictable, amethyst uses a configurable
//! frame limiting strategy to introduce a delay before starting each frame if the previous
//! frame comp... | true |
9b28efec53fcdde06d87e85a63bed6e0e09a5770 | Rust | stuartstein777/CodeWars | /8KYU/Quadrants/solution.rs | UTF-8 | 199 | 2.859375 | 3 | [] | no_license | fn quadrant(x: i32, y: i32) -> i32 {
if(x > 0 && y > 0) {
return 1;
}
if(x < 0 && y > 0) {
return 2;
}
if(x < 0 && y < 0) {
return 3;
}
return 4;
} | true |
2900056bc161ea7be63edb17099f3d310fd53b8c | Rust | devforfu/rust | /concurrency/src/main.rs | UTF-8 | 646 | 2.65625 | 3 | [] | no_license | mod channels;
use std::thread;
use std::time::Duration;
use rand::Rng;
fn main() {
let mut rng = rand::thread_rng();
let durations: Vec<u64> = (1..10).map(|x| rng.gen_range(1, x+1)).collect();
let handle = thread::spawn(move || {
for j in 1..10 {
let duration = durations[j-1];
... | true |
2bc5034a3ca8e5ded4c3425a008bfd2417d31a8a | Rust | RustPanda/hello-state-maschine | /src/main.rs | UTF-8 | 2,695 | 3.53125 | 4 | [] | no_license |
//ОбЪявим возможные сос state: () state: ()тояния StateMaschine
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
struct Follower {
a: i32,
}
impl Follower {
fn new(a: i32) -> Follower {
Follower { a }
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
struct Condidate {
a: i32,
}
#[derive(Debug, Co... | true |
7408e690abbbf34d6b8b82b8936335643d915e4c | Rust | andrrff/fltk-rs | /fltk/src/utils.rs | UTF-8 | 1,888 | 3.25 | 3 | [
"MIT"
] | permissive | use std::ffi::CString;
pub(crate) trait FlString {
fn safe_new(s: &str) -> CString;
}
impl FlString for CString {
fn safe_new(s: &str) -> CString {
match CString::new(s) {
Ok(v) => v,
Err(r) => {
let i = r.nul_position();
CString::new(&r.into_vec... | true |
d2ee972656fc95c8a51bba8d009d7a0bfc287e7e | Rust | tiger1710/didactic-octo-funicular | /source/rust-code/acmicpc/6600/6603.rs | UTF-8 | 996 | 3.125 | 3 | [] | no_license | // 6603 로또
use std::collections::BTreeSet;
use std::fmt::Write;
use std::io;
fn op(v: &[usize], set: &mut BTreeSet<usize>, output: &mut String) {
if set.len() == 6 {
for num in set.iter() {
write!(output, "{num} ").unwrap();
}
writeln!(output, "").unwrap();
return;
}... | true |
8bca26d8e0ce45df8c12bbf709024672fd8c5d75 | Rust | kosslab-kr/rust | /src/librustc_trans/symbol_map.rs | UTF-8 | 4,550 | 2.515625 | 3 | [
"MIT",
"Apache-2.0",
"NCSA",
"ISC",
"LicenseRef-scancode-public-domain",
"BSD-3-Clause",
"BSD-2-Clause",
"Unlicense",
"LicenseRef-scancode-other-permissive"
] | permissive | // Copyright 2016 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 |
fb3a722194513d475b85cce9e95116e6df5b2340 | Rust | AlisCode/utopia | /utopia_core/src/controllers/mod.rs | UTF-8 | 2,866 | 2.765625 | 3 | [] | no_license | use crate::{
math::{Size, Vector2},
widgets::{TypedWidget, Widget},
Backend,
};
pub mod click;
/// A Controller is a bit of logic that reacts to a specific Event type.
pub trait Controller<T, W: Widget<T>> {
type Event;
type Reaction;
fn event(
&mut self,
child: &mut W,
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.