Implement Schema::attribute_for_ident.
This commit is contained in:
parent
16e9740d8a
commit
b165a0b2ad
2 changed files with 10 additions and 0 deletions
|
@ -6,3 +6,5 @@ version = "0.0.1"
|
||||||
num = "0.1.35"
|
num = "0.1.35"
|
||||||
ordered-float = "0.4.0"
|
ordered-float = "0.4.0"
|
||||||
|
|
||||||
|
[dependencies.edn]
|
||||||
|
path = "../edn"
|
||||||
|
|
|
@ -8,10 +8,12 @@
|
||||||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||||
// specific language governing permissions and limitations under the License.
|
// specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
extern crate edn;
|
||||||
extern crate ordered_float;
|
extern crate ordered_float;
|
||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use self::ordered_float::OrderedFloat;
|
use self::ordered_float::OrderedFloat;
|
||||||
|
use self::edn::NamespacedKeyword;
|
||||||
|
|
||||||
/// Core types defining a Mentat knowledge base.
|
/// Core types defining a Mentat knowledge base.
|
||||||
|
|
||||||
|
@ -224,6 +226,12 @@ impl Schema {
|
||||||
self.schema_map.get(&x)
|
self.schema_map.get(&x)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn attribute_for_ident(&self, ident: &NamespacedKeyword) -> Option<&Attribute> {
|
||||||
|
let s = ident.to_string(); // TODO: don't do this. #291.
|
||||||
|
self.get_entid(&s)
|
||||||
|
.and_then(|x| self.attribute_for_entid(x))
|
||||||
|
}
|
||||||
|
|
||||||
/// Return true if the provided entid identifies an attribute in this schema.
|
/// Return true if the provided entid identifies an attribute in this schema.
|
||||||
pub fn is_attribute(&self, x: Entid) -> bool {
|
pub fn is_attribute(&self, x: Entid) -> bool {
|
||||||
self.schema_map.contains_key(&x)
|
self.schema_map.contains_key(&x)
|
||||||
|
|
Loading…
Reference in a new issue